mirror of
https://github.com/believethehype/nostdress.git
synced 2026-07-03 15:03:34 -07:00
added associated note to bot message (if zap is connected to a note)
This commit is contained in:
@@ -52,6 +52,7 @@ type LNURLPayValuesCustom struct {
|
||||
Nip57ReceiptRelays []string `json:"nip57ReceiptRelays"`
|
||||
AwaitInvoicePaid bool `json:"awaitInvoicePaid"`
|
||||
Sender string `json:"sender"`
|
||||
Note string `json:"note"`
|
||||
}
|
||||
|
||||
func handleLNURL(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -282,11 +283,15 @@ func serveLNURLpSecond(w http.ResponseWriter, params *Params, username string, a
|
||||
//Check invoice paid only if we actually have a NIP57 event
|
||||
var awaitPaid = false
|
||||
var sender = ""
|
||||
var note = ""
|
||||
// nip57 - we need to store the newly created invoice in the zap receipt
|
||||
if zapEvent.Sig != "" {
|
||||
nip57Receipt = CreateNostrReceipt(zapEvent, invoice)
|
||||
awaitPaid = true
|
||||
sender = "@" + EncodeBench32Public(zapEvent.PubKey)
|
||||
if zapEvent.Tags.GetFirst([]string{"e"}) != nil {
|
||||
note = "@" + EncodeBench32Note(zapEvent.Tags.GetFirst([]string{"e"}).Value())
|
||||
}
|
||||
log.Debug().Str("Zap from", sender).Msg("Nostr")
|
||||
}
|
||||
|
||||
@@ -306,6 +311,7 @@ func serveLNURLpSecond(w http.ResponseWriter, params *Params, username string, a
|
||||
Nip57ReceiptRelays: nip57ReceiptRelays,
|
||||
AwaitInvoicePaid: awaitPaid,
|
||||
Sender: sender,
|
||||
Note: note,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,13 @@ func EncodeBench32Private(key string) string {
|
||||
return key
|
||||
}
|
||||
|
||||
func EncodeBench32Note(key string) string {
|
||||
if v, err := nip19.EncodeNote(key); err == nil {
|
||||
return v
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
func sendMessage(receiverKey string, message string) {
|
||||
|
||||
var relays []string
|
||||
|
||||
+12
-2
@@ -178,9 +178,19 @@ func WaitForInvoicePaid(payvalues LNURLPayValuesCustom, params *Params) {
|
||||
}
|
||||
|
||||
if params.Npub != "" && params.NotifyZapComment && payvalues.Comment != "" {
|
||||
go sendMessage(params.Npub, "Received Zap from "+payvalues.Sender+" with amount: "+strconv.FormatInt(amount, 10)+" "+satsr+" ⚡️. Comment: "+payvalues.Comment)
|
||||
if payvalues.Note != "" {
|
||||
go sendMessage(params.Npub, "Received Zap from "+payvalues.Sender+" with amount: "+strconv.FormatInt(amount, 10)+" "+satsr+" ⚡️ for note "+payvalues.Note+". Comment: "+payvalues.Comment)
|
||||
|
||||
} else {
|
||||
go sendMessage(params.Npub, "Received Profile Zap from "+payvalues.Sender+" with amount: "+strconv.FormatInt(amount, 10)+" "+satsr+" ⚡️. Comment: "+payvalues.Comment)
|
||||
}
|
||||
} else if params.Npub != "" && params.NotifyZaps {
|
||||
go sendMessage(params.Npub, "Received Zap from "+payvalues.Sender+" with amount: "+strconv.FormatInt(amount, 10)+" "+satsr+" ⚡️.")
|
||||
if payvalues.Note != "" {
|
||||
go sendMessage(params.Npub, "Received Zap from "+payvalues.Sender+" with amount: "+strconv.FormatInt(amount, 10)+" "+satsr+" ⚡️ for note "+payvalues.Note+".")
|
||||
|
||||
} else {
|
||||
go sendMessage(params.Npub, "Received Profile Zap from "+payvalues.Sender+" with amount: "+strconv.FormatInt(amount, 10)+" "+satsr+" ⚡️.")
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug().Str("ZAPPED ⚡️", "Published zap on Nostr").Msg("Nostr")
|
||||
|
||||
Reference in New Issue
Block a user