diff --git a/src/Core/Models/PushNotification.cs b/src/Core/Models/PushNotification.cs index 9ba702b878..e7d1deefce 100644 --- a/src/Core/Models/PushNotification.cs +++ b/src/Core/Models/PushNotification.cs @@ -1,5 +1,6 @@ using Bit.Core.Enums; using System; +using System.Collections.Generic; namespace Bit.Core.Models { @@ -22,6 +23,7 @@ namespace Bit.Core.Models public Guid Id { get; set; } public Guid? UserId { get; set; } public Guid? OrganizationId { get; set; } + public IEnumerable CollectionIds { get; set; } public DateTime RevisionDate { get; set; } } diff --git a/src/Core/Services/IPushNotificationService.cs b/src/Core/Services/IPushNotificationService.cs index 131bca808f..805bf846df 100644 --- a/src/Core/Services/IPushNotificationService.cs +++ b/src/Core/Services/IPushNotificationService.cs @@ -2,13 +2,14 @@ using System.Threading.Tasks; using Bit.Core.Models.Table; using Bit.Core.Enums; +using System.Collections.Generic; namespace Bit.Core.Services { public interface IPushNotificationService { - Task PushSyncCipherCreateAsync(Cipher cipher); - Task PushSyncCipherUpdateAsync(Cipher cipher); + Task PushSyncCipherCreateAsync(Cipher cipher, IEnumerable collectionIds); + Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable collectionIds); Task PushSyncCipherDeleteAsync(Cipher cipher); Task PushSyncFolderCreateAsync(Folder folder); Task PushSyncFolderUpdateAsync(Folder folder); diff --git a/src/Core/Services/Implementations/AzureQueuePushNotificationService.cs b/src/Core/Services/Implementations/AzureQueuePushNotificationService.cs index 820c5af54c..4a8ba5c2aa 100644 --- a/src/Core/Services/Implementations/AzureQueuePushNotificationService.cs +++ b/src/Core/Services/Implementations/AzureQueuePushNotificationService.cs @@ -7,6 +7,7 @@ using Bit.Core.Models; using Microsoft.WindowsAzure.Storage.Queue; using Microsoft.WindowsAzure.Storage; using Microsoft.AspNetCore.Http; +using System.Collections.Generic; namespace Bit.Core.Services { @@ -32,22 +33,22 @@ namespace Bit.Core.Services _httpContextAccessor = httpContextAccessor; } - public async Task PushSyncCipherCreateAsync(Cipher cipher) + public async Task PushSyncCipherCreateAsync(Cipher cipher, IEnumerable collectionIds) { - await PushCipherAsync(cipher, PushType.SyncCipherCreate); + await PushCipherAsync(cipher, PushType.SyncCipherCreate, collectionIds); } - public async Task PushSyncCipherUpdateAsync(Cipher cipher) + public async Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable collectionIds) { - await PushCipherAsync(cipher, PushType.SyncCipherUpdate); + await PushCipherAsync(cipher, PushType.SyncCipherUpdate, collectionIds); } public async Task PushSyncCipherDeleteAsync(Cipher cipher) { - await PushCipherAsync(cipher, PushType.SyncLoginDelete); + await PushCipherAsync(cipher, PushType.SyncLoginDelete, null); } - private async Task PushCipherAsync(Cipher cipher, PushType type) + private async Task PushCipherAsync(Cipher cipher, PushType type, IEnumerable collectionIds) { if(cipher.OrganizationId.HasValue) { @@ -56,6 +57,7 @@ namespace Bit.Core.Services Id = cipher.Id, OrganizationId = cipher.OrganizationId, RevisionDate = cipher.RevisionDate, + CollectionIds = collectionIds, }; await SendMessageAsync(type, message, true); diff --git a/src/Core/Services/Implementations/CipherService.cs b/src/Core/Services/Implementations/CipherService.cs index fb540438f4..2a8d77163c 100644 --- a/src/Core/Services/Implementations/CipherService.cs +++ b/src/Core/Services/Implementations/CipherService.cs @@ -62,7 +62,7 @@ namespace Bit.Core.Services await _eventService.LogCipherEventAsync(cipher, Enums.EventType.Cipher_Created); // push - await _pushService.PushSyncCipherCreateAsync(cipher); + await _pushService.PushSyncCipherCreateAsync(cipher, null); } else { @@ -71,7 +71,7 @@ namespace Bit.Core.Services await _eventService.LogCipherEventAsync(cipher, Enums.EventType.Cipher_Updated); // push - await _pushService.PushSyncCipherUpdateAsync(cipher); + await _pushService.PushSyncCipherUpdateAsync(cipher, null); } } @@ -95,7 +95,7 @@ namespace Bit.Core.Services } // push - await _pushService.PushSyncCipherCreateAsync(cipher); + await _pushService.PushSyncCipherCreateAsync(cipher, null); } else { @@ -104,7 +104,7 @@ namespace Bit.Core.Services await _eventService.LogCipherEventAsync(cipher, Enums.EventType.Cipher_Updated); // push - await _pushService.PushSyncCipherUpdateAsync(cipher); + await _pushService.PushSyncCipherUpdateAsync(cipher, null); } } @@ -180,7 +180,7 @@ namespace Bit.Core.Services } // push - await _pushService.PushSyncCipherUpdateAsync(cipher); + await _pushService.PushSyncCipherUpdateAsync(cipher, null); } public async Task CreateAttachmentShareAsync(Cipher cipher, Stream stream, string fileName, long requestLength, @@ -264,7 +264,7 @@ namespace Bit.Core.Services await _eventService.LogCipherEventAsync(cipher, Enums.EventType.Cipher_AttachmentDeleted); // push - await _pushService.PushSyncCipherUpdateAsync(cipher); + await _pushService.PushSyncCipherUpdateAsync(cipher, null); } public async Task MoveManyAsync(IEnumerable cipherIds, Guid? destinationFolderId, Guid movingUserId) @@ -401,7 +401,7 @@ namespace Bit.Core.Services await _attachmentStorageService.CleanupAsync(cipher.Id); // push - await _pushService.PushSyncCipherUpdateAsync(cipher); + await _pushService.PushSyncCipherUpdateAsync(cipher, collectionIds); } public async Task ShareManyAsync(IEnumerable ciphers, Guid organizationId, @@ -476,7 +476,7 @@ namespace Bit.Core.Services await _eventService.LogCipherEventAsync(cipher, Enums.EventType.Cipher_UpdatedCollections); // push - await _pushService.PushSyncCipherUpdateAsync(cipher); + await _pushService.PushSyncCipherUpdateAsync(cipher, collectionIds); } public async Task ImportCiphersAsync( diff --git a/src/Core/Services/Implementations/MultiServicePushNotificationService.cs b/src/Core/Services/Implementations/MultiServicePushNotificationService.cs index 8952a9ae1d..c64d5f8ed2 100644 --- a/src/Core/Services/Implementations/MultiServicePushNotificationService.cs +++ b/src/Core/Services/Implementations/MultiServicePushNotificationService.cs @@ -47,15 +47,15 @@ namespace Bit.Core.Services } } - public Task PushSyncCipherCreateAsync(Cipher cipher) + public Task PushSyncCipherCreateAsync(Cipher cipher, IEnumerable collectionIds) { - PushToServices((s) => s.PushSyncCipherCreateAsync(cipher)); + PushToServices((s) => s.PushSyncCipherCreateAsync(cipher, collectionIds)); return Task.FromResult(0); } - public Task PushSyncCipherUpdateAsync(Cipher cipher) + public Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable collectionIds) { - PushToServices((s) => s.PushSyncCipherUpdateAsync(cipher)); + PushToServices((s) => s.PushSyncCipherUpdateAsync(cipher, collectionIds)); return Task.FromResult(0); } diff --git a/src/Core/Services/Implementations/NotificationHubPushNotificationService.cs b/src/Core/Services/Implementations/NotificationHubPushNotificationService.cs index c0a7e8c35e..39cdb85202 100644 --- a/src/Core/Services/Implementations/NotificationHubPushNotificationService.cs +++ b/src/Core/Services/Implementations/NotificationHubPushNotificationService.cs @@ -26,22 +26,22 @@ namespace Bit.Core.Services _httpContextAccessor = httpContextAccessor; } - public async Task PushSyncCipherCreateAsync(Cipher cipher) + public async Task PushSyncCipherCreateAsync(Cipher cipher, IEnumerable collectionIds) { - await PushCipherAsync(cipher, PushType.SyncCipherCreate); + await PushCipherAsync(cipher, PushType.SyncCipherCreate, collectionIds); } - public async Task PushSyncCipherUpdateAsync(Cipher cipher) + public async Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable collectionIds) { - await PushCipherAsync(cipher, PushType.SyncCipherUpdate); + await PushCipherAsync(cipher, PushType.SyncCipherUpdate, collectionIds); } public async Task PushSyncCipherDeleteAsync(Cipher cipher) { - await PushCipherAsync(cipher, PushType.SyncLoginDelete); + await PushCipherAsync(cipher, PushType.SyncLoginDelete, null); } - private async Task PushCipherAsync(Cipher cipher, PushType type) + private async Task PushCipherAsync(Cipher cipher, PushType type, IEnumerable collectionIds) { if(cipher.OrganizationId.HasValue) { diff --git a/src/Core/Services/Implementations/NotificationsApiPushNotificationService.cs b/src/Core/Services/Implementations/NotificationsApiPushNotificationService.cs index 4c0c54013a..01de688863 100644 --- a/src/Core/Services/Implementations/NotificationsApiPushNotificationService.cs +++ b/src/Core/Services/Implementations/NotificationsApiPushNotificationService.cs @@ -7,6 +7,7 @@ using Bit.Core.Models; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using System.Net.Http; +using System.Collections.Generic; namespace Bit.Core.Services { @@ -36,22 +37,22 @@ namespace Bit.Core.Services _httpContextAccessor = httpContextAccessor; } - public async Task PushSyncCipherCreateAsync(Cipher cipher) + public async Task PushSyncCipherCreateAsync(Cipher cipher, IEnumerable collectionIds) { - await PushCipherAsync(cipher, PushType.SyncCipherCreate); + await PushCipherAsync(cipher, PushType.SyncCipherCreate, collectionIds); } - public async Task PushSyncCipherUpdateAsync(Cipher cipher) + public async Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable collectionIds) { - await PushCipherAsync(cipher, PushType.SyncCipherUpdate); + await PushCipherAsync(cipher, PushType.SyncCipherUpdate, collectionIds); } public async Task PushSyncCipherDeleteAsync(Cipher cipher) { - await PushCipherAsync(cipher, PushType.SyncLoginDelete); + await PushCipherAsync(cipher, PushType.SyncLoginDelete, null); } - private async Task PushCipherAsync(Cipher cipher, PushType type) + private async Task PushCipherAsync(Cipher cipher, PushType type, IEnumerable collectionIds) { if(cipher.OrganizationId.HasValue) { @@ -60,6 +61,7 @@ namespace Bit.Core.Services Id = cipher.Id, OrganizationId = cipher.OrganizationId, RevisionDate = cipher.RevisionDate, + CollectionIds = collectionIds, }; await SendMessageAsync(type, message, true); diff --git a/src/Core/Services/Implementations/RelayPushNotificationService.cs b/src/Core/Services/Implementations/RelayPushNotificationService.cs index 34bffcaf67..a9f37f1eb5 100644 --- a/src/Core/Services/Implementations/RelayPushNotificationService.cs +++ b/src/Core/Services/Implementations/RelayPushNotificationService.cs @@ -7,6 +7,7 @@ using Bit.Core.Models; using System.Net.Http; using Bit.Core.Models.Api; using Microsoft.Extensions.Logging; +using System.Collections.Generic; namespace Bit.Core.Services { @@ -31,22 +32,22 @@ namespace Bit.Core.Services _logger = logger; } - public async Task PushSyncCipherCreateAsync(Cipher cipher) + public async Task PushSyncCipherCreateAsync(Cipher cipher, IEnumerable collectionIds) { - await PushCipherAsync(cipher, PushType.SyncCipherCreate); + await PushCipherAsync(cipher, PushType.SyncCipherCreate, collectionIds); } - public async Task PushSyncCipherUpdateAsync(Cipher cipher) + public async Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable collectionIds) { - await PushCipherAsync(cipher, PushType.SyncCipherUpdate); + await PushCipherAsync(cipher, PushType.SyncCipherUpdate, collectionIds); } public async Task PushSyncCipherDeleteAsync(Cipher cipher) { - await PushCipherAsync(cipher, PushType.SyncLoginDelete); + await PushCipherAsync(cipher, PushType.SyncLoginDelete, null); } - private async Task PushCipherAsync(Cipher cipher, PushType type) + private async Task PushCipherAsync(Cipher cipher, PushType type, IEnumerable collectionIds) { if(cipher.OrganizationId.HasValue) { diff --git a/src/Core/Services/NoopImplementations/NoopPushNotificationService.cs b/src/Core/Services/NoopImplementations/NoopPushNotificationService.cs index 89d305e624..51cc3d868e 100644 --- a/src/Core/Services/NoopImplementations/NoopPushNotificationService.cs +++ b/src/Core/Services/NoopImplementations/NoopPushNotificationService.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using Bit.Core.Enums; using Bit.Core.Models.Table; @@ -7,7 +8,7 @@ namespace Bit.Core.Services { public class NoopPushNotificationService : IPushNotificationService { - public Task PushSyncCipherCreateAsync(Cipher cipher) + public Task PushSyncCipherCreateAsync(Cipher cipher, IEnumerable collectionIds) { return Task.FromResult(0); } @@ -22,7 +23,7 @@ namespace Bit.Core.Services return Task.FromResult(0); } - public Task PushSyncCipherUpdateAsync(Cipher cipher) + public Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable collectionIds) { return Task.FromResult(0); }