store and use notifications token

This commit is contained in:
boufni95 2025-07-23 15:45:42 +00:00
parent 5ee048a568
commit c18f71c548
27 changed files with 564 additions and 28 deletions

View file

@ -74,6 +74,7 @@ type Client struct {
EditDebit func(req DebitAuthorizationRequest) error
EncryptionExchange func(req EncryptionExchangeRequest) error
EnrollAdminToken func(req EnrollAdminTokenRequest) error
EnrollMessagingToken func(req MessagingToken) error
GetApp func() (*Application, error)
GetAppUser func(req GetAppUserRequest) (*AppUser, error)
GetAppUserLNURLInfo func(req GetAppUserLNURLInfoRequest) (*LnurlPayInfoResponse, error)
@ -667,6 +668,30 @@ func NewClient(params ClientParams) *Client {
}
return nil
},
EnrollMessagingToken: func(req MessagingToken) error {
auth, err := params.RetrieveUserAuth()
if err != nil {
return err
}
finalRoute := "/api/user/messaging/enroll"
body, err := json.Marshal(req)
if err != nil {
return err
}
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
if err != nil {
return err
}
result := ResultError{}
err = json.Unmarshal(resBody, &result)
if err != nil {
return err
}
if result.Status == "ERROR" {
return fmt.Errorf(result.Reason)
}
return nil
},
GetApp: func() (*Application, error) {
auth, err := params.RetrieveAppAuth()
if err != nil {

View file

@ -445,6 +445,10 @@ type ManageAuthorizations struct {
type ManageOperation struct {
Npub string `json:"npub"`
}
type MessagingToken struct {
Device_id string `json:"device_id"`
Firebase_messaging_token string `json:"firebase_messaging_token"`
}
type MetricsFile struct {
}
type MigrationUpdate struct {