Notify user about incoming sats via XMPP
This commit is contained in:
parent
4232df302b
commit
9e988e92d1
@ -6,15 +6,33 @@ class WebhooksController < ApplicationController
|
||||
def lndhub
|
||||
begin
|
||||
payload = JSON.parse(request.body.read, symbolize_names: true)
|
||||
return unless payload[:type] == "incoming"
|
||||
rescue
|
||||
head :unprocessable_entity and return
|
||||
end
|
||||
|
||||
user = User.find_by(ln_account: payload[:user_login])
|
||||
|
||||
# TODO make configurable
|
||||
notify_xmpp(user.address, payload[:amount], payload[:memo])
|
||||
|
||||
head :ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def notify_xmpp(address, amt_sats, memo)
|
||||
payload = {
|
||||
type: "normal",
|
||||
from: "kosmos.org", # TODO domain config
|
||||
# to: address,
|
||||
to: "raucao@kosmos.org",
|
||||
subject: "Sats received!",
|
||||
body: "#{amt_sats} sats received in your wallet. Memo: \"#{memo}\""
|
||||
}
|
||||
XmppSendMessageJob.perform_later(payload)
|
||||
end
|
||||
|
||||
def authorize_request
|
||||
if !ENV['WEBHOOKS_ALLOWED_IPS'].split(',').include?(request.remote_ip)
|
||||
head :forbidden and return
|
||||
|
Loading…
x
Reference in New Issue
Block a user