1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-02 23:41:21 +01:00

send collection ids with cipher notification

This commit is contained in:
Kyle Spearrin 2018-08-21 09:29:38 -04:00
parent ad5b71643a
commit 1b489daca1
9 changed files with 49 additions and 40 deletions

View File

@ -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<Guid> CollectionIds { get; set; }
public DateTime RevisionDate { get; set; }
}

View File

@ -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<Guid> collectionIds);
Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable<Guid> collectionIds);
Task PushSyncCipherDeleteAsync(Cipher cipher);
Task PushSyncFolderCreateAsync(Folder folder);
Task PushSyncFolderUpdateAsync(Folder folder);

View File

@ -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<Guid> 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<Guid> 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<Guid> 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);

View File

@ -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<Guid> 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<Cipher> 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(

View File

@ -47,15 +47,15 @@ namespace Bit.Core.Services
}
}
public Task PushSyncCipherCreateAsync(Cipher cipher)
public Task PushSyncCipherCreateAsync(Cipher cipher, IEnumerable<Guid> 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<Guid> collectionIds)
{
PushToServices((s) => s.PushSyncCipherUpdateAsync(cipher));
PushToServices((s) => s.PushSyncCipherUpdateAsync(cipher, collectionIds));
return Task.FromResult(0);
}

View File

@ -26,22 +26,22 @@ namespace Bit.Core.Services
_httpContextAccessor = httpContextAccessor;
}
public async Task PushSyncCipherCreateAsync(Cipher cipher)
public async Task PushSyncCipherCreateAsync(Cipher cipher, IEnumerable<Guid> 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<Guid> 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<Guid> collectionIds)
{
if(cipher.OrganizationId.HasValue)
{

View File

@ -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<Guid> 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<Guid> 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<Guid> 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);

View File

@ -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<Guid> 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<Guid> 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<Guid> collectionIds)
{
if(cipher.OrganizationId.HasValue)
{

View File

@ -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<Guid> 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<Guid> collectionIds)
{
return Task.FromResult(0);
}