286 Commits

Author SHA1 Message Date
Râu Cao
6acc3f2f59 0.7.0
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-20 18:49:38 +02:00
7987e92723 Merge pull request 'Offer LNURL QR code for download on Lightning info page' (#135) from feature/lightning_donation_qr_codes into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #135
Reviewed-by: slvrbckt <slvrbckt@noreply.kosmos.org>
Reviewed-by: bumi <bumi@noreply.kosmos.org>
2023-06-20 16:44:58 +00:00
Râu Cao
d922e7f869 Resolve review comment
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 3s
2023-06-20 18:18:14 +02:00
Râu Cao
89c67f3617 Merge branch 'master' into feature/lightning_donation_qr_codes
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-06-18 15:51:38 +02:00
1b959b5643 Merge pull request 'Let users add a verified nostr pubkey to their account' (#101) from feature/98-nostr_nip05 into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #101
2023-06-16 13:04:24 +00:00
Râu Cao
4551a14362 Fix path
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 4s
2023-06-16 14:55:11 +02:00
Râu Cao
bfc0969829 Improve wording
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-06-16 14:39:28 +02:00
Râu Cao
a1be338ba1 Add hint for updating nostr profiles when pubkey is added 2023-06-16 14:39:26 +02:00
Râu Cao
589e46bc63 Replace hardcoded domains with primary domain setting 2023-06-16 14:38:04 +02:00
Râu Cao
34e4cec503 Add NIP-05 well-known endpoint 2023-06-16 14:37:16 +02:00
Râu Cao
c48538a1c6 Add primary domain setting 2023-06-16 14:37:15 +02:00
Râu Cao
2cced696f5 Don't try to access target when it doesn't exist 2023-06-16 14:35:57 +02:00
Râu Cao
beaafa5d7e Make nostr pubkey unique globally 2023-06-16 14:35:56 +02:00
Râu Cao
9cf309aaa8 Prevent mounting of checked-in vendored files
Mount bundle cache specifically on `vendor/cache` instead of all of
`vendor`, which prevents access to vendored javascript code for example.
2023-06-16 14:34:34 +02:00
Râu Cao
e8bbe6c713 Let user remove nostr pubkey from account 2023-06-16 14:34:32 +02:00
Râu Cao
49de4007ab Settings page for adding verified nostr pubkeys 2023-06-16 14:22:30 +02:00
Râu Cao
bc4d9ff528 Add nostr_pubkey to users 2023-06-16 13:52:42 +02:00
Râu Cao
b03c6e9513 Support vendoring npm module code 2023-06-16 13:51:09 +02:00
Râu Cao
332ad757a5 Use respond_to for request formats
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-06-13 12:30:38 +02:00
Râu Cao
07fe8dba71 Add a copy button for the Lightning address
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Same as on profile settings page.
2023-06-12 18:18:47 +02:00
Râu Cao
aedaabc7ba Offer lnurl-pay QR codes for download on the Lightning page 2023-06-12 18:18:06 +02:00
Râu Cao
8eb5f093a4 Don't show flash message when opening the root URL while signed out 2023-06-08 08:04:23 +03:00
de45d070aa Merge pull request 'Report Lndhub API errors to Sentry' (#133) from refactor/lndhub_integration into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #133
2023-06-06 15:44:36 +00:00
c0b1112e49 Merge pull request 'Hide unsuccessful outgoing lndhub txs in list' (#132) from bugfix/lndhub_tx_list into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #132
2023-06-06 15:43:38 +00:00
Râu Cao
2f90393eb6 Lndhub v2 service inherits from v1, only adds v2-specific code
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 3s
2023-06-05 13:53:24 +03:00
Râu Cao
8b87072485 Raise custom auth error, re-raise on failed re-auth 2023-06-05 13:52:41 +03:00
Râu Cao
82019f47be Report lndhub errors to Sentry 2023-06-05 13:51:59 +03:00
Râu Cao
259e72167b Hide unsuccessful outgoing lndhub txs in list
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 4s
2023-06-05 13:06:49 +03:00
Râu Cao
7000908891 Auto-login Discourse link
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-04 15:15:09 +03:00
Râu Cao
df0c13b400 Fix potential nil access
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-31 14:43:00 +02:00
Râu Cao
387a2fa2e6 0.6.0
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-31 14:12:26 +02:00
68eba80fd7 Merge pull request 'Integrate Discourse Connect (SSO)' (#131) from feature/126_discourse_sso into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #131
2023-05-31 10:02:43 +00:00
Râu Cao
7e05530ab7 Add specs for Discourse Connect
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 3s
2023-05-31 12:00:33 +02:00
Râu Cao
745a319b3d Minor refactoring 2023-05-31 12:00:31 +02:00
Râu Cao
f829bb3379 Use devise method for requiring login 2023-05-31 12:00:02 +02:00
Râu Cao
19bafe081f Integrate Discourse Connect (SSO) 2023-05-31 12:00:02 +02:00
d130f2f68b Merge pull request 'Allow users to set/update their display name in LDAP' (#128) from feature/123-display_names into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #128
Reviewed-by: greg <greg@noreply.kosmos.org>
2023-05-31 09:13:50 +00:00
Râu Cao
e284996c1c Remove obsolete route
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 4s
2023-05-28 15:28:51 +02:00
Râu Cao
51489a83ab Use feature block for email update specs
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-05-28 15:25:53 +02:00
Râu Cao
05426e4ced Add specs for display name update 2023-05-28 15:25:42 +02:00
Râu Cao
445cdfa024 Only validate display name when updated
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Otherwise we needlessly fetch the validated one from LDAP every time a
model is saved.
2023-05-27 20:11:01 +02:00
Râu Cao
f74227fedb Allow users to set/update their display name in LDAP
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-05-27 19:59:49 +02:00
Râu Cao
32d1992632 Set user instance var for settings routes where needed 2023-05-27 19:58:59 +02:00
48be35f1b1 Merge pull request 'Allow updating one's email address on the account settings page' (#127) from feature/103-update_email into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #127
Reviewed-by: greg <greg@noreply.kosmos.org>
2023-05-26 18:07:07 +00:00
87720ef285 Merge pull request 'Add feature flags' (#125) from feature/124-feature_flags into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #125
Reviewed-by: greg <greg@noreply.kosmos.org>
2023-05-26 17:56:50 +00:00
Râu Cao
193a4c2edd Remove obsolete function argument
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 4s
2023-05-25 19:31:16 +02:00
Râu Cao
134c81460a Allow email address updates on account settings page
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-05-25 16:58:53 +02:00
Râu Cao
b1a693e7cf Send different Devise mail for re-confirmations 2023-05-25 16:58:45 +02:00
Râu Cao
75bd879f84 Rename settings menu item for Lightning 2023-05-25 16:57:14 +02:00
Râu Cao
33a9e1eaa9 Use username instead of email in Devise mails 2023-05-25 16:56:40 +02:00
Râu Cao
7b321577db Update LDAP mail attribute when re-confirming email 2023-05-25 16:55:27 +02:00
Râu Cao
61f12c2741 Improve form fields with errors for model updates 2023-05-25 16:53:16 +02:00
Râu Cao
c58358c66e Add feature flags, RS dashboard dummy
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 4s
closes #124
refs #94
2023-05-23 19:18:11 +02:00
Râu Cao
287adbd365 Add flipper gem and database migration/tables 2023-05-23 14:09:35 +02:00
Râu Cao
9048052318 Fix URL in email template
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-16 13:22:44 +02:00
cddc1e86f6 Merge pull request 'Show fees of Lightning transactions' (#122) from feature/lightning_fees into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #122
Reviewed-by: hueso <hueso@noreply.kosmos.org>
Reviewed-by: bumi <bumi@noreply.kosmos.org>
2023-05-10 12:27:24 +00:00
Râu Cao
ce7387a409 Remove obsolete routes
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 6s
2023-05-03 21:54:33 +02:00
Râu Cao
f1ae5667de Shape tx details UI a bit
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-05-03 12:51:22 +02:00
Râu Cao
67a9fc02d7 Rename Wallet to Lightning Network, move to Services
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-05-01 16:13:41 +02:00
Râu Cao
34849b28b0 WIP show fees of Lightning transactions 2023-05-01 15:15:23 +02:00
8ce5f9708f Merge pull request 'Add configurable default chatroom bookmarks for new users' (#116) from feature/default_chatrooms into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #116
Reviewed-by: galfert <garret.alfert@gmail.com>
2023-04-19 13:07:00 +00:00
Râu Cao
cb2197893c Merge branch 'master' into feature/default_chatrooms
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 4s
2023-04-18 17:00:48 +02:00
7a50bd23d6 Merge pull request 'Add user preferences and configurable notifications' (#113) from feature/user_preferences into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #113
Reviewed-by: galfert <garret.alfert@gmail.com>
2023-04-11 21:04:46 +00:00
64c8c3cb06 Merge pull request 'WebFinger endpoint' (#118) from feature/webfinger into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #118
Reviewed-by: raucao <raucao@noreply.kosmos.org>
2023-04-11 09:44:39 +00:00
Râu Cao
a2100b23a9 Formatting, wording
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Update release notes draft
2023-04-11 11:41:30 +02:00
27195f693a Merge pull request 'Fix failing spec expectation when using Ruby 3.x' (#119) from fix/ruby-3-failed-expectation into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #119
Reviewed-by: raucao <raucao@noreply.kosmos.org>
2023-04-11 09:32:46 +00:00
9e74c89a80 Fix failing spec expectation when using Ruby 3.x
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Update release notes draft
2023-04-10 23:03:59 +02:00
0774c88918 WebFinger endpoint
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-04-10 21:23:21 +02:00
ef2d2b6422 Merge pull request 'Add remoteStorage settings' (#117) from feature/rs-settings into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #117
Reviewed-by: raucao <raucao@noreply.kosmos.org>
2023-04-09 09:45:19 +00:00
a47e4fc16b Add RS storage URL to test env
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Update release notes draft
2023-04-09 10:12:12 +02:00
9b89101afc Basic RemoteStorage settings
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-04-08 21:49:16 +02:00
Râu Cao
ad90fcd539 Add specs for xmpp default bookmarks, refactor xmpp job usage
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-04-08 16:37:21 +02:00
Râu Cao
705bd63b42 Add configurable default room bookmarks for new users
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-07 23:03:43 +02:00
Râu Cao
83e418cdee Update README
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-07 20:11:45 +02:00
Râu Cao
7a193d6647 Add comment
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-06 16:25:01 +02:00
Râu Cao
bb82b6b462 Update README 2023-04-06 16:24:46 +02:00
Râu Cao
4e2e13108c Refactor user preferences, add defaults from file
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Update release notes draft
* Turn prefs into a flat hash structure, since nesting is not worth the
trouble
* Add a custom serializer class for prefs
* Add a config file for defaults and merge set prefs with unset ones
* Use booleans for "true" and "false", and integers where appropriate
2023-04-05 17:02:35 +02:00
Râu Cao
ca7475dca2 Add notification mailer, make wallet notifications configurable
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-04-04 13:39:32 +02:00
Râu Cao
43a43e1a2c Use setting instead of ENV var
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-04 12:46:09 +02:00
Râu Cao
595bb03c5a Do not exchange XMPP contacts when turned off by inviter
Some checks are pending
continuous-integration/drone/push Build is running
2023-04-04 12:45:13 +02:00
Râu Cao
62cd0eb7d1 Re-rename "ejabberd" service to "xmpp"
Shouldn't matter which implementation is integrated if someone adds
another one
2023-04-04 12:29:39 +02:00
Râu Cao
f19baaf22a Add new user settings pages for Chat and Wallet 2023-04-04 12:28:53 +02:00
Râu Cao
23821f9e65 Add preferences to user model 2023-04-04 12:27:49 +02:00
Râu Cao
a33410eeb4 Allow handing custom field names to toggle fieldset component 2023-04-04 12:03:00 +02:00
Râu Cao
a1b238e86b Fix email default URL options missing
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-04 09:11:06 +02:00
Râu Cao
334b47353e WIP Add notifications preferences page
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-03 13:55:58 +02:00
Râu Cao
6848bd739c Add horizontal layout option for fieldset component 2023-04-03 13:55:39 +02:00
Râu Cao
7f77ad5528 Refactor user settings
All checks were successful
continuous-integration/drone/push Build is passing
Use resources instead of custom controllers, following the Rails way
and making things much cleaner in the process.
2023-04-03 13:19:07 +02:00
6f2160b479 Merge pull request 'Add solargraph in development, document usage with bundled gems' (#112) from feature/solargraph into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #112
2023-04-02 08:19:26 +00:00
Râu Cao
f08bb56a7a 0.5.0
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-01 11:44:25 +02:00
Râu Cao
fe1dfd8ec8 Add solargraph in development, document usage with bundled gems
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Update release notes draft
2023-03-31 18:07:38 +02:00
c1f275463e Merge pull request 'Add Redis, Sidekiq to Docker Compose setup' (#110) from feature/docker-compose_sidekiq into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #110
Reviewed-by: galfert <garret.alfert@gmail.com>
2023-03-31 09:09:46 +00:00
324809f77e Merge pull request 'Expire inactive sessions, optionally allow to stay signed in' (#82) from feature/8-session_timeouts into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #82
Reviewed-by: galfert <garret.alfert@gmail.com>
2023-03-31 07:58:24 +00:00
Râu Cao
f9b07bcb01 Use development branch of release drafter action
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-28 17:27:31 +02:00
Râu Cao
986eb5387c Use release drafter fork with PR ID fix
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-28 17:13:39 +02:00
f76e2c2f14 Merge pull request 'Add Gitea Release Drafter as Gitea Action' (#111) from feature/release_drafter into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #111
2023-03-28 14:21:44 +00:00
Râu Cao
22a7bbe6eb Add Gitea Release Drafter as Gitea Action
All checks were successful
Update release notes draft
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-28 16:17:19 +02:00
18f4deb30f Merge pull request 'Add (optional) Sentry integration' (#108) from feature/sentry_integration into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #108
Reviewed-by: greg <greg@noreply.kosmos.org>
2023-03-28 12:53:00 +00:00
Râu Cao
9f9bf6fd80 Add Redis and Sidekiq to Docker Compose setup
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Update release notes draft
2023-03-28 12:24:58 +02:00
Râu Cao
d2987da70a Send Devise emails via Sidekiq 2023-03-28 12:22:17 +02:00
Râu Cao
6b7a80e23a Make Redis URL configurable 2023-03-28 12:21:54 +02:00
Râu Cao
42b9b27561 Allow external network access
All checks were successful
continuous-integration/drone/push Build is passing
Useful for connecting to services on private networks for example.
2023-03-28 11:38:56 +02:00
Râu Cao
c17c980b69 Prepare for multiple akkounts containers
All checks were successful
continuous-integration/drone/push Build is passing
Initially "web" and "sidekiq"
2023-03-28 11:25:10 +02:00
Râu Cao
f199d5d12a Add (optional) Sentry integration
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
A Sentry DSN can be set via `SENTRY_DSN` and authenticated users will be
tagged with ID and username (cn) in events.
2023-03-27 12:47:28 +02:00
Râu Cao
4b17afa93d Fix typo
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-27 11:55:02 +02:00
Râu Cao
6d52af53ae Add basic storage config
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-27 11:46:39 +02:00
Râu Cao
4c5ad67652 Require action_mailbox
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-27 11:40:59 +02:00
Râu Cao
3437a756eb Only create LNDHub accounts when feature is enabled
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-24 16:01:53 +07:00
0d9fc4aa74 Merge pull request 'Make email settings configurable, add custom mailer for one-off emails' (#107) from feature/custom_mailer into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #107
Reviewed-by: greg <greg@noreply.kosmos.org>
2023-03-23 15:52:43 +00:00
82475161a9 Merge branch 'master' into feature/custom_mailer
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-23 15:38:43 +00:00
Râu Cao
fb3b9af3e5 Add custom mailer for one-off emails
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-22 14:54:23 +07:00
Râu Cao
b1a0268e6b Make email settings configurable 2023-03-22 14:53:44 +07:00
e1e7d8f87d Merge pull request 'Move exchanging of XMPP contacts to account confirmation' (#105) from chore/exchange_xmpp_contacts_after_confirmation into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #105
Reviewed-by: galfert <garret.alfert@gmail.com>
2023-03-22 06:45:30 +00:00
Râu Cao
5b46f3adf5 Move exchanging of XMPP contacts to account confirmation
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Since the ejabberd service is now being enabled after the confirmation,
we also need to move the exchanging of roster contacts to that point.
2023-03-20 17:59:43 +07:00
Râu Cao
a8a8fba14c Change styling of Devise shared links
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Update release notes draft
2023-03-19 18:07:09 +07:00
Râu Cao
8a7016a30b Add remember-me function for sign-in
When checked, remember user for 2 weeks. Otherwise expire session after
30 minutes.
2023-03-19 18:06:18 +07:00
Râu Cao
e2618de7c6 Add time limit for inactive sessions
closes #8
2023-03-19 16:16:36 +07:00
90680368fb Merge pull request 'Complete admin pages for service settings' (#104) from feature/admin_user_service_settings into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #104
Reviewed-by: galfert <garret.alfert@gmail.com>
2023-03-19 06:33:13 +00:00
Râu Cao
8d90847896 Add setting for contact roster name
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
And only exchange contacts when ejabberd integration is enabled
2023-03-15 09:03:39 +00:00
Râu Cao
8da297811b Mark settings as readonly, allow params for editable ones 2023-03-15 09:03:39 +00:00
Râu Cao
fa56d6b772 Refactor toggles to work without JS, add specs 2023-03-15 09:03:39 +00:00
Râu Cao
ca1221e9f3 Refactor admin settings, add all service settings 2023-03-15 09:03:39 +00:00
Râu Cao
295d486761 Disable toggles on admin user page
They are purely informational
2023-03-15 09:03:39 +00:00
Râu Cao
e00390d102 Add cached settings for all current services 2023-03-15 09:03:39 +00:00
Râu Cao
b947480190 Refactor sidenav link component, allow multiple levels 2023-03-15 09:03:39 +00:00
Râu Cao
fa07978aac Add form field update capability to toggle components 2023-03-15 09:03:39 +00:00
Râu Cao
e758e258a8 Allow disabling toggles, add toggle fieldset component 2023-03-15 09:03:39 +00:00
Râu Cao
805733939c Add toggle switch component, service configs, admin profile links 2023-03-15 09:03:39 +00:00
Râu Cao
f050d010fd Refactor admin donation pages, fix errors
All checks were successful
continuous-integration/drone/push Build is passing
Not sending the right response codes for Turbo to handle.
2023-03-15 15:24:00 +07:00
Râu Cao
95fac38b53 Show email address on account settings page
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-12 11:01:22 +07:00
cb80465297 Merge pull request 'Upgrade Devise, remove custom Turbo integration' (#102) from chore/87-upgrade_devise into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #102
2023-03-09 04:43:03 +00:00
Râu Cao
c7550b4f64 Upgrade Devise, remove custom Turbo integration
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-09 11:34:42 +07:00
341284aa99 Merge pull request 'Refactor form input styles/layouts' (#100) from ui/form_inputs into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #100
2023-03-09 03:42:22 +00:00
Râu Cao
b34d040ce3 Refactor form input styles
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
* Fix issue where button is rendered taller in flexbox, due to default
  margin on input elements
* Refactor/improve all login and signup views
2023-03-09 10:23:16 +07:00
1142a4e2d5 Merge pull request 'Add keysend support for Lightning Addresses, specs for address/lnurlp responses' (#84) from feature/ln_address_keysend into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #84
Reviewed-by: bumi <bumi@noreply.kosmos.org>
2023-03-03 13:29:02 +00:00
Râu Cao
f2c7aa2f09 Fix typos
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-03 21:27:18 +08:00
cca44d7542 Merge branch 'master' into feature/ln_address_keysend
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-02 15:49:13 +00:00
cdad7546fb Merge pull request 'Improve design of service grid on dashboard' (#97) from feature/dashboard_layout into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #97
Reviewed-by: greg <greg@noreply.kosmos.org>
2023-03-02 15:48:27 +00:00
feb7833533 Merge branch 'master' into feature/dashboard_layout
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-02 15:41:51 +00:00
Râu Cao
dfb12b8f62 Fix typo
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-02 15:54:03 +08:00
Râu Cao
6c2a97e7e5 Improve design of service grid on dashboard
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-01 22:48:23 +08:00
c8b65de7f6 Merge pull request 'Add service attribute to LDAP user entry' (#91) from feature/ldap_services into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #91
Reviewed-by: greg <greg@noreply.kosmos.org>
2023-03-01 09:57:53 +00:00
2861254adf Merge branch 'master' into feature/ldap_services
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-01 09:35:53 +00:00
1d2910dadb Merge pull request 'Add pagination features, paginate admin pages' (#95) from feature/89-pagination into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #95
Reviewed-by: greg <greg@noreply.kosmos.org>
2023-03-01 09:34:58 +00:00
Râu Cao
251a170f2b Add documentation link for Pagy
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-01 17:14:44 +08:00
Râu Cao
cbbb4c6e47 Add pagination to admin pages
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-01 17:08:36 +08:00
Râu Cao
3aad27c7bd Add Pagy gem, config, styles 2023-03-01 17:08:24 +08:00
Râu Cao
7cff849d79 Add more users when seeding db 2023-03-01 17:07:13 +08:00
Râu Cao
75ffd4e2f1 Add service attribute to LDAP user entry
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-02-27 23:36:23 +08:00
b84f9109f6 Merge pull request 'Fix broken database seed' (#90) from bugfix/reserved_admin_username into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #90
Reviewed-by: raucao <raucao@noreply.kosmos.org>
2023-02-26 14:20:45 +00:00
7fd564726f Merge pull request 'Add user page to admin panel, improve other admin pages' (#88) from feature/admin_user_details into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #88
Reviewed-by: galfert <garret.alfert@gmail.com>
2023-02-26 14:16:41 +00:00
b2a1b8caf5 Remove "admin" from default reserved usernames
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Blocking admin prevents seeding the DB, which creates an admin user
2023-02-26 13:15:33 +01:00
52cc2a8151 Fix numbering in quickstart steps 2023-02-26 13:10:49 +01:00
Râu Cao
c8e405d93a Fix inline tailwind styles not being applied
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-02-26 18:41:18 +08:00
Râu Cao
5f74212603 Improve admin donation pages
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-02-26 11:33:11 +08:00
Râu Cao
1c3e893b6b Fix height of link element buttons 2023-02-26 11:32:26 +08:00
Râu Cao
eec4533fea Improve markup 2023-02-26 11:32:03 +08:00
Râu Cao
6d20ac9a1c Add lndhub info to admin user page
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-02-25 15:33:03 +08:00
Râu Cao
27dd4163f0 Add more data to admin user page 2023-02-25 15:32:50 +08:00
Râu Cao
1a55e5e895 Link users everywhere in admin panel 2023-02-25 15:32:13 +08:00
Râu Cao
8eb487600c Switch admin users index from pure LDAP to database 2023-02-25 15:31:19 +08:00
Râu Cao
678e80a25d Retrieve ldap entry from user model 2023-02-25 15:30:23 +08:00
Râu Cao
30fb9805e5 Add associations between users via invitations 2023-02-25 15:29:46 +08:00
Râu Cao
e675970f4c Add view helper for colored badges 2023-02-25 15:28:02 +08:00
Râu Cao
a0727e709f Add table class for rows with dividers 2023-02-25 15:27:28 +08:00
Râu Cao
55abbcc5ad WIP user page 2023-02-23 23:55:32 +08:00
Râu Cao
ffed398024 Add admin user details page 2023-02-23 22:09:23 +08:00
Râu Cao
1a2482434c Rename admin users controller/route
All checks were successful
continuous-integration/drone/push Build is passing
Started out as a simple helper page to list LDAP users, but turning into
proper user management now.
2023-02-23 21:53:12 +08:00
b530ad2f0f Merge pull request 'Remove ln_login from users' (#86) from chore/remove_ln_login into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #86
2023-02-23 12:16:06 +00:00
Râu Cao
3c2fe7c15d Remove ln_login from users
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Not needed anymore, removing in favor of unencrypted `ln_account`.
2023-02-23 20:13:08 +08:00
aa7044dea7 Merge pull request 'Fix deprecation warnings' (#85) from chore/fix_deprecation_warnings into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #85
2023-02-23 11:03:56 +00:00
Râu Cao
a3f0d0f2cf Fix deprecation warnings
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-02-23 19:00:03 +08:00
Râu Cao
dc63506102 Add ln node public key to test env
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-02-23 17:56:38 +08:00
Râu Cao
b87b9c2437 Prevent double render
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-02-23 17:54:34 +08:00
Râu Cao
e580cc9991 Add specs for Lightning Address and lnurlpay requests
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-02-23 17:46:36 +08:00
Râu Cao
68ab88c481 Add names for lnurl routes 2023-02-23 17:46:19 +08:00
Râu Cao
c7fe1bc3bc Add keysend support for Lightning Address
Allow keysend payments to user addresses. Useful for Podcasting 2.0/v4v.
2023-02-23 15:47:16 +08:00
84337c3a7d Merge pull request 'Add lndhub admin panel, quick stats for admin pages' (#80) from feature/admin_stats into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #80
Reviewed-by: bumi <bumi@noreply.kosmos.org>
2023-02-23 07:43:15 +00:00
654b90f9ee Merge pull request 'Add configurable settings, admin settings pages, reserved usernames' (#81) from feature/settings into feature/admin_stats
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Reviewed-on: #81
2023-02-23 07:42:21 +00:00
aa0ba18763 Merge pull request 'Fix password validation during password reset' (#83) from bugfix/28-password_reset into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #83
Reviewed-by: bumi <bumi@noreply.kosmos.org>
2023-02-19 14:01:25 +00:00
Râu Cao
7dae66959e Formatting
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-02-19 15:54:59 +08:00
Râu Cao
b67d6139ac Fix password validation during password reset
fixes #28
2023-02-19 15:54:55 +08:00
Râu Cao
b9259958f4 Add spec to prove issue #28
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-19 14:41:45 +08:00
Râu Cao
832d1e3bd7 Improve layout of password reset form 2023-02-19 14:41:16 +08:00
Râu Cao
f3f967f9f7 Prevent signups with reserved usernames
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
closes #12
2023-02-19 12:12:00 +08:00
Râu Cao
9407c7a94d Add username format restrictions
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-19 12:04:24 +08:00
Râu Cao
df3ec9f90a Add spec for updating reserved usernames setting
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-19 11:56:34 +08:00
Râu Cao
25a0723166 Make admin flag persist for subsequent calls in spec 2023-02-19 11:55:53 +08:00
Râu Cao
6e884b789a Show full lightning account ID/login
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
No use in hiding it, because it will be public through Lightning
Address, but can be useful for copypasta.
2023-02-18 10:08:49 +08:00
Râu Cao
346e36e160 Use success notices where appropriate
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-18 10:07:54 +08:00
Râu Cao
b7bf957dd2 Update registration settings
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-17 22:12:38 +08:00
Râu Cao
084835f06a WIP Add admin settings pages, reserved username config
All checks were successful
continuous-integration/drone/push Build is passing
Prototyping settings forms
2023-02-17 20:33:15 +08:00
Râu Cao
cd7b05e2ff Add rails-settings-cached, use for initial feature flags
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-17 17:07:42 +08:00
Râu Cao
7280a4c023 Order invitations by date on user invitations page
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-02-16 23:40:17 +08:00
Râu Cao
164400adec Merge branch 'chore/fix_ci' into feature/admin_stats
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-02-14 13:18:38 +08:00
Râu Cao
c2e0909132 Use plain hash for ENV vars
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-14 13:16:10 +08:00
Râu Cao
c44ce61e25 Remove empty tests
Some checks failed
continuous-integration/drone/push Build is failing
2023-02-14 13:06:18 +08:00
Râu Cao
e2294c4029 Add config for lndhub postgres/admin
Some checks failed
continuous-integration/drone/push Build is failing
2023-02-14 13:01:53 +08:00
Râu Cao
bdc03a7181 bundle exec rspec
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-02-14 12:55:03 +08:00
Râu Cao
959449a3f4 Add default empty password
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-02-13 22:10:54 +08:00
Râu Cao
b4c9b31ce7 Disable lndhub admin UI when not configured
Some checks failed
continuous-integration/drone/push Build is failing
2023-02-13 21:57:06 +08:00
Râu Cao
43f133ebd7 Add config for lndhub postgres/admin 2023-02-13 21:56:32 +08:00
Râu Cao
d9e767298b Refactor admin users page, add quick stats
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-13 16:32:28 +08:00
Râu Cao
dd482d7f2e Add LndHub db/models, and quick stats for admin views 2023-02-13 16:25:35 +08:00
Râu Cao
09d99ce9c2 Increase size of current balance 2023-02-10 11:37:27 +08:00
Râu Cao
8f9e1c3e84 Improve lnurlp message and notification
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-25 13:18:44 +08:00
4a045bf61c Merge pull request 'Various front-end improvements and bugfixes' (#78) from feature/frontend_improvements into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #78
Reviewed-by: galfert <garret.alfert@gmail.com>
Reviewed-by: bumi <bumi@noreply.kosmos.org>
2023-01-25 04:16:55 +00:00
f62e49f524 Merge pull request 'Add Webhooks and XMPP notifications for incoming sats' (#79) from feature/webhooks into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #79
Reviewed-by: bumi <bumi@noreply.kosmos.org>
2023-01-13 04:33:02 +00:00
Râu Cao
b0c787bbc7 Throw exception when user cannot be found
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-01-13 12:24:22 +08:00
Râu Cao
86dc44d096 Add empty state for wallet transactions view
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-01-12 16:21:40 +08:00
Râu Cao
a1663b9f9d Add specs for lndhub webhook
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-01-12 14:33:31 +08:00
Râu Cao
aa3c2b4fa2 Remove hardcoded user address from hook 2023-01-12 14:32:53 +08:00
Râu Cao
4c0d8283e3 Make status code explicit 2023-01-12 14:32:35 +08:00
Râu Cao
d4a3f8dadb Fix spec after renaming job
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-01-12 11:50:13 +08:00
Râu Cao
9e988e92d1 Notify user about incoming sats via XMPP
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-01-12 11:44:55 +08:00
Râu Cao
4232df302b Add send_message to ejabberd service 2023-01-12 11:44:28 +08:00
Râu Cao
2c8b3cdacc Rename job 2023-01-12 11:43:30 +08:00
Râu Cao
51952ecdc2 Add migration for unencrypted ln login field
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-11 19:50:01 +08:00
Râu Cao
68e0d00f6e WIP Add Webhooks controller, allowed IP config
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-11 19:17:27 +08:00
Râu Cao
99dc36f13a Make empty donations page prettier
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-01-10 14:13:28 +08:00
Râu Cao
ee74c4847f Make invitation page prettier when it's empty 2023-01-10 14:13:27 +08:00
Râu Cao
15b63eee73 Add coming-soon note to disabled settings nav items 2023-01-10 14:13:27 +08:00
Râu Cao
c756528d32 Allow to copy invitation URLs via button 2023-01-10 14:13:27 +08:00
Râu Cao
fef29b4fc0 Add more info about project contributions 2023-01-10 14:13:27 +08:00
Râu Cao
38608e053d Add Zeus to recommended wallet apps 2023-01-10 14:13:26 +08:00
Râu Cao
5f215b8ed8 Replace vanilla JS with new clipboard code 2023-01-10 14:13:26 +08:00
Râu Cao
87aae35974 Add a clipboard controller and wire up the copy button 2023-01-10 14:13:26 +08:00
Râu Cao
6ad02e69a2 WIP Profile settings page
Show the user's user address, and provide a button for copying it to the
clipboard
2023-01-10 14:13:26 +08:00
Râu Cao
94ca0f3764 Rename settings page 2023-01-10 14:13:25 +08:00
Râu Cao
0fec37e0a9 Add inviter and time to admin invitations list 2023-01-10 14:13:25 +08:00
Râu Cao
620befd7c0 Fix devise not rendering errors as flash messages
https://github.com/heartcombo/devise/issues/5446

closes #63
2023-01-10 14:13:25 +08:00
Râu Cao
aba4930696 Set a minimum height for content with sidenav 2023-01-10 14:13:25 +08:00
Râu Cao
0492b42327 Improve button style 2023-01-10 14:13:25 +08:00
Râu Cao
445a1c80a6 Refactor settings routes and menu
Use sub controllers/routes for the sections
2023-01-10 14:13:24 +08:00
Râu Cao
cf48f76553 Fix web container start when offline 2023-01-10 14:13:24 +08:00
Râu Cao
70fa43f5d2 Use tabnav component for wallet view 2023-01-10 14:13:24 +08:00
Râu Cao
b37a0c25a4 Wording 2023-01-10 14:13:23 +08:00
Râu Cao
3197743a55 Change donations to contrbutions, add tabbed nav
Introduces components for tabbed navigation and adds a tab menu and item
for non-financial contributions to the donations/contributions page.
2023-01-10 14:13:23 +08:00
Râu Cao
3f49e4a3b8 Use more appropriate icon in sidenav 2023-01-10 14:13:23 +08:00
2e1d930e0f Merge pull request 'Docker Compose config, local 389ds/dirsrv, LDAP and user seeds' (#74) from feature/docker_compose into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #74
2022-12-27 06:26:43 +00:00
d849d28f62 Merge pull request 'Add support and migration for lndhub.go' (#77) from feature/73-lndhub-go into feature/docker_compose
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Reviewed-on: #77
2022-12-27 06:25:37 +00:00
Râu Cao
f2a22adf6b Switch legacy to lndhub.go
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Temporary fix
2022-12-23 17:42:20 +07:00
Râu Cao
e1aaa2c434 Re-authorize when token is invalid 2022-12-23 17:42:17 +07:00
Râu Cao
e62bf67262 Use v2 API for creating new lndhub accounts
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-12-23 12:39:57 +07:00
Râu Cao
6df3d5933c Update test env
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2022-12-22 20:11:38 +07:00
Râu Cao
a5a90c4d83 Add support and migration for lndhub.go
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
Slightly WIP
2022-12-22 20:01:14 +07:00
Râu Cao
80ef75ff42 Improve README, add quick start instructions
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-12-07 18:15:04 +01:00
Râu Cao
67e2e45dd8 Remove pid dir from git 2022-12-07 18:14:49 +01:00
Râu Cao
3834e5230b Comment encryption option in admin ldap users controller
Refactor to use the service later
2022-12-07 18:13:58 +01:00
Râu Cao
4cb7c0998f Add db/user seeds 2022-12-07 18:12:54 +01:00
Râu Cao
20382f7df7 Rename ldap seed task to setup 2022-12-07 18:11:57 +01:00
Râu Cao
add94eee8d Don't start phpldapadmin by default 2022-12-07 18:11:23 +01:00
Râu Cao
067dc3b63d Remove obsolete method 2022-12-07 18:11:03 +01:00
Râu Cao
1a470cf1c8 Add flag for creating pre-confirmed users 2022-12-07 18:09:44 +01:00
Râu Cao
f85b7f4f62 Define patch version for Ruby base image
No need to re-download new images for every patch version
2022-12-07 18:07:53 +01:00
Râu Cao
8635413002 Delete admin role manually on reset
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-12-07 15:20:34 +01:00
Râu Cao
a3da956b48 Add missing ACI and role to LDAP seeds
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-12-07 14:27:51 +01:00
Râu Cao
3c40dc98ca Add note about resetting LDAP server
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-12-06 10:28:34 +01:00
28b31e63f9 Merge pull request 'Update Docker image in CI' (#75) from chore/ci_image_upgrade into feature/docker_compose
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Reviewed-on: #75
2022-12-06 09:23:05 +00:00
Râu Cao
efafd38f68 Update Docker image in CI
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
We need a newer node.js version.
2022-12-06 10:19:47 +01:00
Râu Cao
537e1a4774 Update database schema (from Rails upgrade)
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2022-12-05 13:36:49 +01:00
Râu Cao
c3b9ff8b4a Add LDAP service and seed task 2022-12-05 13:36:33 +01:00
Râu Cao
93d56f79d5 Add config and documentation for running dirsrv with Docker 2022-12-05 13:35:30 +01:00
Râu Cao
1a30345f46 Add byebug for debugging in development 2022-12-05 13:20:47 +01:00
Râu Cao
778babcc05 Add Docker Compose config and 389ds service
Some checks failed
continuous-integration/drone/push Build is failing
refs #2
2022-12-02 19:21:13 +01:00
Râu Cao
fa3b53d3b3 Add Dockerfile for development 2022-12-02 19:19:02 +01:00
Râu Cao
0ca85656b7 Update dependencies 2022-12-02 19:16:56 +01:00
Râu Cao
f7183f68d5 Decrease mininum sats for Lighting invoices
All checks were successful
continuous-integration/drone/push Build is passing
2022-09-16 11:20:29 +02:00
87027b514b Merge pull request 'Update gems' (#72) from chore/update_gems into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #72
2022-07-27 13:47:33 +00:00
Râu Cao
16ad621365 Update gems
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
In particular Rails due to security updates:

https://rubyonrails.org/2022/7/12/Rails-Versions-7-0-3-1-6-1-6-1-6-0-5-1-and-5-2-8-1-have-been-released
2022-07-27 15:22:24 +02:00
33e87d6472 Merge pull request 'Add BTCPay service, Kredits API' (#71) from feature/community_funds_balance into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #71
Reviewed-by: bumi <bumi@noreply.kosmos.org>
2022-06-12 05:15:05 +00:00
03dc6c7a9c Log unexpected kredits API errors
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-05-24 13:42:00 +02:00
897b5bf4ea Specify whole API base URL in config
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-05-23 22:49:39 +02:00
caea2d0121 Add kredits API with wallet balance endpoint
All checks were successful
continuous-integration/drone/push Build is passing
2022-05-23 22:47:08 +02:00
e1ff5c479e Initial BTCPay integration 2022-05-23 21:35:03 +02:00
9b3386de30 Update credentials 2022-05-23 18:49:37 +02:00
f2287c1186 Remove separate development credentials files 2022-05-23 18:49:22 +02:00
b29197cf4e Merge pull request 'Various UI improvements' (#70) from feature/ui_improvements into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #70
2022-04-28 13:05:10 +00:00
5c48055ac8 Use feather icon for wallet on dashboard
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
fixes #51
2022-04-28 15:01:20 +02:00
5ead3476b7 Normalize overall (font) size
The entire UI is a bit too large. This normalizes the font size and
dimensions, so it doesn't look zoomed in on most screens.
2022-04-28 14:56:03 +02:00
fbf163740a Merge pull request 'Replace the LDAP production config for the new server' (#69) from chore/new_ldap_server into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #69
2022-04-28 10:11:01 +00:00
Greg Karékinian
1fc1457e97 Replace the LDAP production config for the new server
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Refs kosmos/chef#227
2022-04-28 11:54:14 +02:00
1f57bbd9c2 Merge pull request 'Add admin task to list LndHub balances' (#68) from feature/list_lndhub_balances into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #68
2022-04-18 08:41:40 +00:00
2a2793ae44 Print sum of user balances
All checks were successful
continuous-integration/drone/pr Build is passing
2022-04-12 16:05:46 +02:00
8773bf5f9e Slow down LndHub auth requests in task 2022-04-12 15:42:44 +02:00
d9970c126a List balances of LndHub accounts 2022-04-12 15:36:45 +02:00
259 changed files with 6401 additions and 1444 deletions

View File

@@ -12,12 +12,12 @@ steps:
settings:
restore: true
mount:
- ./vendor
- ./vendor/cache
when:
branch:
- master
- name: rspec
image: guildeducation/rails:2.7.2-12.22.0
image: guildeducation/rails:2.7.2-14.20.0
environment:
RAILS_ENV: test
commands:
@@ -28,7 +28,7 @@ steps:
- bundle install --jobs=3 --retry=3
- yarn install
- rake css:build
- rake spec
- bundle exec rspec
- name: rebuild-cache
image: drillster/drone-volume-cache
volumes:
@@ -37,7 +37,7 @@ steps:
settings:
rebuild: true
mount:
- ./vendor
- ./vendor/cache
when:
branch:
- master

View File

@@ -1,3 +1,43 @@
PRIMARY_DOMAIN=kosmos.org
AKKOUNTS_DOMAIN=accounts.example.com
SMTP_SERVER=smtp.example.com
SMTP_PORT=587
SMTP_LOGIN=accounts
SMTP_PASSWORD=123abc
SMTP_FROM_ADDRESS=accounts@example.com
SMTP_DOMAIN=example.com
SMTP_AUTH_METHOD=plain
SMTP_ENABLE_STARTTLS=auto
LDAP_HOST=localhost
LDAP_PORT=389
LDAP_ADMIN_PASSWORD=passthebutter
LDAP_SUFFIX='dc=kosmos,dc=org'
REDIS_URL='redis://localhost:6379/1'
WEBHOOKS_ALLOWED_IPS='10.1.1.163'
DISCOURSE_PUBLIC_URL='https://community.kosmos.org'
DISCOURSE_CONNECT_SECRET='discourse_connect_ftw'
GITEA_PUBLIC_URL='https://gitea.kosmos.org'
MASTODON_PUBLIC_URL='https://kosmos.social'
MEDIAWIKI_PUBLIC_URL='https://wiki.kosmos.org'
RS_STORAGE_URL='https://storage.kosmos.org'
EJABBERD_ADMIN_URL='https://xmpp.kosmos.org/admin'
EJABBERD_API_URL='https://xmpp.kosmos.org/api'
BTCPAY_API_URL='http://localhost:23001/api/v1'
LNDHUB_API_URL='http://localhost:3023'
LNDHUB_PUBLIC_URL='https://lndhub.kosmos.org'
LNDHUB_PUBLIC_KEY='0123d3be18617f39cf645851e3ba63f51fc13f0bb09e3bb25e6fd4de556486d946'
LNDHUB_ADMIN_UI=true
LNDHUB_PG_HOST=localhost
LNDHUB_PG_PORT=5432
LNDHUB_PG_DATABASE=lndhub
LNDHUB_PG_USERNAME=lndhub
LNDHUB_PG_PASSWORD=''

View File

@@ -1,3 +0,0 @@
EJABBERD_API_URL='https://xmpp.kosmos.org:5443/api'
LNDHUB_API_URL='http://10.1.1.163:3023'
LNDHUB_PUBLIC_URL='https://lndhub.kosmos.org'

View File

@@ -1,3 +1,16 @@
PRIMARY_DOMAIN=kosmos.org
DISCOURSE_PUBLIC_URL='http://discourse.example.com'
DISCOURSE_CONNECT_SECRET='discourse_connect_ftw'
EJABBERD_API_URL='http://xmpp.example.com/api'
LNDHUB_API_URL='http://localhost:3023'
BTCPAY_API_URL='http://btcpay.example.com/api/v1'
LNDHUB_API_URL='http://localhost:3026'
LNDHUB_PUBLIC_URL='https://lndhub.kosmos.org'
LNDHUB_PUBLIC_KEY='024cd3be18617f39cf645851e3ba63f51fc13f0bb09e3bb25e6fd4de556486d946'
RS_STORAGE_URL='https://storage.kosmos.org'
WEBHOOKS_ALLOWED_IPS='10.1.1.23'

View File

@@ -0,0 +1,13 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
version-resolver:
major:
labels:
- 'release/major'
minor:
labels:
- 'release/minor'
patch:
labels:
- 'release/patch'
default: patch

View File

@@ -0,0 +1,11 @@
name: Release Drafter
on:
pull_request:
types: [closed]
jobs:
release_drafter_job:
name: Update release notes draft
runs-on: ubuntu-latest
steps:
- name: Release Drafter
uses: https://github.com/raucao/gitea-release-drafter@dev

21
Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
# syntax=docker/dockerfile:1
FROM ruby:2.7.6
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update -qq && apt-get install -y --no-install-recommends curl \
ldap-utils tini
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get update && apt-get install -y nodejs
WORKDIR /akkounts
COPY Gemfile /akkounts/Gemfile
COPY Gemfile.lock /akkounts/Gemfile.lock
COPY package.json /akkounts/package.json
RUN bundle install
RUN gem install foreman
RUN npm install -g yarn
RUN yarn install
ENTRYPOINT ["/usr/bin/tini", "--"]
EXPOSE 3000

21
Gemfile
View File

@@ -32,24 +32,39 @@ gem 'lockbox'
# Authentication
gem 'warden'
gem 'devise'
gem 'devise', '~> 4.9.0'
gem 'devise_ldap_authenticatable'
gem 'net-ldap'
# Utilities
gem "rqrcode", "~> 2.0"
gem 'rails-settings-cached', '~> 2.8.3'
gem 'pagy', '~> 6.0', '>= 6.0.2'
gem 'flipper'
gem 'flipper-active_record'
gem 'flipper-ui'
# HTTP requests
gem 'faraday'
# Background/scheduled jobs
gem 'sidekiq'
gem 'sidekiq', '< 7'
gem 'sidekiq-scheduler'
# Monitoring
gem "sentry-ruby"
gem "sentry-rails"
# Services
gem 'discourse_api'
gem "lnurl"
gem 'nostr', git: 'https://gitea.kosmos.org/kosmos/nostr-gem.git', branch: 'feature/ruby_2.7_compat'
group :development, :test do
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
gem 'rspec-rails'
gem "byebug", "~> 11.1"
end
group :development do
@@ -58,6 +73,8 @@ group :development do
gem 'listen', '~> 3.2'
gem 'letter_opener'
gem 'letter_opener_web'
gem 'faker'
gem 'solargraph'
end
group :test do

View File

@@ -1,77 +1,98 @@
GIT
remote: https://gitea.kosmos.org/kosmos/nostr-gem.git
revision: 596529d9eb50d13b3f385245636698fccf37b442
branch: feature/ruby_2.7_compat
specs:
nostr (0.4.0)
bech32 (~> 1.3)
bip-schnorr (~> 0.4)
ecdsa (~> 1.2)
event_emitter (~> 0.2)
faye-websocket (~> 0.11)
json (~> 2.6)
GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.2.2)
actionpack (= 7.0.2.2)
activesupport (= 7.0.2.2)
actioncable (7.0.5)
actionpack (= 7.0.5)
activesupport (= 7.0.5)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.2.2)
actionpack (= 7.0.2.2)
activejob (= 7.0.2.2)
activerecord (= 7.0.2.2)
activestorage (= 7.0.2.2)
activesupport (= 7.0.2.2)
actionmailbox (7.0.5)
actionpack (= 7.0.5)
activejob (= 7.0.5)
activerecord (= 7.0.5)
activestorage (= 7.0.5)
activesupport (= 7.0.5)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.2.2)
actionpack (= 7.0.2.2)
actionview (= 7.0.2.2)
activejob (= 7.0.2.2)
activesupport (= 7.0.2.2)
actionmailer (7.0.5)
actionpack (= 7.0.5)
actionview (= 7.0.5)
activejob (= 7.0.5)
activesupport (= 7.0.5)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.2.2)
actionview (= 7.0.2.2)
activesupport (= 7.0.2.2)
rack (~> 2.0, >= 2.2.0)
actionpack (7.0.5)
actionview (= 7.0.5)
activesupport (= 7.0.5)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.2.2)
actionpack (= 7.0.2.2)
activerecord (= 7.0.2.2)
activestorage (= 7.0.2.2)
activesupport (= 7.0.2.2)
actiontext (7.0.5)
actionpack (= 7.0.5)
activerecord (= 7.0.5)
activestorage (= 7.0.5)
activesupport (= 7.0.5)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.2.2)
activesupport (= 7.0.2.2)
actionview (7.0.5)
activesupport (= 7.0.5)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.2.2)
activesupport (= 7.0.2.2)
activejob (7.0.5)
activesupport (= 7.0.5)
globalid (>= 0.3.6)
activemodel (7.0.2.2)
activesupport (= 7.0.2.2)
activerecord (7.0.2.2)
activemodel (= 7.0.2.2)
activesupport (= 7.0.2.2)
activestorage (7.0.2.2)
actionpack (= 7.0.2.2)
activejob (= 7.0.2.2)
activerecord (= 7.0.2.2)
activesupport (= 7.0.2.2)
activemodel (7.0.5)
activesupport (= 7.0.5)
activerecord (7.0.5)
activemodel (= 7.0.5)
activesupport (= 7.0.5)
activestorage (7.0.5)
actionpack (= 7.0.5)
activejob (= 7.0.5)
activerecord (= 7.0.5)
activesupport (= 7.0.5)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.2.2)
activesupport (7.0.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
bcrypt (3.1.16)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
backport (1.2.0)
bcrypt (3.1.18)
bech32 (1.3.0)
thor (>= 1.1.0)
benchmark (0.2.1)
bindex (0.8.1)
bip-schnorr (0.6.0)
ecdsa_ext (~> 0.5.0)
builder (3.2.4)
capybara (3.36.0)
byebug (11.1.3)
capybara (3.39.2)
addressable
matrix
mini_mime (>= 0.1.3)
@@ -81,20 +102,21 @@ GEM
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
chunky_png (1.4.0)
concurrent-ruby (1.1.9)
connection_pool (2.2.5)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
crack (0.4.5)
rexml
crass (1.0.6)
cssbundling-rails (1.0.0)
cssbundling-rails (1.1.2)
railties (>= 6.0.0)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
database_cleaner-active_record (2.0.1)
database_cleaner (2.0.2)
database_cleaner-active_record (>= 2, < 3)
database_cleaner-active_record (2.1.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
devise (4.8.1)
date (3.3.3)
devise (4.9.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
@@ -104,186 +126,269 @@ GEM
devise (>= 3.4.1)
net-ldap (>= 0.16.0)
diff-lcs (1.5.0)
digest (3.1.0)
dotenv (2.7.6)
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
discourse_api (2.0.1)
faraday (~> 2.7)
faraday-follow_redirects
faraday-multipart
rack (>= 1.6)
dotenv (2.8.1)
dotenv-rails (2.8.1)
dotenv (= 2.8.1)
railties (>= 3.2)
e2mmap (0.1.0)
erubi (1.10.0)
et-orbi (1.2.6)
ecdsa (1.2.0)
ecdsa_ext (0.5.0)
ecdsa (~> 1.2.0)
erubi (1.12.0)
et-orbi (1.2.7)
tzinfo
factory_bot (6.2.0)
event_emitter (0.2.6)
eventmachine (1.2.7)
factory_bot (6.2.1)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
faraday (2.2.0)
faraday-net_http (~> 2.0)
faker (3.2.0)
i18n (>= 1.8.11, < 2)
faraday (2.7.6)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (2.0.1)
faraday-follow_redirects (0.3.0)
faraday (>= 1, < 3)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (3.0.2)
faye-websocket (0.11.2)
eventmachine (>= 0.12.0)
websocket-driver (>= 0.5.1)
ffi (1.15.5)
fugit (1.5.2)
et-orbi (~> 1.1, >= 1.1.8)
flipper (0.28.0)
concurrent-ruby (< 2)
flipper-active_record (0.28.0)
activerecord (>= 4.2, < 8)
flipper (~> 0.28.0)
flipper-ui (0.28.0)
erubi (>= 1.0.0, < 2.0.0)
flipper (~> 0.28.0)
rack (>= 1.4, < 3)
rack-protection (>= 1.5.3, <= 4.0.0)
sanitize (< 7)
fugit (1.8.1)
et-orbi (~> 1, >= 1.2.7)
raabro (~> 1.4)
globalid (1.0.0)
globalid (1.1.0)
activesupport (>= 5.0)
hashdiff (1.0.1)
i18n (1.9.1)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
importmap-rails (1.0.2)
importmap-rails (1.1.6)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
io-wait (0.2.1)
jaro_winkler (1.5.6)
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
launchy (2.5.0)
addressable (~> 2.7)
letter_opener (1.7.0)
launchy (~> 2.2)
json (2.6.3)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
launchy (2.5.2)
addressable (~> 2.8)
letter_opener (1.8.1)
launchy (>= 2.2, < 3)
letter_opener_web (2.0.0)
actionmailer (>= 5.2)
letter_opener (~> 1.7)
railties (>= 5.2)
rexml
listen (3.7.1)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
lockbox (0.6.8)
loofah (2.14.0)
lnurl (1.0.1)
bech32 (~> 1.1)
lockbox (1.2.0)
loofah (2.21.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.15.0)
net-imap (0.2.3)
digest
minitest (5.18.0)
multipart-post (2.3.0)
net-imap (0.3.6)
date
net-protocol
strscan
net-ldap (0.17.0)
net-pop (0.1.1)
digest
net-ldap (0.18.0)
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
timeout
net-protocol (0.1.2)
io-wait
timeout
net-smtp (0.3.1)
digest
net-smtp (0.3.3)
net-protocol
timeout
nio4r (2.5.8)
nokogiri (1.13.1-x86_64-linux)
nio4r (2.5.9)
nokogiri (1.15.2-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
pagy (6.0.4)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pg (1.2.3)
public_suffix (4.0.6)
puma (4.3.11)
public_suffix (5.0.1)
puma (4.3.12)
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.6.0)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (7.0.2.2)
actioncable (= 7.0.2.2)
actionmailbox (= 7.0.2.2)
actionmailer (= 7.0.2.2)
actionpack (= 7.0.2.2)
actiontext (= 7.0.2.2)
actionview (= 7.0.2.2)
activejob (= 7.0.2.2)
activemodel (= 7.0.2.2)
activerecord (= 7.0.2.2)
activestorage (= 7.0.2.2)
activesupport (= 7.0.2.2)
racc (1.7.1)
rack (2.2.7)
rack-protection (3.0.6)
rack
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.5)
actioncable (= 7.0.5)
actionmailbox (= 7.0.5)
actionmailer (= 7.0.5)
actionpack (= 7.0.5)
actiontext (= 7.0.5)
actionview (= 7.0.5)
activejob (= 7.0.5)
activemodel (= 7.0.5)
activerecord (= 7.0.5)
activestorage (= 7.0.5)
activesupport (= 7.0.5)
bundler (>= 1.15.0)
railties (= 7.0.2.2)
railties (= 7.0.5)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
railties (7.0.2.2)
actionpack (= 7.0.2.2)
activesupport (= 7.0.2.2)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails-settings-cached (2.8.3)
activerecord (>= 5.0.0)
railties (>= 5.0.0)
railties (7.0.5)
actionpack (= 7.0.5)
activesupport (= 7.0.5)
method_source
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
rb-fsevent (0.11.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
redis (4.6.0)
regexp_parser (2.2.1)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rbs (2.8.4)
redis (4.8.1)
regexp_parser (2.8.1)
responders (3.1.0)
actionpack (>= 5.2)
railties (>= 5.2)
reverse_markdown (2.1.1)
nokogiri
rexml (3.2.5)
rqrcode (2.1.1)
rqrcode (2.2.0)
chunky_png (~> 1.0)
rqrcode_core (~> 1.0)
rqrcode_core (1.2.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-rails (5.1.0)
actionpack (>= 5.2)
activesupport (>= 5.2)
railties (>= 5.2)
rspec-core (~> 3.10)
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.11.0)
rspec-support (~> 3.12.0)
rspec-rails (6.0.3)
actionpack (>= 6.1)
activesupport (>= 6.1)
railties (>= 6.1)
rspec-core (~> 3.12)
rspec-expectations (~> 3.12)
rspec-mocks (~> 3.12)
rspec-support (~> 3.12)
rspec-support (3.12.0)
rubocop (1.52.1)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rufus-scheduler (3.8.1)
rufus-scheduler (3.9.1)
fugit (~> 1.1, >= 1.1.6)
sidekiq (6.4.1)
connection_pool (>= 2.2.2)
sanitize (6.0.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
sentry-rails (5.9.0)
railties (>= 5.0)
sentry-ruby (~> 5.9.0)
sentry-ruby (5.9.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
sidekiq (6.5.9)
connection_pool (>= 2.2.5, < 3)
rack (~> 2.0)
redis (>= 4.2.0)
sidekiq-scheduler (3.1.1)
e2mmap
redis (>= 3, < 5)
redis (>= 4.5.0, < 5)
sidekiq-scheduler (5.0.3)
rufus-scheduler (~> 3.2)
sidekiq (>= 3)
thwait
sidekiq (>= 6, < 8)
tilt (>= 1.4.0)
sprockets (4.0.2)
solargraph (0.49.0)
backport (~> 1.2)
benchmark
bundler (~> 2.0)
diff-lcs (~> 1.4)
e2mmap
jaro_winkler (~> 1.5)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.1)
parser (~> 3.0)
rbs (~> 2.0)
reverse_markdown (~> 2.0)
rubocop (~> 1.38)
thor (~> 1.0)
tilt (~> 2.0)
yard (~> 0.9, >= 0.9.24)
sprockets (4.2.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
stimulus-rails (1.0.2)
sqlite3 (1.6.3-x86_64-linux)
stimulus-rails (1.2.1)
railties (>= 6.0.0)
strscan (3.0.1)
thor (1.2.1)
thwait (0.2.0)
e2mmap
tilt (2.0.10)
timeout (0.2.0)
turbo-rails (1.0.1)
thor (1.2.2)
tilt (2.2.0)
timeout (0.3.2)
turbo-rails (1.4.0)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.4)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
view_component (3.2.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
view_component (2.49.0)
activesupport (>= 5.0.0, < 8.0)
method_source (~> 1.0)
warden (1.2.9)
rack (>= 2.0.9)
@@ -292,7 +397,7 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webmock (3.14.0)
webmock (3.18.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
@@ -301,34 +406,48 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.5.4)
yard (0.9.34)
zeitwerk (2.6.8)
PLATFORMS
x86_64-linux
DEPENDENCIES
byebug (~> 11.1)
capybara
cssbundling-rails
database_cleaner
devise
devise (~> 4.9.0)
devise_ldap_authenticatable
discourse_api
dotenv-rails
factory_bot_rails
faker
faraday
flipper
flipper-active_record
flipper-ui
importmap-rails
jbuilder (~> 2.7)
letter_opener
letter_opener_web
listen (~> 3.2)
lnurl
lockbox
net-ldap
nostr!
pagy (~> 6.0, >= 6.0.2)
pg (~> 1.2.3)
puma (~> 4.1)
rails (~> 7.0.2)
rails-settings-cached (~> 2.8.3)
rqrcode (~> 2.0)
rspec-rails
sidekiq
sentry-rails
sentry-ruby
sidekiq (< 7)
sidekiq-scheduler
solargraph
sprockets-rails
sqlite3 (~> 1.4)
stimulus-rails

View File

@@ -1,2 +1,2 @@
web: bin/rails server -p 3000
web: bin/rails server -b 0.0.0.0 -p 3000
css: yarn build:css --watch

View File

@@ -7,6 +7,26 @@ credentials, invites, donations, etc..
## Development
### Quick Start
The easiest way to get a working development setup is using Docker Compose like
so:
1. Make sure [Docker Compose is installed][1] and Docker is running (included in
Docker Desktop)
2. Uncomment the `redis`, `web`, and `sidekiq` sections in `docker-compose.yml`
3. Run `docker compose up` and wait until 389ds announces its successful start
in the log output
4. `docker-compose exec ldap dsconf localhost backend create --suffix="dc=kosmos,dc=org" --be-name="dev"`
5. `docker compose run web rails ldap:setup`
6. `docker compose run web rails db:setup`
After these steps, you should have a working Rails app with a handful of test
users running on [http://localhost:3000](http://localhost:3000).
Log in with username "admin" and password "admin is admin". All users listed on
[http://localhost:3000/admin/users](http://localhost:3000/admin/users)
have the password "user is user".
### Rails app
Installing dependencies:
@@ -31,19 +51,61 @@ Running all specs:
bundle exec rspec
### LDAP server
### Docker (Compose)
TODO make it easy to run a local Kosmos LDAP server for development, without
manual LDIF imports etc. (or provide a staging instance)
There is a working Docker Compose config file, which allows you to spin up both
an app server for Rails as well as a local 389ds (LDAP) server.
By default, `docker-compose up` will only start the LDAP server, listening on
port 389 on your machine. Uncomment other services in `docker-compose.yml` if
you want to use them.
#### LDAP server
After creating the Docker container for the first time (or after deleting it),
you need to run the following command once, in order to create the dirsrv
back-end:
docker-compose exec ldap dsconf localhost backend create --suffix="dc=kosmos,dc=org" --be-name="dev"
Now you can seed the back-end with data using this Rails task:
bundle exec rails ldap:setup
The setup task will first delete any existing entries in the directory tree
("dc=kosmos,dc=org"), and then create our development entries.
Note that all 389ds data is stored in `tmp/389ds`. So if you want to start over
with a fresh installation, delete both that directory as well as the container.
### Adding npm modules to use with Stimulus controllers
The following command downloads the specified npm module to `vendor/javascript`
and adds an entry for it to `config/importmap.rb`.
bin/importmap pin bech32 --download
### Solargraph
[Solargraph](https://solargraph.org/) is a Ruby language server, which you may
use with your editor to add features like auto-completion and syntax
validation. You can add inline documentation for bundled gems with this
command:
bundle exec yard gems
## Documentation
### Rails
* [Ruby on Rails](https://guides.rubyonrails.org/)
* [Sass](https://sass-lang.com/documentation)
* [Pagination](https://ddnexus.github.io/pagy/)
### Front-end
* [Tailwind CSS](https://tailwindcss.com/)
* [Sass](https://sass-lang.com/documentation)
* [Stimulus](https://stimulus.hotwired.dev/handbook/)
### Testing
@@ -60,6 +122,12 @@ manual LDIF imports etc. (or provide a staging instance)
* [Sidekiq](https://github.com/mperham/sidekiq/wiki/)
* [ActiveJob](https://github.com/mperham/sidekiq/wiki/Active-Job)
### Feature Flags
* [Flipper](https://www.flippercloud.io/docs/get-started/self-hosted)
## License
[GNU Affero General Public License v3.0](https://choosealicense.com/licenses/agpl-3.0/)
[1]: https://docs.docker.com/compose/install/

View File

@@ -1,3 +1,4 @@
//= link_tree ../images
//= link_tree ../../javascript .js
//= link_tree ../builds
//= link_tree ../../../vendor/javascript .js

View File

@@ -4,7 +4,9 @@
@import "components/base";
@import "components/buttons";
@import "components/dashboard_services";
@import "components/forms";
@import "components/links";
@import "components/notifications";
@import "components/pagination";
@import "components/tables";

View File

@@ -1,4 +1,8 @@
@layer base {
html {
font-size: 14px;
}
body {
@apply leading-none bg-cover bg-fixed;
background-image: linear-gradient(35deg, rgba(255,0,255,0.2) 0, rgba(13,79,153,0.8) 100%), url('/img/bg-1.jpg');
@@ -20,6 +24,10 @@
@apply text-xl mb-6;
}
h4 {
@apply font-bold mb-4 leading-6;
}
main section {
@apply pt-8 sm:pt-12;
}
@@ -32,10 +40,18 @@
@apply mb-4 leading-6;
}
main p:last-child {
@apply mb-0;
}
main ul {
@apply mb-6;
}
main ul:last-child {
@apply mb-0;
}
main ul li {
@apply leading-6;
}

View File

@@ -1,17 +1,25 @@
@layer components {
.btn {
@apply font-semibold rounded-md leading-none cursor-pointer text-center
@apply inline-block font-semibold rounded-md leading-none cursor-pointer text-center
transition-colors duration-75 focus:outline-none focus:ring-4;
}
.btn-md {
@apply btn;
@apply py-2.5 px-5 shadow-md;
@apply py-3 px-6;
}
.btn-sm {
@apply btn;
@apply py-1 px-2 text-sm shadow-sm;
@apply py-1 px-2 text-sm;
}
.btn-outline {
@apply border-2 border-gray-100 hover:bg-gray-100;
}
.btn-icon {
@apply px-3;
}
.btn-gray {
@@ -28,4 +36,9 @@
@apply bg-red-600 hover:bg-red-700 text-white
focus:ring-red-500 focus:ring-opacity-75;
}
.btn:disabled {
@apply bg-gray-100 hover:bg-gray-200 text-gray-400
focus:ring-gray-300 focus:ring-opacity-75;
}
}

View File

@@ -0,0 +1,5 @@
@layer components {
.services > div > a {
background-image: linear-gradient(110deg, rgba(255,255,255,0.99) 0, rgba(255,255,255,0.88) 100%);
}
}

View File

@@ -1,11 +1,20 @@
@layer components {
input[type=text], input[type=email], input[type=password],
input[type=number], select {
@apply mt-1 rounded-md bg-gray-100 focus:bg-white
input[type=number], select, textarea {
@apply rounded-md bg-gray-100 focus:bg-white
border-transparent focus:border-transparent focus:ring-2
focus:ring-blue-600 focus:ring-opacity-75;
}
input[type=text]:disabled,
input[type=email]:disabled {
@apply text-gray-700;
}
input.field_with_errors {
@apply border-b-red-600;
}
.field_with_errors {
@apply inline-block;
}

View File

@@ -5,10 +5,4 @@
&:visited { @apply text-indigo-600; }
&:active { @apply text-red-600; }
}
.devise-links {
a {
@apply ks-text-link;
}
}
}

View File

@@ -0,0 +1,45 @@
@layer components {
.pagy-nav.pagination {
@apply isolate inline-flex -space-x-px rounded-md shadow-sm;
}
.pagy-nav .page:not(.prev):not(.next) {
@apply hidden sm:inline-block;
}
.pagy-nav .page.next a {
@apply relative inline-flex items-center rounded-r-md border
border-gray-300 bg-white px-3 py-2 text-sm font-medium
text-gray-500 hover:bg-gray-100 focus:z-20;
}
.pagy-nav .page.prev a {
@apply relative inline-flex items-center rounded-l-md border
border-gray-300 bg-white px-3 py-2 text-sm font-medium
text-gray-500 hover:bg-gray-100 focus:z-20;
}
.pagy-nav .page.next.disabled {
@apply relative inline-flex items-center rounded-r-md border
border-gray-300 bg-gray-100 px-3 py-2 text-sm font-medium
text-gray-400 focus:z-20;
}
.pagy-nav .page.prev.disabled {
@apply relative inline-flex items-center rounded-l-md border
border-gray-300 bg-gray-100 px-3 py-2 text-sm font-medium
text-gray-400 focus:z-20;
}
.pagy-nav .page a, .page.gap {
@apply bg-white border-gray-300 text-gray-500 hover:bg-gray-100 relative
inline-flex items-center border px-4 py-2 text-sm font-medium
focus:z-20;
}
.pagy-nav .page.active {
@apply z-10 border-indigo-500 bg-indigo-50 text-indigo-600 relative
inline-flex items-center border px-4 py-2 text-sm font-medium
focus:z-20;
}
}

View File

@@ -7,16 +7,30 @@
@apply text-left;
}
table th {
table thead th {
@apply pb-3.5 text-sm font-normal uppercase text-gray-500;
}
table tbody th {
@apply text-left font-normal text-gray-500;
}
table th:not(:last-of-type),
table td:not(:last-of-type) {
@apply pr-2;
}
table td {
table td, tbody th {
@apply py-2;
}
table.divided {
@apply divide-y divide-gray-300;
}
table.divided tbody {
@apply divide-y divide-gray-200;
}
table.divided td, table.divided tbody th {
@apply py-3;
}
}

View File

@@ -0,0 +1,29 @@
<%= tag.public_send(@tag, class: "mb-6 last:mb-0") do %>
<% if @positioning == :vertical %>
<label class="block">
<p class="font-bold <%= @descripton.present? ? "mb-1" : "mb-2" %>">
<%= @title %>
</p>
<% if @descripton.present? %>
<p class="text-gray-500">
<%= @descripton %>
</p>
<% end %>
<%= content %>
</label>
<% elsif @positioning == :horizontal %>
<label class="block flex items-center justify-between">
<div class="flex flex-col">
<label class="font-bold mb-1"><%= @title %></label>
<% if @descripton.present? %>
<p class="text-gray-500"><%= @descripton %></p>
<% end %>
</div>
<div class="relative ml-4 inline-flex flex-shrink-0">
<%= content %>
</div>
</label>
<% else %>
<p>Invalid <code>positioning<code> argument for <code>FieldsetComponent</code>.</p>
<% end %>
<% end %>

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
module FormElements
class FieldsetComponent < ViewComponent::Base
def initialize(tag: "li", positioning: :vertical, title:, description: nil)
@tag = tag
@positioning = positioning
@title = title
@descripton = description
end
end
end

View File

@@ -0,0 +1,33 @@
<%= tag.public_send @tag, class: "flex items-center justify-between mb-6 last:mb-0",
data: @form_enabled ? {
controller: "settings--toggle",
:'settings--toggle-switch-enabled-value' => @enabled.to_s
} : nil do %>
<div class="flex flex-col">
<label class="font-bold mb-1"><%= @title %></label>
<p class="text-gray-500"><%= @descripton %></p>
</div>
<div class="relative ml-4 inline-flex flex-shrink-0">
<%= render FormElements::ToggleComponent.new(
enabled: @enabled,
input_enabled: @input_enabled,
class_names: @form_enabled ? "hidden" : nil,
data: {
:'settings--toggle-target' => "button",
action: "settings--toggle#toggleSwitch"
}) %>
<% if @form_enabled %>
<% if @attribute.present? %>
<%= @form.check_box @attribute, {
checked: @enabled,
data: { :'settings--toggle-target' => "checkbox" }
}, "true", "false" %>
<% else %>
<input name="<%= @field_name %>" type="hidden" value="false" autocomplete="off">
<%= check_box_tag @field_name, "true", @enabled, {
data: { :'settings--toggle-target' => "checkbox" }
} %>
<% end %>
<% end %>
</div>
<% end %>

View File

@@ -0,0 +1,19 @@
# frozen_string_literal: true
module FormElements
class FieldsetToggleComponent < ViewComponent::Base
def initialize(tag: "li", form: nil, attribute: nil, field_name: nil,
enabled: false, input_enabled: true, title:, description:)
@tag = tag
@form = form
@attribute = attribute
@field_name = field_name
@form_enabled = @form.present? || @field_name.present?
@enabled = enabled
@input_enabled = input_enabled
@title = title
@descripton = description
@button_text = @enabled ? "Switch off" : "Switch on"
end
end
end

View File

@@ -0,0 +1,15 @@
<%= button_tag type: "button", name: "toggle", data: @data,
role: "switch", aria: { checked: @enabled.to_s },
tabindex: @tabindex, disabled: !@input_enabled,
class: "#{ @enabled ? 'bg-blue-600' : 'bg-gray-200' }
#{ @class_names.present? ? @class_names : '' }
relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer
rounded-full border-2 border-transparent transition-colors
duration-200 ease-in-out focus:outline-none focus:ring-2
focus:ring-blue-600 focus:ring-offset-2" do %>
<span class="sr-only"><%= @button_text %></span>
<span aria-hidden="true" data-settings--toggle-target="switch"
class="<%= @enabled ? 'translate-x-5' : 'translate-x-0' %>
pointer-events-none inline-block h-5 w-5 transform rounded-full
bg-white shadow ring-0 transition duration-200 ease-in-out"></span>
<% end %>

View File

@@ -0,0 +1,13 @@
# frozen_string_literal: true
module FormElements
class ToggleComponent < ViewComponent::Base
def initialize(enabled:, input_enabled: true, data: nil, class_names: nil, tabindex: nil)
@enabled = !!enabled
@input_enabled = input_enabled
@data = data
@class_names = class_names
@tabindex = tabindex
end
end
end

View File

@@ -1,5 +1,5 @@
<main class="w-full max-w-6xl mx-auto pb-12 px-4 md:px-6 lg:px-8">
<div class="bg-white rounded-lg shadow px-6 sm:px-12 py-8 sm:py-12">
<div class="md:min-h-[50vh] bg-white rounded-lg shadow px-6 sm:px-12 py-8 sm:py-12">
<%= content %>
</div>
</main>

View File

@@ -1,6 +1,6 @@
<main class="w-full max-w-6xl mx-auto pb-12 px-4 md:px-6 lg:px-8">
<div class="bg-white rounded-lg shadow">
<div class="divide-y divide-gray-200 lg:grid lg:grid-cols-12 lg:divide-y-0 lg:divide-x">
<div class="md:min-h-[50vh] divide-y divide-gray-200 lg:grid lg:grid-cols-12 lg:divide-y-0 lg:divide-x">
<aside class="py-6 sm:py-8 lg:col-span-3">
<nav class="space-y-1">
<%= render partial: @sidenav_partial %>

View File

@@ -0,0 +1,10 @@
<main class="w-full max-w-6xl mx-auto pb-12 px-4 md:px-6 lg:px-8">
<div class="bg-white rounded-lg shadow">
<div class="px-6 sm:px-12 pt-2 sm:pt-4">
<%= render partial: @tabnav_partial %>
</div>
<div class="px-6 sm:px-12 py-8 sm:py-12">
<%= content %>
</div>
</div>
</main>

View File

@@ -0,0 +1,7 @@
# frozen_string_literal: true
class MainWithTabnavComponent < ViewComponent::Base
def initialize(tabnav_partial:)
@tabnav_partial = tabnav_partial
end
end

View File

@@ -0,0 +1,3 @@
<dl class="grid grid-cols-2 lg:grid-cols-4 gap-6 sm:gap-12">
<%= content %>
</dl>

View File

@@ -0,0 +1,4 @@
# frozen_string_literal: true
class QuickstatsContainerComponent < ViewComponent::Base
end

View File

@@ -0,0 +1,18 @@
<div class="">
<dt class="mb-2 text-gray-500">
<%= @title %>
</dt>
<dd>
<% if @type == :number %>
<span class="text-2xl"><%= number_with_delimiter @value %></span>
<% else %>
<span class="text-2xl"><%= @value %></span>
<% end %>
<% if @unit %>
<span><%= @unit %></span>
<% end %>
<% if @meta %>
<span class="text-gray-500"><%= @meta %></span>
<% end %>
</dd>
</div>

View File

@@ -0,0 +1,13 @@
# frozen_string_literal: true
class QuickstatsItemComponent < ViewComponent::Base
def initialize(type:, title:, value:, unit: nil, meta: nil, icon_name: nil, icon_color_class: nil)
@type = type
@title = title
@value = value
@unit = unit
@meta = meta
@icon_name = icon_name
@icon_color_class = icon_color_class
end
end

View File

@@ -1,4 +1,4 @@
<%= link_to @path, class: @link_class do %>
<%= link_to @path, class: @link_class, title: (@disabled ? "Coming soon" : nil) do %>
<%= render partial: "icons/#{@icon}", locals: { custom_class: @icon_class } %>
<span class="truncate"><%= @name %></span>
<% end %>

View File

@@ -1,8 +1,9 @@
# frozen_string_literal: true
class SidenavLinkComponent < ViewComponent::Base
def initialize(name:, path:, icon:, active: false, disabled: false)
def initialize(name:, level: 1, path:, icon:, active: false, disabled: false)
@name = name
@level = level
@path = path
@icon = icon
@active = active
@@ -12,12 +13,15 @@ class SidenavLinkComponent < ViewComponent::Base
end
def class_names_link(path)
px = @level == 1 ? "px-4" : "pl-8 pr-4"
base = "#{px} py-2 group border-l-4 flex items-center text-base font-medium"
if @active
"bg-teal-50 border-teal-500 text-teal-700 hover:bg-teal-50 hover:text-teal-700 group border-l-4 px-4 py-2 flex items-center text-base font-medium"
"#{base} bg-teal-50 border-teal-500 text-teal-700 hover:bg-teal-50 hover:text-teal-700"
elsif @disabled
"border-transparent text-gray-400 hover:bg-gray-50 group border-l-4 px-4 py-2 flex items-center text-base font-medium"
"#{base} border-transparent text-gray-400 hover:bg-gray-50"
else
"border-transparent text-gray-900 hover:bg-gray-50 hover:text-gray-900 group border-l-4 px-4 py-2 flex items-center text-base font-medium"
"#{base} border-transparent text-gray-900 hover:bg-gray-50 hover:text-gray-900"
end
end

View File

@@ -0,0 +1,3 @@
<%= link_to @path, class: @link_class do %>
<%= @name %>
<% end %>

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
class TabnavLinkComponent < ViewComponent::Base
def initialize(name:, path:, active: false, disabled: false)
@name = name
@path = path
@active = active
@disabled = disabled
@link_class = class_names_link(path)
end
def class_names_link(path)
if @active
"border-indigo-500 text-indigo-600 w-1/2 py-4 px-1 text-center border-b-2"
elsif @disabled
"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 w-1/2 py-4 px-1 text-center border-b-2"
else
"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 w-1/2 py-4 px-1 text-center border-b-2"
end
end
end

View File

@@ -7,10 +7,14 @@
<div class="md:col-span-4 mt-4 md:mt-0">
<p class="font-mono md:text-right mb-0 p-4 border border-gray-300 rounded-lg overflow-hidden">
<% if @balance %>
<span class="text-xl"><%= number_with_delimiter @balance %> sats</span><br>
<span class="text-2xl"><%= number_with_delimiter @balance %></span>
<span class="text-xl">sats</span>
<br>
<span class="text-sm text-gray-500">Available balance</span>
<% else %>
<span class="text-xl">n/a sats</span><br>
<span class="text-2xl">n/a</span>
<span class="text-xl">sats</span>
<br>
<span class="text-sm text-gray-500">Balance unavailable</span>
<% end %>
</p>

View File

@@ -0,0 +1,7 @@
class AccountController < ApplicationController
before_action :authenticate_user!
def index
@current_section = :account
end
end

View File

@@ -1,4 +1,5 @@
class Admin::BaseController < ApplicationController
include Pagy::Backend
before_action :authenticate_user!
before_action :authorize_admin
@@ -7,5 +8,4 @@ class Admin::BaseController < ApplicationController
def set_context
@context = :admin
end
end

View File

@@ -5,7 +5,12 @@ class Admin::DonationsController < Admin::BaseController
# GET /donations
# GET /donations.json
def index
@donations = Donation.all
@pagy, @donations = pagy(Donation.all.order('created_at desc'))
@stats = {
overall_sats: @donations.all.sum("amount_sats"),
donor_count: Donation.distinct.count(:user_id)
}
end
# GET /donations/1
@@ -29,10 +34,14 @@ class Admin::DonationsController < Admin::BaseController
respond_to do |format|
if @donation.save
format.html { redirect_to admin_donation_url(@donation), notice: 'Donation was successfully created.' }
format.html do
redirect_to admin_donation_url(@donation), flash: {
success: 'Donation was successfully created.'
}
end
format.json { render :show, status: :created, location: @donation }
else
format.html { render :new }
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @donation.errors, status: :unprocessable_entity }
end
end
@@ -43,10 +52,14 @@ class Admin::DonationsController < Admin::BaseController
def update
respond_to do |format|
if @donation.update(donation_params)
format.html { redirect_to admin_donation_url(@donation), notice: 'Donation was successfully updated.' }
format.html do
redirect_to admin_donation_url(@donation), flash: {
success: 'Donation was successfully updated.'
}
end
format.json { render :show, status: :ok, location: @donation }
else
format.html { render :edit }
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @donation.errors, status: :unprocessable_entity }
end
end
@@ -57,7 +70,10 @@ class Admin::DonationsController < Admin::BaseController
def destroy
@donation.destroy
respond_to do |format|
format.html { redirect_to admin_donations_url, notice: 'Donation was successfully destroyed.' }
format.html do redirect_to admin_donations_url, flash: {
success: 'Donation was successfully destroyed.'
}
end
format.json { head :no_content }
end
end

View File

@@ -1,8 +1,12 @@
class Admin::InvitationsController < Admin::BaseController
def index
@current_section = :invitations
@invitations_unused_count = Invitation.unused.count
@users_with_referrals_count = Invitation.used.distinct.count(:user_id)
@invitations_used = Invitation.used.order('used_at desc')
@pagy, @invitations_used = pagy(Invitation.used.order('used_at desc'))
@stats = {
available: Invitation.unused.count,
accepted: @invitations_used.length,
users_with_referrals: Invitation.used.distinct.count(:user_id)
}
end
end

View File

@@ -1,45 +0,0 @@
class Admin::LdapUsersController < Admin::BaseController
before_action :set_current_section
def index
attributes = %w{dn cn uid mail admin}
filter = Net::LDAP::Filter.eq("uid", "*")
@ou = params[:ou] || "kosmos.org"
treebase = "ou=#{@ou},cn=users,dc=kosmos,dc=org"
entries = ldap_client.search(base: treebase, filter: filter, attributes: attributes)
entries.sort_by! { |e| e.cn[0] }
@entries = entries.collect do |e|
{
uid: e.uid.first,
mail: e.try(:mail) ? e.mail.first : nil,
admin: e.try(:admin) ? 'admin' : nil
# password: e.userpassword.first
}
end
# ldap_client.get_operation_result
end
private
def ldap_client
ldap_client ||= Net::LDAP.new host: ldap_config['host'],
port: ldap_config['port'],
encryption: ldap_config['ssl'],
auth: {
method: :simple,
username: ldap_config['admin_user'],
password: ldap_config['admin_password']
}
end
def ldap_config
ldap_config ||= YAML.load(ERB.new(File.read("#{Rails.root}/config/ldap.yml")).result)[Rails.env]
end
def set_current_section
@current_section = :ldap_users
end
end

View File

@@ -0,0 +1,21 @@
class Admin::LightningController < Admin::BaseController
before_action :check_feature_enabled
def index
@current_section = :lightning
@users = User.pluck(:cn, :ou, :ln_account)
@accounts = LndhubAccount.with_balances.order(balance: :desc).to_a
@ln = {}
@ln[:current_balance] = LndhubAccount.current.joins(:ledgers).sum("account_ledgers.amount")
@ln[:users_with_sats] = @accounts.length
end
def check_feature_enabled
if !Setting.lndhub_admin_enabled?
flash[:alert] = "Lightning Admin UI not enabled"
redirect_to admin_root_path and return
end
end
end

View File

@@ -0,0 +1,12 @@
class Admin::Settings::RegistrationsController < Admin::SettingsController
def index
end
def create
update_settings
redirect_to admin_settings_registrations_path, flash: {
success: "Settings saved"
}
end
end

View File

@@ -0,0 +1,19 @@
class Admin::Settings::ServicesController < Admin::SettingsController
def index
@service = params[:s]
if @service.blank?
redirect_to admin_settings_services_path(params: { s: "discourse" })
end
end
def create
service = params.require(:service)
update_settings
redirect_to admin_settings_services_path(params: { s: service }), flash: {
success: "Settings saved"
}
end
end

View File

@@ -0,0 +1,40 @@
class Admin::SettingsController < Admin::BaseController
before_action :set_current_section
def index
end
def update_settings
@errors = ActiveModel::Errors.new(Setting.new)
changed_keys = []
setting_params.keys.each do |key|
next if setting_params[key].nil? ||
(Setting.send(key).to_s == setting_params[key].strip)
changed_keys.push(key)
setting = Setting.new(var: key)
setting.value = setting_params[key].strip
unless setting.valid?
@errors.merge!(setting.errors)
end
end
if @errors.any?
render :index and return
end
changed_keys.each do |key|
Setting.send("#{key}=", setting_params[key].strip)
end
end
private
def set_current_section
@current_section = :settings
end
def setting_params
params.require(:setting).permit(Setting.editable_keys.map(&:to_sym))
end
end

View File

@@ -0,0 +1,35 @@
class Admin::UsersController < Admin::BaseController
before_action :set_user, only: [:show]
before_action :set_current_section
def index
ldap = LdapService.new
@ou = params[:ou] || Setting.primary_domain
@orgs = ldap.fetch_organizations
@pagy, @users = pagy(User.where(ou: @ou).order(cn: :asc))
@stats = {
users_confirmed: User.where(ou: @ou).confirmed.count,
users_pending: User.where(ou: @ou).pending.count
}
end
def show
if Setting.lndhub_admin_enabled?
@lndhub_user = @user.lndhub_user
end
@services_enabled = @user.services_enabled
end
private
def set_user
address = params[:address].split("@")
@user = User.where(cn: address.first, ou: address.last).first
end
def set_current_section
@current_section = :users
end
end

View File

@@ -0,0 +1,5 @@
class Api::BaseController < ApplicationController
layout false
end

View File

@@ -0,0 +1,13 @@
class Api::KreditsController < Api::BaseController
def onchain_btc_balance
btcpay = BtcPay.new
balance = btcpay.onchain_wallet_balance
render json: balance
rescue => error
Rails.logger.warn "Failed to fetch kredits BTC wallet balance: #{error.message}"
render json: { error: 'Failed to fetch wallet balance' },
status: 500
end
end

View File

@@ -3,6 +3,18 @@ class ApplicationController < ActionController::Base
render :text => exception, :status => 500
end
before_action :sentry_set_user
def sentry_set_user
return unless Setting.sentry_enabled
if user_signed_in?
Sentry.set_user(id: current_user.id, username: current_user.cn)
else
Sentry.set_user({})
end
end
def require_user_signed_in
unless user_signed_in?
redirect_to welcome_path and return

View File

@@ -1,5 +1,5 @@
class DonationsController < ApplicationController
before_action :require_user_signed_in
class Contributions::DonationsController < ApplicationController
before_action :authenticate_user!
# GET /donations
# GET /donations.json

View File

@@ -0,0 +1,8 @@
class Contributions::ProjectsController < ApplicationController
before_action :authenticate_user!
# GET /contributions
def index
@current_section = :contributions
end
end

View File

@@ -2,6 +2,6 @@ class DashboardController < ApplicationController
before_action :require_user_signed_in
def index
@current_section = :dashboard
@current_section = :services
end
end

View File

@@ -0,0 +1,17 @@
class Discourse::SsoController < ApplicationController
before_action :authenticate_user!
def connect
secret = Setting.discourse_connect_secret
sso = DiscourseApi::SingleSignOn.parse(request.query_string, secret)
sso.external_id = current_user.id
sso.email = current_user.email
sso.username = current_user.cn
sso.name = current_user.display_name
sso.admin = current_user.is_admin?
sso.sso_secret = secret
redirect_to sso.to_url("#{Setting.discourse_public_url}/session/sso_login"),
allow_other_host: true
end
end

View File

@@ -1,11 +1,11 @@
class InvitationsController < ApplicationController
before_action :require_user_signed_in, except: ["show"]
before_action :authenticate_user!, except: ["show"]
before_action :require_user_signed_out, only: ["show"]
# GET /invitations
def index
@invitations_unused = current_user.invitations.unused
@invitations_used = current_user.invitations.used
@invitations_used = current_user.invitations.used.order('used_at desc')
@current_section = :invitations
end
@@ -27,7 +27,10 @@ class InvitationsController < ApplicationController
respond_to do |format|
if @invitation.save
format.html { redirect_to @invitation, notice: 'Invitation was successfully created.' }
format.html do redirect_to @invitation, flash: {
success: 'Invitation was successfully created.'
}
end
format.json { render :show, status: :created, location: @invitation }
else
format.html { render :new }

View File

@@ -1,7 +1,8 @@
class LnurlpayController < ApplicationController
before_action :check_feature_enabled
before_action :find_user_by_address
MIN_SATS = 100
MIN_SATS = 10
MAX_SATS = 1_000_000
MAX_COMMENT_CHARS = 100
@@ -17,6 +18,20 @@ class LnurlpayController < ApplicationController
}
end
def keysend
http_status :not_found and return unless Setting.lndhub_keysend_enabled?
render json: {
status: "OK",
tag: "keysend",
pubkey: Setting.lndhub_public_key,
customData: [{
customKey: "696969",
customValue: @user.ln_account
}]
}
end
def invoice
amount = params[:amount].to_i / 1000 # msats
address = params[:address]
@@ -32,7 +47,7 @@ class LnurlpayController < ApplicationController
return
end
memo = "Sats for #{address}"
memo = "To #{address}"
memo = "#{memo}: \"#{comment}\"" if comment.present?
payment_request = @user.ln_create_invoice({
@@ -72,4 +87,9 @@ class LnurlpayController < ApplicationController
comment.length <= MAX_COMMENT_CHARS
end
private
def check_feature_enabled
http_status :not_found unless Setting.lndhub_enabled?
end
end

View File

@@ -1,7 +0,0 @@
class SecurityController < ApplicationController
before_action :require_user_signed_in
def index
@current_section = :security
end
end

View File

@@ -0,0 +1,137 @@
require "rqrcode"
require "lnurl"
class Services::LightningController < ApplicationController
before_action :authenticate_user!
before_action :authenticate_with_lndhub
before_action :set_current_section
before_action :fetch_balance
def index
@wallet_url = "lndhub://#{current_user.ln_account}:#{current_user.ln_password}@#{ENV['LNDHUB_PUBLIC_URL']}"
initialize_lndhub_qr_code
end
def transactions
@transactions = fetch_transactions
end
def qr_lnurlp
lnurlp_url = "https://kosmos.org/.well-known/lnurlp/#{current_user.cn}"
lnurlp_bech32 = Lnurl.new(lnurlp_url).to_bech32
qr_code = RQRCode::QRCode.new("lightning:" + lnurlp_bech32)
respond_to do |format|
format.svg do
qr_svg = qr_code.as_svg(
color: "000",
shape_rendering: "crispEdges",
module_size: 6,
standalone: true,
use_path: true,
svg_attributes: {
class: 'inline-block'
}
)
send_data(
qr_svg,
filename: "bitcoin-lightning-#{current_user.address}.svg",
type: "image/svg+xml"
)
end
format.png do
qr_png = qr_code.as_png(
fill: "white",
color: "black",
size: 1024,
)
send_data(
qr_png,
filename: "bitcoin-lightning-#{current_user.address}.png",
type: "image/png"
)
end
end
end
private
def initialize_lndhub_qr_code
qr_code = RQRCode::QRCode.new(@wallet_url)
@lndhub_qr_svg = qr_code.as_svg(
color: "000",
shape_rendering: "crispEdges",
module_size: 6,
standalone: true,
use_path: true,
svg_attributes: {
class: 'inline-block'
}
)
end
def authenticate_with_lndhub(options={})
if session[:ln_auth_token].present? && !options[:force_reauth]
@ln_auth_token = session[:ln_auth_token]
else
lndhub = Lndhub.new
auth_token = lndhub.authenticate(current_user)
session[:ln_auth_token] = auth_token
@ln_auth_token = auth_token
end
rescue => e
Sentry.capture_exception(e) if Setting.sentry_enabled?
end
def set_current_section
@current_section = :services
end
def fetch_balance
lndhub = Lndhub.new
data = lndhub.balance @ln_auth_token
@balance = data["BTC"]["AvailableBalance"] rescue nil
rescue AuthError
authenticate_with_lndhub(force_reauth: true)
raise if @fetch_balance_retried
@fetch_balance_retried = true
fetch_balance
end
def fetch_transactions
lndhub = Lndhub.new
txs = lndhub.gettxs @ln_auth_token
invoices = lndhub.getuserinvoices(@ln_auth_token).select{|i| i["ispaid"]}
process_transactions(txs + invoices)
rescue AuthError
authenticate_with_lndhub(force_reauth: true)
raise if @fetch_transactions_retried
@fetch_transactions_retried = true
fetch_transactions
end
def process_transactions(txs)
txs.collect do |tx|
if tx["type"] == "bitcoind_tx"
tx["amount_sats"] = (tx["amount"] * 100000000).to_i
tx["datetime"] = Time.at(tx["time"].to_i)
tx["title"] = "Received"
tx["description"] = "On-chain topup"
tx["received"] = true
else
tx["amount_sats"] = tx["value"] || tx["amt"]
tx["fee"] = tx["type"] == "paid_invoice" ? tx["fee"] : nil
tx["datetime"] = Time.at(tx["timestamp"].to_i)
tx["title"] = tx["type"] == "paid_invoice" ? "Sent" : "Received"
tx["description"] = tx["memo"] || tx["description"]
tx["received"] = tx["type"] == "user_invoice"
end
end
# Handle an edge case where lndhub.go includes a failed payment in the
# list, which wasn't actually booked
txs.reject!{ |tx| tx["type"] == "paid_invoice" && tx["payment_preimage"].blank? }
txs.sort{ |a,b| b["datetime"] <=> a["datetime"] }
end
end

View File

@@ -0,0 +1,30 @@
class Services::RemotestorageController < ApplicationController
before_action :require_user_signed_in
before_action :require_service_enabled
before_action :require_feature_enabled
before_action :set_current_section
def dashboard
# unless current_user.services_enabled.include?(:remotestorage)
# redirect_to service_remotestorage_info_path
# end
end
private
def require_feature_enabled
unless Flipper.enabled?(:remotestorage, current_user)
http_status :forbidden
end
end
def require_service_enabled
unless Setting.remotestorage_enabled?
http_status :not_found
end
end
def set_current_section
@current_section = :services
end
end

View File

@@ -1,7 +1,54 @@
require 'securerandom'
class SettingsController < ApplicationController
before_action :require_user_signed_in
before_action :authenticate_user!
before_action :set_main_nav_section
before_action :set_settings_section, only: [:show, :update, :update_email]
before_action :set_user, only: [:show, :update, :update_email]
def index
redirect_to setting_path(:profile)
end
def show
if @settings_section == "experiments"
session[:shared_secret] ||= SecureRandom.base64(12)
end
end
def update
@user.preferences.merge!(user_params[:preferences] || {})
@user.display_name = user_params[:display_name]
if @user.save
if @user.display_name && (@user.display_name != @user.ldap_entry[:display_name])
LdapManager::UpdateDisplayName.call(@user.dn, user_params[:display_name])
end
redirect_to setting_path(@settings_section), flash: {
success: 'Settings saved.'
}
else
@validation_errors = @user.errors
render :show, status: :unprocessable_entity
end
end
def update_email
if @user.valid_ldap_authentication?(email_params[:current_password])
if @user.update email: email_params[:email]
redirect_to setting_path(:account), flash: {
notice: 'Please confirm your new address using the confirmation link we just sent you.'
}
else
@validation_errors = @user.errors
render :show, status: :unprocessable_entity
end
else
redirect_to setting_path(:account), flash: {
error: 'Password did not match your current password. Try again.'
}
end
end
def reset_password
@@ -10,4 +57,79 @@ class SettingsController < ApplicationController
msg = "We have sent you an email with a link to reset your password."
redirect_to check_your_email_path, notice: msg
end
def set_nostr_pubkey
signed_event = nostr_event_params[:signed_event].to_h.symbolize_keys
is_valid_id = NostrManager::ValidateId.call(signed_event)
is_valid_sig = NostrManager::VerifySignature.call(signed_event)
is_correct_content = signed_event[:content] == "Connect my public key to #{current_user.address} (confirmation #{session[:shared_secret]})"
unless is_valid_id && is_valid_sig && is_correct_content
flash[:alert] = "Public key could not be verified"
http_status :unprocessable_entity and return
end
pubkey_taken = User.all_except(current_user).where(
ou: current_user.ou, nostr_pubkey: signed_event[:pubkey]
).any?
if pubkey_taken
flash[:alert] = "Public key already in use for a different account"
http_status :unprocessable_entity and return
end
current_user.update! nostr_pubkey: signed_event[:pubkey]
session[:shared_secret] = nil
flash[:success] = "Public key verification successful"
http_status :ok
rescue
flash[:alert] = "Public key could not be verified"
http_status :unprocessable_entity and return
end
# DELETE /settings/nostr_pubkey
def remove_nostr_pubkey
current_user.update! nostr_pubkey: nil
redirect_to setting_path(:experiments), flash: {
success: 'Public key removed from account'
}
end
private
def set_main_nav_section
@current_section = :settings
end
def set_settings_section
@settings_section = params[:section]
allowed_sections = [:profile, :account, :lightning, :xmpp, :experiments]
unless allowed_sections.include?(@settings_section.to_sym)
redirect_to setting_path(:profile)
end
end
def set_user
@user = current_user
end
def user_params
params.require(:user).permit(:display_name, preferences: [
:lightning_notify_sats_received,
:xmpp_exchange_contacts_with_invitees
])
end
def email_params
params.require(:user).permit(:email, :current_password)
end
def nostr_event_params
params.permit(signed_event: [
:id, :pubkey, :created_at, :kind, :tags, :content, :sig
])
end
end

View File

@@ -88,7 +88,7 @@ class SignupController < ApplicationController
if session[:new_user].present?
@user = User.new(session[:new_user])
else
@user = User.new(ou: "kosmos.org")
@user = User.new(ou: Setting.primary_domain)
end
end
@@ -98,7 +98,7 @@ class SignupController < ApplicationController
CreateAccount.call(
username: @user.cn,
domain: "kosmos.org",
domain: Setting.primary_domain,
email: @user.email,
password: @user.password,
invitation: @invitation

View File

@@ -0,0 +1,18 @@
class TurboController < ApplicationController
class Responder < ActionController::Responder
def to_turbo_stream
controller.render(options.merge(formats: :html))
rescue ActionView::MissingTemplate => error
if get?
raise error
elsif has_errors? && default_action
render rendering_options.merge(formats: :html, status: :unprocessable_entity)
else
redirect_to navigation_location
end
end
end
self.responder = Responder
respond_to :html, :turbo_stream
end

View File

@@ -0,0 +1,17 @@
# frozen_string_literal: true
class Users::ConfirmationsController < Devise::ConfirmationsController
# GET /resource/confirmation?confirmation_token=abcdef
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
yield resource if block_given?
if resource.errors.empty?
set_flash_message!(:success, :confirmed)
resource.devise_after_confirmation
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
end
end
end

View File

@@ -0,0 +1,18 @@
class Users::DeviseController < ApplicationController
class Responder < ActionController::Responder
def to_turbo_stream
controller.render(options.merge(formats: :html))
rescue ActionView::MissingTemplate => error
if get?
raise error
elsif has_errors? && default_action
render rendering_options.merge(formats: :html, status: :unprocessable_entity)
else
redirect_to navigation_location
end
end
end
self.responder = Responder
respond_to :html, :turbo_stream
end

View File

@@ -1,81 +0,0 @@
require "rqrcode"
class WalletController < ApplicationController
before_action :require_user_signed_in
before_action :authenticate_with_lndhub
before_action :set_current_section
before_action :fetch_balance
def index
@wallet_url = "lndhub://#{current_user.ln_login}:#{current_user.ln_password}@#{ENV['LNDHUB_PUBLIC_URL']}"
qrcode = RQRCode::QRCode.new(@wallet_url)
@svg = qrcode.as_svg(
color: "000",
shape_rendering: "crispEdges",
module_size: 6,
standalone: true,
use_path: true,
svg_attributes: {
class: 'inline-block'
}
)
end
def transactions
@transactions = fetch_transactions
end
private
def authenticate_with_lndhub
if session["ln_auth_token"].present?
@ln_auth_token = session["ln_auth_token"]
else
lndhub = Lndhub.new
auth_token = lndhub.authenticate(current_user)
session["ln_auth_token"] = auth_token
@ln_auth_token = auth_token
end
rescue
# TODO add exception tracking
end
def set_current_section
@current_section = :wallet
end
def fetch_balance
lndhub = Lndhub.new
data = lndhub.balance @ln_auth_token
@balance = data["BTC"]["AvailableBalance"] rescue nil
end
def fetch_transactions
lndhub = Lndhub.new
txs = lndhub.gettxs @ln_auth_token
invoices = lndhub.getuserinvoices(@ln_auth_token).select{|i| i["ispaid"]}
process_transactions(txs + invoices)
end
def process_transactions(txs)
txs.collect do |tx|
if tx["type"] == "bitcoind_tx"
tx["amount_sats"] = (tx["amount"] * 100000000).to_i
tx["datetime"] = Time.at(tx["time"].to_i)
tx["title"] = "Received"
tx["description"] = "On-chain topup"
tx["received"] = true
else
tx["amount_sats"] = tx["value"] || tx["amt"]
tx["datetime"] = Time.at(tx["timestamp"].to_i)
tx["title"] = tx["type"] == "paid_invoice" ? "Sent" : "Received"
tx["description"] = tx["memo"] || tx["description"]
tx["received"] = tx["type"] == "user_invoice"
end
end
txs.sort{ |a,b| b["datetime"] <=> a["datetime"] }
end
end

View File

@@ -0,0 +1,57 @@
class WebfingerController < ApplicationController
before_action :allow_cross_origin_requests, only: [:show]
layout false
def show
resource = params[:resource]
if resource && resource.match(/acct:\w+/)
useraddress = resource.split(":").last
username, org = useraddress.split("@")
username.downcase!
unless User.where(cn: username, ou: org).any?
head 404 and return
end
render json: webfinger(useraddress).to_json,
content_type: "application/jrd+json"
else
head 422 and return
end
end
private
def webfinger(useraddress)
links = [];
links << remotestorage_link(useraddress) if Setting.remotestorage_enabled
{ "links" => links }
end
def remotestorage_link(useraddress)
# TODO use when OAuth routes are available
# auth_url = new_rs_oauth_url(useraddress)
auth_url = "https://example.com/rs/oauth"
storage_url = "#{Setting.rs_storage_url}/#{useraddress}"
{
"rel" => "http://tools.ietf.org/id/draft-dejong-remotestorage",
"href" => storage_url,
"properties" => {
"http://remotestorage.io/spec/version" => "draft-dejong-remotestorage-13",
"http://tools.ietf.org/html/rfc6749#section-4.2" => auth_url,
"http://tools.ietf.org/html/rfc6750#section-2.3" => nil, # access token via a HTTP query parameter
"http://tools.ietf.org/html/rfc7233": "GET", # content range requests
"http://remotestorage.io/spec/web-authoring": nil
}
}
end
def allow_cross_origin_requests
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, OPTIONS'
end
end

View File

@@ -0,0 +1,46 @@
class WebhooksController < ApplicationController
skip_forgery_protection
before_action :authorize_request
def lndhub
begin
payload = JSON.parse(request.body.read, symbolize_names: true)
head :no_content and return unless payload[:type] == "incoming"
rescue
head :unprocessable_entity and return
end
user = User.find_by!(ln_account: payload[:user_login])
notify = user.preferences[:lightning_notify_sats_received]
case notify
when "xmpp"
notify_xmpp(user.address, payload[:amount], payload[:memo])
when "email"
NotificationMailer.with(user: user, amount_sats: payload[:amount])
.lightning_sats_received.deliver_later
end
head :ok
end
private
# TODO refactor into mailer-like generic class/service
def notify_xmpp(address, amt_sats, memo)
payload = {
type: "normal",
from: Setting.primary_domain,
to: address,
subject: "Sats received!",
body: "#{helpers.number_with_delimiter amt_sats} sats received in your Lightning wallet:\n> #{memo}"
}
XmppSendMessageJob.perform_later(payload)
end
def authorize_request
if !ENV['WEBHOOKS_ALLOWED_IPS'].split(',').include?(request.remote_ip)
head :forbidden and return
end
end
end

View File

@@ -0,0 +1,16 @@
class WellKnownController < ApplicationController
def nostr
http_status :unprocessable_entity and return if params[:name].blank?
domain = request.headers["X-Forwarded-Host"].presence || Setting.primary_domain
@user = User.where(cn: params[:name], ou: domain).first
http_status :not_found and return if @user.nil? || @user.nostr_pubkey.blank?
respond_to do |format|
format.json do
render json: {
names: { "#{@user.cn}": @user.nostr_pubkey }
}.to_json
end
end
end
end

1
app/errors/auth_error.rb Normal file
View File

@@ -0,0 +1 @@
class AuthError < StandardError; end

View File

@@ -1,4 +1,6 @@
module ApplicationHelper
include Pagy::Frontend
def sats_to_btc(sats)
sats.to_f / 100000000
end
@@ -10,5 +12,10 @@ module ApplicationHelper
"text-gray-300 hover:bg-gray-900/30 hover:text-white active:bg-gray-900/30 active:text-white px-3 py-2 rounded-md font-medium text-base md:text-sm block md:inline-block"
end
end
end
# Colors available: gray, red, yellow, green, blue, purple, pink
# (Add more colors by adding classes to the safelist in tailwind.config.js)
def badge(text, color)
tag.span text, class: "inline-flex items-center rounded-full bg-#{color}-100 px-2.5 py-0.5 text-xs font-medium text-#{color}-800"
end
end

View File

@@ -1,2 +0,0 @@
module LdapUsersHelper
end

View File

@@ -0,0 +1,2 @@
module UsersHelper
end

View File

@@ -0,0 +1,16 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["source", "trigger"]
copy (event) {
event.preventDefault();
navigator.clipboard.writeText(this.sourceTarget.value);
this.triggerTarget.querySelector('.content-initial').classList.add('hidden');
this.triggerTarget.querySelector('.content-active').classList.remove('hidden');
setTimeout(() => {
this.triggerTarget.querySelector('.content-initial').classList.remove('hidden');
this.triggerTarget.querySelector('.content-active').classList.add('hidden');
}, 2000)
}
}

View File

@@ -4,6 +4,10 @@ export default class extends Controller {
static targets = ["buttons", "countdown"]
connect() {
// Devise timeoutable ends up adding a second flash message without content
// TODO investigate bug
if (this.element.textContent.trim() == "true") return;
const timeoutSeconds = parseInt(this.data.get("timeout"));
setTimeout(() => {

View File

@@ -0,0 +1,27 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = [ "emailField", "editEmailButton" ]
static values = { validationFailed: Boolean }
connect () {
if (this.validationFailedValue) return;
this.emailFieldTarget.disabled = true;
this.element.querySelectorAll(".initial-hidden").forEach(el => {
el.classList.add("hidden");
})
this.element.querySelectorAll(".initial-visible").forEach(el => {
el.classList.remove("hidden");
})
}
editEmail () {
this.emailFieldTarget.disabled = false;
this.emailFieldTarget.select();
this.editEmailButtonTarget.classList.add("hidden");
this.element.querySelectorAll(".initial-hidden").forEach(el => {
el.classList.remove("hidden");
})
}
}

View File

@@ -0,0 +1,65 @@
import { Controller } from "@hotwired/stimulus"
import { bech32 } from "bech32"
function hexToBytes (hex) {
let bytes = []
for (let c = 0; c < hex.length; c += 2) {
bytes.push(parseInt(hex.substr(c, 2), 16))
}
return bytes
}
// Connects to data-controller="settings--nostr-pubkey"
export default class extends Controller {
static targets = [ "noExtension", "setPubkey", "pubkeyBech32Input" ]
static values = { userAddress: String, pubkeyHex: String, sharedSecret: String }
connect () {
if (this.hasPubkeyHexValue && this.pubkeyHexValue.length > 0) {
this.pubkeyBech32InputTarget.value = this.pubkeyBech32
}
if (window.nostr) {
if (this.hasSetPubkeyTarget) {
this.setPubkeyTarget.disabled = false
}
} else {
this.noExtensionTarget.classList.remove("hidden")
}
}
async setPubkey () {
this.setPubkeyTarget.disabled = true
try {
const signedEvent = await window.nostr.signEvent({
created_at: Math.floor(Date.now() / 1000),
kind: 1,
tags: [],
content: `Connect my public key to ${this.userAddressValue} (confirmation ${this.sharedSecretValue})`
})
const res = await fetch("/settings/set_nostr_pubkey", {
method: "POST", credentials: "include", headers: {
"Accept": "application/json", 'Content-Type': 'application/json',
"X-CSRF-Token": this.csrfToken
}, body: JSON.stringify({ signed_event: signedEvent })
});
window.location.reload()
} catch (error) {
console.warn('Unable to verify pubkey:', error.message)
this.setPubkeyTarget.disabled = false
}
}
get pubkeyBech32 () {
const words = bech32.toWords(hexToBytes(this.pubkeyHexValue))
return bech32.encode('npub', words)
}
get csrfToken () {
const element = document.head.querySelector('meta[name="csrf-token"]')
return element.getAttribute("content")
}
}

View File

@@ -0,0 +1,30 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = [ "button", "switch", "checkbox" ]
static values = { switchEnabled: Boolean }
connect () {
this.buttonTarget.classList.remove("hidden")
this.checkboxTarget.classList.add("hidden")
}
toggleSwitch () {
this.switchEnabledValue = !this.switchEnabledValue
this.checkboxTarget.checked = this.switchEnabledValue
if (this.switchEnabledValue) {
this.buttonTarget.setAttribute("aria-checked", "true");
this.buttonTarget.classList.remove("bg-gray-200")
this.buttonTarget.classList.add("bg-blue-600")
this.switchTarget.classList.remove("translate-x-0")
this.switchTarget.classList.add("translate-x-5")
} else {
this.buttonTarget.setAttribute("aria-checked", "false");
this.buttonTarget.classList.remove("bg-blue-600")
this.buttonTarget.classList.add("bg-gray-200")
this.switchTarget.classList.remove("translate-x-5")
this.switchTarget.classList.add("translate-x-0")
}
}
}

View File

@@ -18,7 +18,7 @@ class CreateLdapUserJob < ApplicationJob
def ldap_client
ldap_client ||= Net::LDAP.new host: ldap_config['host'],
port: ldap_config['port'],
encryption: ldap_config['ssl'],
# encryption: ldap_config['ssl'],
auth: {
method: :simple,
username: ldap_config['admin_user'],

View File

@@ -0,0 +1,13 @@
class CreateLndhubAccountJob < ApplicationJob
queue_as :default
def perform(user)
return if user.ln_account.present? && user.ln_password.present?
lndhub = LndhubV2.new
credentials = lndhub.create_account
user.update! ln_account: credentials["login"],
ln_password: credentials["password"]
end
end

View File

@@ -1,13 +0,0 @@
class CreateLndhubWalletJob < ApplicationJob
queue_as :default
def perform(user)
return if user.ln_login.present? && user.ln_password.present?
lndhub = Lndhub.new
credentials = lndhub.create({ partnerid: user.ou, accounttype: "user" })
user.update! ln_login: credentials["login"],
ln_password: credentials["password"]
end
end

View File

@@ -1,18 +0,0 @@
class ExchangeXmppContactsJob < ApplicationJob
queue_as :default
def perform(inviter, username, domain)
ejabberd = EjabberdApiClient.new
ejabberd.add_rosteritem({
"localuser": username, "localhost": domain,
"user": inviter.cn, "host": inviter.ou,
"nick": inviter.cn, "group": "Friends", "subs": "both"
})
ejabberd.add_rosteritem({
"localuser": inviter.cn, "localhost": inviter.ou,
"user": username, "host": domain,
"nick": username, "group": "Friends", "subs": "both"
})
end
end

View File

@@ -0,0 +1,22 @@
class XmppExchangeContactsJob < ApplicationJob
queue_as :default
def perform(inviter, invitee)
return unless inviter.services_enabled.include?("xmpp") &&
invitee.services_enabled.include?("xmpp") &&
inviter.preferences[:xmpp_exchange_contacts_with_invitees]
ejabberd = EjabberdApiClient.new
ejabberd.add_rosteritem({
"localuser": invitee.cn, "localhost": invitee.ou,
"user": inviter.cn, "host": inviter.ou,
"nick": inviter.cn, "group": Setting.ejabberd_buddy_roster, "subs": "both"
})
ejabberd.add_rosteritem({
"localuser": inviter.cn, "localhost": inviter.ou,
"user": invitee.cn, "host": invitee.ou,
"nick": invitee.cn, "group": Setting.ejabberd_buddy_roster, "subs": "both"
})
end
end

View File

@@ -0,0 +1,8 @@
class XmppSendMessageJob < ApplicationJob
queue_as :default
def perform(payload)
ejabberd = EjabberdApiClient.new
ejabberd.send_message payload
end
end

View File

@@ -0,0 +1,26 @@
class XmppSetDefaultBookmarksJob < ApplicationJob
queue_as :default
def perform(user)
return unless Setting.xmpp_default_rooms.any?
@user = user
ejabberd = EjabberdApiClient.new
ejabberd.private_set user, storage_content
end
def storage_content
bookmarks = ""
Setting.xmpp_default_rooms.each do |r|
bookmarks << conference_element(
jid: r[/<(.+)>/, 1], name: r[/^(.+)\s/, 1], nick: @user.cn,
autojoin: Setting.xmpp_autojoin_default_rooms
)
end
"<storage xmlns='storage:bookmarks'>#{bookmarks}</storage>"
end
def conference_element(jid:, name:, autojoin: false, nick:)
"<conference jid='#{jid}' name='#{name}' autojoin='#{autojoin.to_s}'><nick>#{nick}</nick></conference>"
end
end

View File

@@ -1,4 +1,3 @@
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end

View File

@@ -0,0 +1,23 @@
# A custom mailer that can be used from the Rails console for one-off emails
# today, and later connected from an admin panel mailing page.
#
# Assign any template variables you want to use:
#
# user = User.first
#
# Create the email body from a custom email template file:
#
# body = ERB.new(File.read('./tmp/mailer-1.txt.erb')).result binding
#
# Send email via Sidekiq:
#
# CustomMailer.with(user: user, subject: "Important announcement", body: body).custom_message.deliver_later
#
class CustomMailer < ApplicationMailer
def custom_message
@user = params[:user]
@subject = params[:subject]
@body = params[:body]
mail(to: @user.email, subject: @subject)
end
end

View File

@@ -0,0 +1,34 @@
# frozen_string_literal: true
if defined?(ActionMailer)
class Devise::Mailer < Devise.parent_mailer.constantize
include Devise::Mailers::Helpers
def confirmation_instructions(record, token, opts = {})
@token = token
if record.pending_reconfirmation?
devise_mail(record, :reconfirmation_instructions, opts)
else
devise_mail(record, :confirmation_instructions, opts)
end
end
def reset_password_instructions(record, token, opts = {})
@token = token
devise_mail(record, :reset_password_instructions, opts)
end
def unlock_instructions(record, token, opts = {})
@token = token
devise_mail(record, :unlock_instructions, opts)
end
def email_changed(record, opts = {})
devise_mail(record, :email_changed, opts)
end
def password_change(record, opts = {})
devise_mail(record, :password_change, opts)
end
end
end

View File

@@ -0,0 +1,8 @@
class NotificationMailer < ApplicationMailer
def lightning_sats_received
@user = params[:user]
@amount_sats = params[:amount_sats]
@subject = "Sats received"
mail to: @user.email, subject: @subject
end
end

View File

@@ -3,7 +3,9 @@ class Donation < ApplicationRecord
belongs_to :user
# Validations
validates_presence_of :user
validates_presence_of :amount_sats
validates_presence_of :paid_at
# Hooks
# TODO before_create :store_fiat_value

View File

@@ -1,6 +1,7 @@
class Invitation < ApplicationRecord
# Relations
belongs_to :user
belongs_to :invitee, class_name: "User", foreign_key: 'invited_user_id', optional: true
# Validations
validates_presence_of :user

View File

@@ -0,0 +1,21 @@
class LndhubAccount < LndhubBase
self.table_name = "accounts"
self.inheritance_column = :_type_disabled
has_many :ledgers, class_name: "LndhubAccountLedger",
foreign_key: "account_id"
belongs_to :user, class_name: "LndhubUser",
foreign_key: "user_id"
scope :current, -> { where(type: "current") }
scope :outgoing, -> { where(type: "outgoing") }
scope :incoming, -> { where(type: "incoming") }
scope :fees, -> { where(type: "fees") }
scope :with_balances, -> {
current.joins(:user).joins(:ledgers)
.group("accounts.id", "users.login")
.select("accounts.id, users.login, SUM(account_ledgers.amount) AS balance")
}
end

View File

@@ -0,0 +1,3 @@
class LndhubAccountLedger < LndhubBase
self.table_name = "account_ledgers"
end

View File

@@ -0,0 +1,4 @@
class LndhubBase < ActiveRecord::Base
self.abstract_class = true
establish_connection :lndhub
end

27
app/models/lndhub_user.rb Normal file
View File

@@ -0,0 +1,27 @@
class LndhubUser < LndhubBase
self.table_name = "users"
self.inheritance_column = :_type_disabled
has_many :accounts, class_name: "LndhubAccount",
foreign_key: "user_id"
belongs_to :user, class_name: "User",
primary_key: "ln_account",
foreign_key: "login"
def balance
accounts.current.first.ledgers.sum("account_ledgers.amount").to_i.abs
end
def sum_outgoing
accounts.outgoing.first.ledgers.sum("account_ledgers.amount").to_i.abs
end
def sum_incoming
accounts.incoming.first.ledgers.sum("account_ledgers.amount").to_i.abs
end
def sum_fees
accounts.fees.first.ledgers.sum("account_ledgers.amount").to_i.abs
end
end

133
app/models/setting.rb Normal file
View File

@@ -0,0 +1,133 @@
# RailsSettings Model
class Setting < RailsSettings::Base
cache_prefix { "v1" }
field :primary_domain, type: :string,
default: ENV["PRIMARY_DOMAIN"].presence
field :accounts_domain, type: :string,
default: ENV["AKKOUNTS_DOMAIN"].presence
#
# Internal services
#
field :redis_url, type: :string, readonly: true,
default: ENV["REDIS_URL"] || "redis://localhost:6379/0"
#
# Registrations
#
field :reserved_usernames, type: :array, default: %w[
account accounts donations mail webmaster support
]
#
# XMPP
#
field :xmpp_default_rooms, type: :array, default: []
field :xmpp_autojoin_default_rooms, type: :boolean, default: false
#
# Sentry
#
field :sentry_enabled, type: :boolean, readonly: true,
default: (ENV["SENTRY_DSN"].present?.to_s || false)
#
# Discourse
#
field :discourse_public_url, type: :string, readonly: true,
default: ENV["DISCOURSE_PUBLIC_URL"].presence
field :discourse_enabled, type: :boolean,
default: (ENV["DISCOURSE_PUBLIC_URL"].present?.to_s || false)
field :discourse_connect_secret, type: :string, readonly: true,
default: ENV["DISCOURSE_CONNECT_SECRET"].presence
#
# ejabberd
#
field :ejabberd_enabled, type: :boolean,
default: (ENV["EJABBERD_API_URL"].present?.to_s || false)
field :ejabberd_api_url, type: :string, readonly: true,
default: ENV["EJABBERD_API_URL"].presence
field :ejabberd_admin_url, type: :string, readonly: true,
default: ENV["EJABBERD_ADMIN_URL"].presence
field :ejabberd_buddy_roster, type: :string,
default: "Buddies"
#
# Gitea
#
field :gitea_public_url, type: :string, readonly: true,
default: ENV["GITEA_PUBLIC_URL"].presence
field :gitea_enabled, type: :boolean,
default: (ENV["GITEA_PUBLIC_URL"].present?.to_s || false)
#
# Lightning Network
#
field :lndhub_api_url, type: :string, readonly: true,
default: ENV["LNDHUB_API_URL"].presence
field :lndhub_enabled, type: :boolean,
default: (ENV["LNDHUB_API_URL"].present?.to_s || false)
field :lndhub_admin_enabled, type: :boolean,
default: (ENV["LNDHUB_ADMIN_UI"] || false)
field :lndhub_public_key, type: :string, readonly: true,
default: (ENV["LNDHUB_PUBLIC_KEY"] || "")
field :lndhub_keysend_enabled, type: :boolean,
default: -> { self.lndhub_public_key.present?.to_s || false }
#
# Mastodon
#
field :mastodon_public_url, type: :string, readonly: true,
default: ENV["MASTODON_PUBLIC_URL"].presence
field :mastodon_enabled, type: :boolean,
default: (ENV["MASTODON_PUBLIC_URL"].present?.to_s || false)
#
# MediaWiki
#
field :mediawiki_public_url, type: :string, readonly: true,
default: ENV["MEDIAWIKI_PUBLIC_URL"].presence
field :mediawiki_enabled, type: :boolean,
default: (ENV["MEDIAWIKI_PUBLIC_URL"].present?.to_s || false)
#
# Nostr
#
field :nostr_enabled, type: :boolean, default: true
#
# RemoteStorage
#
field :remotestorage_enabled, type: :boolean,
default: (ENV["RS_STORAGE_URL"].present?.to_s || false)
field :rs_storage_url, type: :string,
default: ENV["RS_STORAGE_URL"].presence
end

View File

@@ -1,30 +1,63 @@
class User < ApplicationRecord
include EmailValidatable
attr_accessor :display_name
serialize :preferences, UserPreferences
# Relations
has_many :invitations, dependent: :destroy
has_one :invitation, inverse_of: :invitee, foreign_key: 'invited_user_id'
has_one :inviter, through: :invitation, source: :user
has_many :invitees, through: :invitations
has_many :donations, dependent: :nullify
validates_uniqueness_of :cn
validates_length_of :cn, :minimum => 3
has_one :lndhub_user, class_name: "LndhubUser", inverse_of: "user",
primary_key: "ln_account", foreign_key: "login"
has_many :accounts, through: :lndhub_user
validates_uniqueness_of :cn, scope: :ou
validates_length_of :cn, minimum: 3
validates_format_of :cn, with: /\A([a-z0-9\-])*\z/,
if: Proc.new{ |u| u.cn.present? },
message: "is invalid. Please use only letters, numbers and -"
validates_format_of :cn, without: /\A-/,
if: Proc.new{ |u| u.cn.present? },
message: "is invalid. Usernames need to start with a letter."
# FIXME This needs a server restart to apply values
validates_format_of :cn, without: /\A(#{Setting.reserved_usernames.join('|')})\z/i,
message: "has already been taken"
validates_uniqueness_of :email
validates :email, email: true
lockbox_encrypts :ln_login
lockbox_encrypts :ln_password
validates_length_of :display_name, minimum: 3, maximum: 35, allow_blank: true,
if: -> { defined?(@display_name) }
validates_uniqueness_of :nostr_pubkey, allow_blank: true
scope :confirmed, -> { where.not(confirmed_at: nil) }
scope :pending, -> { where(confirmed_at: nil) }
scope :all_except, -> (user) { where.not(id: user) }
has_encrypted :ln_login, :ln_password
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :ldap_authenticatable,
:confirmable,
:recoverable,
:validatable
:validatable,
:timeoutable,
:rememberable
def ldap_before_save
self.email = Devise::LDAP::Adapter.get_ldap_param(self.cn, "mail").first
dn = Devise::LDAP::Adapter.get_ldap_param(self.cn, "dn")
self.ou = dn.split(',').select{|e| e[0..1] == "ou"}.first.delete_prefix("ou=")
self.ou = dn.split(',')
.select{|e| e[0..1] == "ou"}.first
.delete_prefix("ou=")
if self.confirmed_at.blank? && self.confirmation_token.blank?
# User had an account with a trusted email address before akkounts was a thing
@@ -32,11 +65,33 @@ class User < ApplicationRecord
end
end
def reset_password(new_password, new_password_confirmation)
if new_password == new_password_confirmation && ::Devise.ldap_update_password
Devise::LDAP::Adapter.update_password(login_with, new_password)
def devise_after_confirmation
if ldap_entry[:mail] != self.email
# E-Mail update confirmed
LdapManager::UpdateEmail.call(self.dn, self.email)
else
# E-Mail from signup confirmed (i.e. account activation)
enable_service %w[ discourse gitea mediawiki xmpp ]
#TODO enable in development when we have easy setup of ejabberd etc.
return if Rails.env.development? || !Setting.ejabberd_enabled?
XmppExchangeContactsJob.perform_later(inviter, self) if inviter.present?
XmppSetDefaultBookmarksJob.perform_later(self)
end
clear_reset_password_token if valid?
end
def send_devise_notification(notification, *args)
devise_mailer.send(notification, self, *args).deliver_later
end
def reset_password(new_password, new_password_confirmation)
self.password = new_password
self.password_confirmation = new_password_confirmation
return false unless valid?
Devise::LDAP::Adapter.update_password(login_with, new_password)
clear_reset_password_token
save
end
@@ -62,4 +117,47 @@ class User < ApplicationRecord
lndhub.authenticate self
lndhub.addinvoice payload
end
def dn
return @dn if defined?(@dn)
@dn = Devise::LDAP::Adapter.get_dn(self.cn)
end
def ldap_entry(reload: false)
return @ldap_entry if defined?(@ldap_entry) && !reload
@ldap_entry = ldap.fetch_users(uid: self.cn, ou: self.ou).first
end
def display_name
@display_name ||= ldap_entry[:display_name]
end
def services_enabled
ldap_entry[:service] || []
end
def enable_service(service)
current_services = services_enabled
new_services = Array(service).map(&:to_s)
services = (current_services + new_services).uniq
ldap.replace_attribute(dn, :service, services)
end
def disable_service(service)
current_services = services_enabled
disabled_services = Array(service).map(&:to_s)
services = (current_services - disabled_services).uniq
ldap.replace_attribute(dn, :service, services)
end
def disable_all_services
ldap.delete_attribute(dn,:service)
end
private
def ldap
return @ldap_service if defined?(@ldap_service)
@ldap_service = LdapService.new
end
end

View File

@@ -0,0 +1,29 @@
DEFAULT_PREFS = YAML.load_file("#{Rails.root}/config/default_preferences.yml")
class UserPreferences
def self.dump(value)
process(value).to_yaml
end
def self.load(string)
stored_prefs = YAML.load(string || "{}")
DEFAULT_PREFS.merge(stored_prefs).with_indifferent_access
end
def self.is_integer?(value)
value.to_i.to_s == value
end
def self.process(hash)
hash.each do |key, value|
if value == "true"
hash[key] = true
elsif value == "false"
hash[key] = false
elsif value.is_a?(String) && is_integer?(value)
hash[key] = value.to_i
end
end
hash.stringify_keys!.to_h
end
end

32
app/services/btc_pay.rb Normal file
View File

@@ -0,0 +1,32 @@
#
# API Docs: https://docs.btcpayserver.org/API/Greenfield/v1/
#
class BtcPay
def initialize
@base_url = ENV["BTCPAY_API_URL"]
@store_id = Rails.application.credentials.btcpay[:store_id]
@auth_token = Rails.application.credentials.btcpay[:auth_token]
end
def onchain_wallet_balance
res = get "stores/#{@store_id}/payment-methods/onchain/BTC/wallet"
{
balance: res["balance"].to_f,
unconfirmed_balance: res["unconfirmedBalance"].to_f,
confirmed_balance: res["confirmedBalance"].to_f
}
end
private
def get(endpoint)
res = Faraday.get("#{@base_url}/#{endpoint}", {}, {
"Content-Type" => "application/json",
"Accept" => "application/json",
"Authorization" => "token #{@auth_token}"
})
JSON.parse(res.body)
end
end

Some files were not shown because too many files have changed in this diff Show More