disable changing settings while registering for push notifications (#2527)
This commit is contained in:
parent
5925b3b7cc
commit
1c549f7d71
|
@ -729,29 +729,10 @@ func (api *PublicAPI) StopPushNotificationsServer() error {
|
|||
// PushNotification client endpoints
|
||||
|
||||
func (api *PublicAPI) RegisterForPushNotifications(ctx context.Context, deviceToken string, apnTopic string, tokenType protobuf.PushNotificationRegistration_TokenType) error {
|
||||
// We set both for now as they are equivalent
|
||||
err := api.service.accountsDB.SaveSetting("remote-push-notifications-enabled?", true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = api.service.accountsDB.SaveSetting("notifications-enabled?", true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return api.service.messenger.RegisterForPushNotifications(ctx, deviceToken, apnTopic, tokenType)
|
||||
}
|
||||
|
||||
func (api *PublicAPI) UnregisterFromPushNotifications(ctx context.Context) error {
|
||||
err := api.service.accountsDB.SaveSetting("remote-push-notifications-enabled?", false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = api.service.accountsDB.SaveSetting("notifications-enabled?", false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return api.service.messenger.UnregisterFromPushNotifications(ctx)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue