disable changing settings while registering for push notifications (#2527)

This commit is contained in:
Parvesh Monu 2022-02-11 18:07:10 +05:30 committed by GitHub
parent 5925b3b7cc
commit 1c549f7d71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 20 deletions

View File

@ -1 +1 @@
0.94.0
0.94.1

View File

@ -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)
}