diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 8e307ca..a21c542 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -12,7 +12,11 @@ class SettingsController < ApplicationController end def show - if @settings_section == "nostr" + case @settings_section + when "lightning" + @notifications_enabled = @user.preferences[:lightning_notify_sats_received] != "disabled" || + @user.preferences[:lightning_notify_zap_received] != "disabled" + when "nostr" session[:shared_secret] ||= SecureRandom.base64(12) end end diff --git a/app/views/settings/_lightning.html.erb b/app/views/settings/_lightning.html.erb index 6e75343..42623d5 100644 --- a/app/views/settings/_lightning.html.erb +++ b/app/views/settings/_lightning.html.erb @@ -5,7 +5,7 @@ <%= render FormElements::FieldsetComponent.new( positioning: :horizontal, title: "Sats received", - description: "Notify me when sats are sent to my Lightning Address" + description: "Notify me when sats are sent to my Lightning account" ) do %> <% f.fields_for :preferences do |p| %> <%= p.select :lightning_notify_sats_received, options_for_select([ @@ -15,6 +15,38 @@ ], selected: @user.preferences[:lightning_notify_sats_received]) %> <% end %> <% end %> + <% if @user.nostr_pubkey.present? %> + <%= render FormElements::FieldsetComponent.new( + positioning: :horizontal, + title: "Zap received", + description: "Notify me when someone zaps me on Nostr" + ) do %> + <% f.fields_for :preferences do |p| %> + <%= p.select :lightning_notify_zap_received, options_for_select([ + ["off", "disabled"], + ["Chat (Jabber)", "xmpp"], + ["E-Mail", "email"] + ], selected: @user.preferences[:lightning_notify_zap_received]) %> + <% end %> + <% end %> + <% end %> + <% if @notifications_enabled %> + <%= render FormElements::FieldsetToggleComponent.new( + field_name: "user[preferences][lightning_notify_only_with_message]", + enabled: @user.preferences[:lightning_notify_only_with_message], + title: "Ignore transactions without message", + description: "Only send notifications when there is a message attached to the payment" + ) %> + <%= render FormElements::FieldsetComponent.new( + title: "Minimum amount", + description: "Only send notifications when amount is higher than this" + ) do %> + <%= f.number_field :lightning_notify_min_sats, + name: "user[preferences][lightning_notify_min_sats]", + class: "w-full", + value: @user.preferences[:lightning_notify_min_sats].to_i %> + <% end %> + <% end %>
diff --git a/config/default_preferences.yml b/config/default_preferences.yml index 8b622c1..8e31491 100644 --- a/config/default_preferences.yml +++ b/config/default_preferences.yml @@ -1,3 +1,6 @@ -remotestorage_notify_auth_created: email # or xmpp, email -lightning_notify_sats_received: email # or xmpp +lightning_notify_sats_received: email +lightning_notify_zap_received: disabled +lightning_notify_min_sats: 0 +lightning_notify_only_with_message: false +remotestorage_notify_auth_created: email xmpp_exchange_contacts_with_invitees: true