Per-payer group ticket ids; deactivate paid objects

The group ticket event was stored under ticket:<groupID>, so a later
/join by another user overwrote the payer and the invite link went to
whoever joined last. The id now includes the payer.

The pay, LNURL-withdraw and group-ticket confirm handlers left their
object Active after success, so a second press repeated the request.
They now deactivate it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-11-13 20:41:39 +00:00
co-authored by Claude Fable 5.1
parent b27b0b7bcb
commit 0bcb821b82
3 changed files with 10 additions and 3 deletions
+6 -3
View File
@@ -178,8 +178,10 @@ func (bot TipBot) groupRequestJoinHandler(ctx intercept.Context) (intercept.Cont
return ctx, fmt.Errorf("group not found")
}
// create tickets
id := fmt.Sprintf("ticket:%d", group.ID)
// create tickets. The id is per group and payer: with a per-group id a
// later /join overwrote the stored payer and the invite link went to
// whoever joined last, not to whoever paid.
id := fmt.Sprintf("ticket:%d:%d", group.ID, user.Telegram.ID)
invoiceEvent := &InvoiceEvent{
Base: storage.New(storage.ID(id)),
User: group.Ticket.Creator,
@@ -309,7 +311,8 @@ func (bot *TipBot) groupConfirmPayButtonHandler(ctx intercept.Context) (intercep
log.Errorln(errmsg)
return ctx, err
}
// if this was a join-ticket, we want to delete the invoice message
// the invoice is paid, a second press must not pay it again
ticketEvent.Active = false
// update the message and remove the button
bot.tryEditMessage(c, i18n.Translate(ticketEvent.LanguageCode, "invoicePaidMessage"), &tb.ReplyMarkup{})
+2
View File
@@ -306,6 +306,8 @@ func (bot *TipBot) confirmWithdrawHandler(ctx intercept.Context) (intercept.Cont
var response2 lnurl.LNURLResponse
json.Unmarshal(body, &response2)
if response2.Status == "OK" {
// the service accepted the invoice, a second press must not send another one
lnurlWithdrawState.Active = false
// update button text
bot.editSingleButton(ctx, c.Message, EditSingleButtonParams{Message: lnurlWithdrawState.Message, ButtonText: i18n.Translate(lnurlWithdrawState.LanguageCode, "lnurlWithdrawSuccess")})
+2
View File
@@ -224,6 +224,8 @@ func (bot *TipBot) confirmPayHandler(ctx intercept.Context) (intercept.Context,
return ctx, err
}
payData.Hash = invoice.PaymentHash
// the invoice is paid, a second press must not pay it again
payData.Active = false
// do balance check for keyboard update
_, err = bot.GetUserBalance(user)