Fix dbConverter error when unmarshalling (failed) deliveries
This commit is contained in:
parent
fb1560a1f5
commit
5da4c3d3b9
@ -12,6 +12,11 @@
|
||||
|
||||
- exerr.New | exerr.Wrap
|
||||
|
||||
- Properly handle UNREGISTERED firebase error (remove token from client?)
|
||||
WRN logic/application.go:284 > FCM Delivery failed error="FCM-Request returned 404:
|
||||
{ \"error\": {\n \"code\": 404,\n \"message\": \"Requested entity was not found.\",\n \"status\": \"NOT_FOUND\",\n \"details\": [\n {\n \"@type\": \"type.googleapis.com/google.firebase.fcm.v1.FcmError\",\n \"errorCode\": \"UNREGISTERED\"\n }\n ]\n }\n}\n"
|
||||
ClientID=CLNGOSVIaCnm5cQmCI0pC5kR MessageID=MSG8w7NvVRm0OtJERnJlEe3C
|
||||
|
||||
#### UNSURE
|
||||
|
||||
- (?) default-priority for channels
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"blackforestbytes.com/simplecloudnotifier/db"
|
||||
"blackforestbytes.com/simplecloudnotifier/models"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/rfctime"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/sq"
|
||||
"time"
|
||||
)
|
||||
@ -27,7 +28,7 @@ func (db *Database) CreateRetryDelivery(ctx db.TxContext, client models.Client,
|
||||
TimestampFinalized: nil,
|
||||
Status: models.DeliveryStatusRetry,
|
||||
RetryCount: 0,
|
||||
NextDelivery: models.NewSCNTimePtr(&next),
|
||||
NextDelivery: rfctime.NewRFC3339NanoPtr(&next),
|
||||
FCMMessageID: nil,
|
||||
}
|
||||
|
||||
@ -75,7 +76,7 @@ func (db *Database) ListRetrieableDeliveries(ctx db.TxContext, pageSize int) ([]
|
||||
}
|
||||
|
||||
return sq.QueryAll[models.Delivery](ctx, tx, "SELECT * FROM deliveries WHERE status = 'RETRY' AND next_delivery < :next ORDER BY next_delivery ASC LIMIT :lim", sq.PP{
|
||||
"next": time2DB(time.Now()),
|
||||
"next": time.Now().Format(time.RFC3339Nano),
|
||||
"lim": pageSize,
|
||||
}, sq.SModeExtended, sq.Safe)
|
||||
}
|
||||
@ -125,7 +126,7 @@ func (db *Database) SetDeliveryRetry(ctx db.TxContext, delivery models.Delivery)
|
||||
}
|
||||
|
||||
_, err = tx.Exec(ctx, "UPDATE deliveries SET status = 'RETRY', next_delivery = :next, retry_count = :rc WHERE delivery_id = :did", sq.PP{
|
||||
"next": scn.NextDeliveryTimestamp(time.Now()),
|
||||
"next": scn.NextDeliveryTimestamp(time.Now()).Format(time.RFC3339Nano),
|
||||
"rc": delivery.RetryCount + 1,
|
||||
"did": delivery.DeliveryID,
|
||||
})
|
||||
|
@ -1,5 +1,7 @@
|
||||
package models
|
||||
|
||||
import "gogs.mikescher.com/BlackForestBytes/goext/rfctime"
|
||||
|
||||
type DeliveryStatus string //@enum:type
|
||||
|
||||
const (
|
||||
@ -17,7 +19,7 @@ type Delivery struct {
|
||||
TimestampFinalized *SCNTime `db:"timestamp_finalized" json:"timestamp_finalized"`
|
||||
Status DeliveryStatus `db:"status" json:"status"`
|
||||
RetryCount int `db:"retry_count" json:"retry_count"`
|
||||
NextDelivery *SCNTime `db:"next_delivery" json:"next_delivery"`
|
||||
NextDelivery *rfctime.RFC3339NanoTime `db:"next_delivery" json:"next_delivery"`
|
||||
FCMMessageID *string `db:"fcm_message_id" json:"fcm_message_id"`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user