Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename AddressTxsChangedPayload to ..ConfirmedPayload #12

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion breezsdk/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func createMessageFactory() services.FCMMessageBuilder {
switch notification.Template {
case notify.NOTIFICATION_PAYMENT_RECEIVED,
notify.NOTIFICATION_TX_CONFIRMED,
notify.NOTIFICATION_ADDRESS_TXS_CHANGED,
notify.NOTIFICATION_ADDRESS_TXS_CONFIRMED,
notify.NOTIFICATION_LNURLPAY_INFO,
notify.NOTIFICATION_LNURLPAY_INVOICE:

Expand Down
10 changes: 5 additions & 5 deletions http/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ func (p *TxConfirmedPayload) ToNotification(query *MobilePushWebHookQuery) *noti
}
}

type AddressTxsChangedPayload struct {
Template string `json:"template" binding:"required,eq=address_txs_changed"`
type AddressTxsConfirmedPayload struct {
Template string `json:"template" binding:"required,eq=address_txs_confirmed"`
Data struct {
Address string `json:"address" binding:"required"`
} `json:"data"`
}

func (p *AddressTxsChangedPayload) ToNotification(query *MobilePushWebHookQuery) *notify.Notification {
func (p *AddressTxsConfirmedPayload) ToNotification(query *MobilePushWebHookQuery) *notify.Notification {
return &notify.Notification{
Template: p.Template,
DisplayMessage: "Address transactions changed",
DisplayMessage: "Address transactions confirmed",
Type: query.Platform,
TargetIdentifier: query.Token,
AppData: query.AppData,
Expand Down Expand Up @@ -148,7 +148,7 @@ func addWebHookRouter(r *gin.RouterGroup, notifier *notify.Notifier) {
}

// Find a matching notification payload
payloads := []NotificationConvertible{&PaymentReceivedPayload{}, &TxConfirmedPayload{}, &AddressTxsChangedPayload{}, &LnurlPayInfoPayload{}, &LnurlPayInvoicePayload{}}
payloads := []NotificationConvertible{&PaymentReceivedPayload{}, &TxConfirmedPayload{}, &AddressTxsConfirmedPayload{}, &LnurlPayInfoPayload{}, &LnurlPayInvoicePayload{}}
var validPayload NotificationConvertible
for _, p := range payloads {
if err := c.ShouldBindBodyWith(p, binding.JSON); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions http/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ func TestAddressTXsChangedHook(t *testing.T) {
Platform: "android",
Token: "1234",
}
txAddresTXsChangedPayload := AddressTxsChangedPayload{
Template: notify.NOTIFICATION_ADDRESS_TXS_CHANGED,
txAddressTxsConfirmedPayload := AddressTxsConfirmedPayload{
Template: notify.NOTIFICATION_ADDRESS_TXS_CONFIRMED,
Data: struct {
Address string "json:\"address\" binding:\"required\""
}{
Address: "1234",
},
}
body, err := json.Marshal(txAddresTXsChangedPayload)
body, err := json.Marshal(txAddressTxsConfirmedPayload)
if err != nil {
t.Fatalf("failed to marshal notification %v", err)
}
expected := txAddresTXsChangedPayload.ToNotification(&query)
expected := txAddressTxsConfirmedPayload.ToNotification(&query)
testValidNotification(t, "/api/v1/notify?platform=android&token=1234", body, expected)
}

Expand Down
2 changes: 1 addition & 1 deletion notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
const (
NOTIFICATION_PAYMENT_RECEIVED = "payment_received"
NOTIFICATION_TX_CONFIRMED = "tx_confirmed"
NOTIFICATION_ADDRESS_TXS_CHANGED = "address_txs_changed"
NOTIFICATION_ADDRESS_TXS_CONFIRMED = "address_txs_confirmed"
NOTIFICATION_LNURLPAY_INFO = "lnurlpay_info"
NOTIFICATION_LNURLPAY_INVOICE = "lnurlpay_invoice"
)
Expand Down
Loading