Refactor user preferences, add defaults from file
* 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
This commit is contained in:
@@ -45,8 +45,8 @@ class SettingsController < ApplicationController
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(preferences: [
|
||||
lightning: [:notify_sats_received],
|
||||
xmpp: [:exchange_contacts_with_invitees]
|
||||
:lightning_notify_sats_received,
|
||||
:xmpp_exchange_contacts_with_invitees
|
||||
])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class WebhooksController < ApplicationController
|
||||
end
|
||||
|
||||
user = User.find_by!(ln_account: payload[:user_login])
|
||||
notify = user.preferences.dig("lightning", "notify_sats_received")
|
||||
notify = user.preferences[:lightning_notify_sats_received]
|
||||
case notify
|
||||
when "xmpp"
|
||||
notify_xmpp(user.address, payload[:amount], payload[:memo])
|
||||
|
||||
Reference in New Issue
Block a user