WIP Add new lightning notification settings

This commit is contained in:
Râu Cao 2024-05-29 15:12:07 +01:00
parent bad3b7a2be
commit 5348a229a6
Signed by: raucao
GPG Key ID: 37036C356E56CC51
3 changed files with 43 additions and 4 deletions

View File

@ -12,7 +12,11 @@ class SettingsController < ApplicationController
end end
def show 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) session[:shared_secret] ||= SecureRandom.base64(12)
end end
end end

View File

@ -5,7 +5,7 @@
<%= render FormElements::FieldsetComponent.new( <%= render FormElements::FieldsetComponent.new(
positioning: :horizontal, positioning: :horizontal,
title: "Sats received", 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 %> ) do %>
<% f.fields_for :preferences do |p| %> <% f.fields_for :preferences do |p| %>
<%= p.select :lightning_notify_sats_received, options_for_select([ <%= p.select :lightning_notify_sats_received, options_for_select([
@ -15,6 +15,38 @@
], selected: @user.preferences[:lightning_notify_sats_received]) %> ], selected: @user.preferences[:lightning_notify_sats_received]) %>
<% end %> <% end %>
<% 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 %>
</ul> </ul>
</section> </section>
<section> <section>

View File

@ -1,3 +1,6 @@
remotestorage_notify_auth_created: email # or xmpp, email lightning_notify_sats_received: email
lightning_notify_sats_received: email # or xmpp 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 xmpp_exchange_contacts_with_invitees: true