mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-22 11:35:21 +01:00
Only process push messages for the current logged in user. Do not unregister from push on logout.
This commit is contained in:
parent
7b9c00cd77
commit
fb77747a1b
@ -56,7 +56,6 @@ namespace Bit.Android
|
||||
Resolver.Resolve<ISyncService>(),
|
||||
Resolver.Resolve<IFingerprint>(),
|
||||
Resolver.Resolve<ISettings>(),
|
||||
Resolver.Resolve<IPushNotification>(),
|
||||
Resolver.Resolve<ILockService>(),
|
||||
Resolver.Resolve<IGoogleAnalyticsService>()));
|
||||
|
||||
|
@ -27,7 +27,6 @@ namespace Bit.App
|
||||
private readonly IAuthService _authService;
|
||||
private readonly IFingerprint _fingerprint;
|
||||
private readonly ISettings _settings;
|
||||
private readonly IPushNotification _pushNotification;
|
||||
private readonly ILockService _lockService;
|
||||
private readonly IGoogleAnalyticsService _googleAnalyticsService;
|
||||
|
||||
@ -39,7 +38,6 @@ namespace Bit.App
|
||||
ISyncService syncService,
|
||||
IFingerprint fingerprint,
|
||||
ISettings settings,
|
||||
IPushNotification pushNotification,
|
||||
ILockService lockService,
|
||||
IGoogleAnalyticsService googleAnalyticsService)
|
||||
{
|
||||
@ -50,7 +48,6 @@ namespace Bit.App
|
||||
_authService = authService;
|
||||
_fingerprint = fingerprint;
|
||||
_settings = settings;
|
||||
_pushNotification = pushNotification;
|
||||
_lockService = lockService;
|
||||
_googleAnalyticsService = googleAnalyticsService;
|
||||
|
||||
@ -211,7 +208,6 @@ namespace Bit.App
|
||||
|
||||
var deviceApiRepository = Resolver.Resolve<IDeviceApiRepository>();
|
||||
var appIdService = Resolver.Resolve<IAppIdService>();
|
||||
_pushNotification.Unregister();
|
||||
_settings.Remove(Constants.PushLastRegistrationDate);
|
||||
await Task.Run(() => deviceApiRepository.PutClearTokenAsync(appIdService.AppId)).ConfigureAwait(false);
|
||||
}
|
||||
|
@ -43,6 +43,11 @@ namespace Bit.App.Services
|
||||
_showNotification = false;
|
||||
Debug.WriteLine("Message Arrived: {0}", JsonConvert.SerializeObject(values));
|
||||
|
||||
if(!_authService.IsAuthenticated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
JToken token;
|
||||
if(!values.TryGetValue("type", StringComparison.OrdinalIgnoreCase, out token) || token == null)
|
||||
{
|
||||
@ -55,18 +60,34 @@ namespace Bit.App.Services
|
||||
case Enums.PushType.SyncCipherUpdate:
|
||||
case Enums.PushType.SyncCipherCreate:
|
||||
var createUpdateMessage = values.ToObject<SyncCipherPushNotification>();
|
||||
if(createUpdateMessage.UserId != _authService.UserId)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_syncService.SyncAsync(createUpdateMessage.Id);
|
||||
break;
|
||||
case Enums.PushType.SyncFolderDelete:
|
||||
var folderDeleteMessage = values.ToObject<SyncCipherPushNotification>();
|
||||
if(folderDeleteMessage.UserId != _authService.UserId)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_syncService.SyncDeleteFolderAsync(folderDeleteMessage.Id, folderDeleteMessage.RevisionDate);
|
||||
break;
|
||||
case Enums.PushType.SyncSiteDelete:
|
||||
var siteDeleteMessage = values.ToObject<SyncCipherPushNotification>();
|
||||
if(siteDeleteMessage.UserId != _authService.UserId)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_syncService.SyncDeleteSiteAsync(siteDeleteMessage.Id);
|
||||
break;
|
||||
case Enums.PushType.SyncCiphers:
|
||||
var cipherMessage = values.ToObject<SyncCiphersPushNotification>();
|
||||
if(cipherMessage.UserId != _authService.UserId)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_syncService.FullSyncAsync();
|
||||
break;
|
||||
default:
|
||||
|
@ -65,7 +65,6 @@ namespace Bit.iOS
|
||||
Resolver.Resolve<ISyncService>(),
|
||||
Resolver.Resolve<IFingerprint>(),
|
||||
Resolver.Resolve<ISettings>(),
|
||||
Resolver.Resolve<IPushNotification>(),
|
||||
Resolver.Resolve<ILockService>(),
|
||||
Resolver.Resolve<IGoogleAnalyticsService>()));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user