mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 23:52:50 -05:00
PM-15084: Consistent notification center push type names.
Renamed PushType's `SyncNotification` to `Notification`, since the push type payload does not require, is not dependent on the sync mechanism.
This commit is contained in:
@ -26,6 +26,6 @@ public enum PushType : byte
|
|||||||
|
|
||||||
SyncOrganizations = 17,
|
SyncOrganizations = 17,
|
||||||
|
|
||||||
SyncNotification = 18,
|
Notification = 18,
|
||||||
SyncNotificationStatus = 19
|
NotificationStatus = 19
|
||||||
}
|
}
|
||||||
|
@ -214,17 +214,17 @@ public class NotificationHubPushNotificationService : IPushNotificationService
|
|||||||
|
|
||||||
if (notification.Global && installationId.HasValue)
|
if (notification.Global && installationId.HasValue)
|
||||||
{
|
{
|
||||||
await SendPayloadToInstallationAsync(installationId.Value, PushType.SyncNotification, message, true,
|
await SendPayloadToInstallationAsync(installationId.Value, PushType.Notification, message, true,
|
||||||
notification.ClientType);
|
notification.ClientType);
|
||||||
}
|
}
|
||||||
else if (notification.UserId.HasValue)
|
else if (notification.UserId.HasValue)
|
||||||
{
|
{
|
||||||
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotification, message, true,
|
await SendPayloadToUserAsync(notification.UserId.Value, PushType.Notification, message, true,
|
||||||
notification.ClientType);
|
notification.ClientType);
|
||||||
}
|
}
|
||||||
else if (notification.OrganizationId.HasValue)
|
else if (notification.OrganizationId.HasValue)
|
||||||
{
|
{
|
||||||
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotification, message,
|
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.Notification, message,
|
||||||
true, notification.ClientType);
|
true, notification.ClientType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,17 +254,17 @@ public class NotificationHubPushNotificationService : IPushNotificationService
|
|||||||
|
|
||||||
if (notification.Global && installationId.HasValue)
|
if (notification.Global && installationId.HasValue)
|
||||||
{
|
{
|
||||||
await SendPayloadToInstallationAsync(installationId.Value, PushType.SyncNotificationStatus, message, true,
|
await SendPayloadToInstallationAsync(installationId.Value, PushType.NotificationStatus, message, true,
|
||||||
notification.ClientType);
|
notification.ClientType);
|
||||||
}
|
}
|
||||||
else if (notification.UserId.HasValue)
|
else if (notification.UserId.HasValue)
|
||||||
{
|
{
|
||||||
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationStatus, message, true,
|
await SendPayloadToUserAsync(notification.UserId.Value, PushType.NotificationStatus, message, true,
|
||||||
notification.ClientType);
|
notification.ClientType);
|
||||||
}
|
}
|
||||||
else if (notification.OrganizationId.HasValue)
|
else if (notification.OrganizationId.HasValue)
|
||||||
{
|
{
|
||||||
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationStatus,
|
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.NotificationStatus,
|
||||||
message, true, notification.ClientType);
|
message, true, notification.ClientType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ public class AzureQueuePushNotificationService : IPushNotificationService
|
|||||||
RevisionDate = notification.RevisionDate
|
RevisionDate = notification.RevisionDate
|
||||||
};
|
};
|
||||||
|
|
||||||
await SendMessageAsync(PushType.SyncNotification, message, true);
|
await SendMessageAsync(PushType.Notification, message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PushNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus)
|
public async Task PushNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus)
|
||||||
@ -208,7 +208,7 @@ public class AzureQueuePushNotificationService : IPushNotificationService
|
|||||||
DeletedDate = notificationStatus.DeletedDate
|
DeletedDate = notificationStatus.DeletedDate
|
||||||
};
|
};
|
||||||
|
|
||||||
await SendMessageAsync(PushType.SyncNotificationStatus, message, true);
|
await SendMessageAsync(PushType.NotificationStatus, message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task PushSendAsync(Send send, PushType type)
|
private async Task PushSendAsync(Send send, PushType type)
|
||||||
|
@ -196,7 +196,7 @@ public class NotificationsApiPushNotificationService : BaseIdentityClientService
|
|||||||
RevisionDate = notification.RevisionDate
|
RevisionDate = notification.RevisionDate
|
||||||
};
|
};
|
||||||
|
|
||||||
await SendMessageAsync(PushType.SyncNotification, message, true);
|
await SendMessageAsync(PushType.Notification, message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PushNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus)
|
public async Task PushNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus)
|
||||||
@ -218,7 +218,7 @@ public class NotificationsApiPushNotificationService : BaseIdentityClientService
|
|||||||
DeletedDate = notificationStatus.DeletedDate
|
DeletedDate = notificationStatus.DeletedDate
|
||||||
};
|
};
|
||||||
|
|
||||||
await SendMessageAsync(PushType.SyncNotificationStatus, message, true);
|
await SendMessageAsync(PushType.NotificationStatus, message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task PushSendAsync(Send send, PushType type)
|
private async Task PushSendAsync(Send send, PushType type)
|
||||||
|
@ -216,17 +216,17 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti
|
|||||||
|
|
||||||
if (notification.Global)
|
if (notification.Global)
|
||||||
{
|
{
|
||||||
await SendPayloadToInstallationAsync(PushType.SyncNotification, message, true,
|
await SendPayloadToInstallationAsync(PushType.Notification, message, true,
|
||||||
notification.ClientType);
|
notification.ClientType);
|
||||||
}
|
}
|
||||||
else if (notification.UserId.HasValue)
|
else if (notification.UserId.HasValue)
|
||||||
{
|
{
|
||||||
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotification, message, true,
|
await SendPayloadToUserAsync(notification.UserId.Value, PushType.Notification, message, true,
|
||||||
notification.ClientType);
|
notification.ClientType);
|
||||||
}
|
}
|
||||||
else if (notification.OrganizationId.HasValue)
|
else if (notification.OrganizationId.HasValue)
|
||||||
{
|
{
|
||||||
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotification, message,
|
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.Notification, message,
|
||||||
true, notification.ClientType);
|
true, notification.ClientType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,17 +252,17 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti
|
|||||||
|
|
||||||
if (notification.Global)
|
if (notification.Global)
|
||||||
{
|
{
|
||||||
await SendPayloadToInstallationAsync(PushType.SyncNotificationStatus, message, true,
|
await SendPayloadToInstallationAsync(PushType.NotificationStatus, message, true,
|
||||||
notification.ClientType);
|
notification.ClientType);
|
||||||
}
|
}
|
||||||
else if (notification.UserId.HasValue)
|
else if (notification.UserId.HasValue)
|
||||||
{
|
{
|
||||||
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationStatus, message, true,
|
await SendPayloadToUserAsync(notification.UserId.Value, PushType.NotificationStatus, message, true,
|
||||||
notification.ClientType);
|
notification.ClientType);
|
||||||
}
|
}
|
||||||
else if (notification.OrganizationId.HasValue)
|
else if (notification.OrganizationId.HasValue)
|
||||||
{
|
{
|
||||||
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationStatus,
|
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.NotificationStatus,
|
||||||
message, true, notification.ClientType);
|
message, true, notification.ClientType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,36 +89,35 @@ public static class HubHelpers
|
|||||||
await hubContext.Clients.User(authRequestNotification.Payload.UserId.ToString())
|
await hubContext.Clients.User(authRequestNotification.Payload.UserId.ToString())
|
||||||
.SendAsync(_receiveMessageMethod, authRequestNotification, cancellationToken);
|
.SendAsync(_receiveMessageMethod, authRequestNotification, cancellationToken);
|
||||||
break;
|
break;
|
||||||
case PushType.SyncNotification:
|
case PushType.Notification:
|
||||||
case PushType.SyncNotificationStatus:
|
case PushType.NotificationStatus:
|
||||||
var syncNotification =
|
var notificationData = JsonSerializer.Deserialize<PushNotificationData<NotificationPushNotification>>(
|
||||||
JsonSerializer.Deserialize<PushNotificationData<NotificationPushNotification>>(
|
notificationJson, _deserializerOptions);
|
||||||
notificationJson, _deserializerOptions);
|
if (notificationData.Payload.InstallationId.HasValue)
|
||||||
if (syncNotification.Payload.InstallationId.HasValue)
|
|
||||||
{
|
{
|
||||||
await hubContext.Clients.Group(NotificationsHub.GetInstallationGroup(
|
await hubContext.Clients.Group(NotificationsHub.GetInstallationGroup(
|
||||||
syncNotification.Payload.InstallationId.Value, syncNotification.Payload.ClientType))
|
notificationData.Payload.InstallationId.Value, notificationData.Payload.ClientType))
|
||||||
.SendAsync(_receiveMessageMethod, syncNotification, cancellationToken);
|
.SendAsync(_receiveMessageMethod, notificationData, cancellationToken);
|
||||||
}
|
}
|
||||||
else if (syncNotification.Payload.UserId.HasValue)
|
else if (notificationData.Payload.UserId.HasValue)
|
||||||
{
|
{
|
||||||
if (syncNotification.Payload.ClientType == ClientType.All)
|
if (notificationData.Payload.ClientType == ClientType.All)
|
||||||
{
|
{
|
||||||
await hubContext.Clients.User(syncNotification.Payload.UserId.ToString())
|
await hubContext.Clients.User(notificationData.Payload.UserId.ToString())
|
||||||
.SendAsync(_receiveMessageMethod, syncNotification, cancellationToken);
|
.SendAsync(_receiveMessageMethod, notificationData, cancellationToken);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await hubContext.Clients.Group(NotificationsHub.GetUserGroup(
|
await hubContext.Clients.Group(NotificationsHub.GetUserGroup(
|
||||||
syncNotification.Payload.UserId.Value, syncNotification.Payload.ClientType))
|
notificationData.Payload.UserId.Value, notificationData.Payload.ClientType))
|
||||||
.SendAsync(_receiveMessageMethod, syncNotification, cancellationToken);
|
.SendAsync(_receiveMessageMethod, notificationData, cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (syncNotification.Payload.OrganizationId.HasValue)
|
else if (notificationData.Payload.OrganizationId.HasValue)
|
||||||
{
|
{
|
||||||
await hubContext.Clients.Group(NotificationsHub.GetOrganizationGroup(
|
await hubContext.Clients.Group(NotificationsHub.GetOrganizationGroup(
|
||||||
syncNotification.Payload.OrganizationId.Value, syncNotification.Payload.ClientType))
|
notificationData.Payload.OrganizationId.Value, notificationData.Payload.ClientType))
|
||||||
.SendAsync(_receiveMessageMethod, syncNotification, cancellationToken);
|
.SendAsync(_receiveMessageMethod, notificationData, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -33,7 +33,7 @@ public class PushControllerTests
|
|||||||
var exception = await Assert.ThrowsAsync<BadRequestException>(() =>
|
var exception = await Assert.ThrowsAsync<BadRequestException>(() =>
|
||||||
sutProvider.Sut.SendAsync(new PushSendRequestModel
|
sutProvider.Sut.SendAsync(new PushSendRequestModel
|
||||||
{
|
{
|
||||||
Type = PushType.SyncNotification,
|
Type = PushType.Notification,
|
||||||
UserId = userId.ToString(),
|
UserId = userId.ToString(),
|
||||||
OrganizationId = organizationId.ToString(),
|
OrganizationId = organizationId.ToString(),
|
||||||
InstallationId = installationId.ToString(),
|
InstallationId = installationId.ToString(),
|
||||||
@ -63,7 +63,7 @@ public class PushControllerTests
|
|||||||
|
|
||||||
await sutProvider.Sut.SendAsync(new PushSendRequestModel
|
await sutProvider.Sut.SendAsync(new PushSendRequestModel
|
||||||
{
|
{
|
||||||
Type = PushType.SyncNotification,
|
Type = PushType.Notification,
|
||||||
UserId = null,
|
UserId = null,
|
||||||
OrganizationId = null,
|
OrganizationId = null,
|
||||||
InstallationId = null,
|
InstallationId = null,
|
||||||
@ -96,7 +96,7 @@ public class PushControllerTests
|
|||||||
|
|
||||||
await sutProvider.Sut.SendAsync(new PushSendRequestModel
|
await sutProvider.Sut.SendAsync(new PushSendRequestModel
|
||||||
{
|
{
|
||||||
Type = PushType.SyncNotification,
|
Type = PushType.Notification,
|
||||||
UserId = userId.ToString(),
|
UserId = userId.ToString(),
|
||||||
OrganizationId = haveOrganizationId ? Guid.NewGuid().ToString() : null,
|
OrganizationId = haveOrganizationId ? Guid.NewGuid().ToString() : null,
|
||||||
InstallationId = null,
|
InstallationId = null,
|
||||||
@ -107,7 +107,7 @@ public class PushControllerTests
|
|||||||
});
|
});
|
||||||
|
|
||||||
await sutProvider.GetDependency<IPushNotificationService>().Received(1)
|
await sutProvider.GetDependency<IPushNotificationService>().Received(1)
|
||||||
.SendPayloadToUserAsync(expectedUserId, PushType.SyncNotification, "test-payload", expectedIdentifier,
|
.SendPayloadToUserAsync(expectedUserId, PushType.Notification, "test-payload", expectedIdentifier,
|
||||||
expectedDeviceId, ClientType.All);
|
expectedDeviceId, ClientType.All);
|
||||||
await sutProvider.GetDependency<IPushNotificationService>().Received(0)
|
await sutProvider.GetDependency<IPushNotificationService>().Received(0)
|
||||||
.SendPayloadToOrganizationAsync(Arg.Any<string>(), Arg.Any<PushType>(), Arg.Any<object>(),
|
.SendPayloadToOrganizationAsync(Arg.Any<string>(), Arg.Any<PushType>(), Arg.Any<object>(),
|
||||||
@ -132,7 +132,7 @@ public class PushControllerTests
|
|||||||
|
|
||||||
await sutProvider.Sut.SendAsync(new PushSendRequestModel
|
await sutProvider.Sut.SendAsync(new PushSendRequestModel
|
||||||
{
|
{
|
||||||
Type = PushType.SyncNotification,
|
Type = PushType.Notification,
|
||||||
UserId = null,
|
UserId = null,
|
||||||
OrganizationId = organizationId.ToString(),
|
OrganizationId = organizationId.ToString(),
|
||||||
InstallationId = null,
|
InstallationId = null,
|
||||||
@ -143,7 +143,7 @@ public class PushControllerTests
|
|||||||
});
|
});
|
||||||
|
|
||||||
await sutProvider.GetDependency<IPushNotificationService>().Received(1)
|
await sutProvider.GetDependency<IPushNotificationService>().Received(1)
|
||||||
.SendPayloadToOrganizationAsync(expectedOrganizationId, PushType.SyncNotification, "test-payload",
|
.SendPayloadToOrganizationAsync(expectedOrganizationId, PushType.Notification, "test-payload",
|
||||||
expectedIdentifier, expectedDeviceId, ClientType.All);
|
expectedIdentifier, expectedDeviceId, ClientType.All);
|
||||||
await sutProvider.GetDependency<IPushNotificationService>().Received(0)
|
await sutProvider.GetDependency<IPushNotificationService>().Received(0)
|
||||||
.SendPayloadToUserAsync(Arg.Any<string>(), Arg.Any<PushType>(), Arg.Any<object>(), Arg.Any<string>(),
|
.SendPayloadToUserAsync(Arg.Any<string>(), Arg.Any<PushType>(), Arg.Any<object>(), Arg.Any<string>(),
|
||||||
@ -166,7 +166,7 @@ public class PushControllerTests
|
|||||||
|
|
||||||
await sutProvider.Sut.SendAsync(new PushSendRequestModel
|
await sutProvider.Sut.SendAsync(new PushSendRequestModel
|
||||||
{
|
{
|
||||||
Type = PushType.SyncNotification,
|
Type = PushType.Notification,
|
||||||
UserId = null,
|
UserId = null,
|
||||||
OrganizationId = null,
|
OrganizationId = null,
|
||||||
InstallationId = installationId.ToString(),
|
InstallationId = installationId.ToString(),
|
||||||
@ -177,7 +177,7 @@ public class PushControllerTests
|
|||||||
});
|
});
|
||||||
|
|
||||||
await sutProvider.GetDependency<IPushNotificationService>().Received(1)
|
await sutProvider.GetDependency<IPushNotificationService>().Received(1)
|
||||||
.SendPayloadToInstallationAsync(installationId.ToString(), PushType.SyncNotification, "test-payload",
|
.SendPayloadToInstallationAsync(installationId.ToString(), PushType.Notification, "test-payload",
|
||||||
expectedIdentifier, expectedDeviceId, ClientType.All);
|
expectedIdentifier, expectedDeviceId, ClientType.All);
|
||||||
await sutProvider.GetDependency<IPushNotificationService>().Received(0)
|
await sutProvider.GetDependency<IPushNotificationService>().Received(0)
|
||||||
.SendPayloadToOrganizationAsync(Arg.Any<string>(), Arg.Any<PushType>(), Arg.Any<object>(),
|
.SendPayloadToOrganizationAsync(Arg.Any<string>(), Arg.Any<PushType>(), Arg.Any<object>(),
|
||||||
@ -198,7 +198,7 @@ public class PushControllerTests
|
|||||||
var exception = await Assert.ThrowsAsync<BadRequestException>(() =>
|
var exception = await Assert.ThrowsAsync<BadRequestException>(() =>
|
||||||
sutProvider.Sut.SendAsync(new PushSendRequestModel
|
sutProvider.Sut.SendAsync(new PushSendRequestModel
|
||||||
{
|
{
|
||||||
Type = PushType.SyncNotification,
|
Type = PushType.Notification,
|
||||||
UserId = null,
|
UserId = null,
|
||||||
OrganizationId = null,
|
OrganizationId = null,
|
||||||
InstallationId = Guid.NewGuid().ToString(),
|
InstallationId = Guid.NewGuid().ToString(),
|
||||||
|
@ -47,12 +47,12 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
{
|
{
|
||||||
sutProvider.GetDependency<IGlobalSettings>().Installation.Id = installationId;
|
sutProvider.GetDependency<IGlobalSettings>().Installation.Id = installationId;
|
||||||
notification.ClientType = ClientType.All;
|
notification.ClientType = ClientType.All;
|
||||||
var expectedSyncNotification = ToNotificationPushNotification(notification, null, installationId);
|
var expectedNotification = ToNotificationPushNotification(notification, null, installationId);
|
||||||
|
|
||||||
await sutProvider.Sut.PushNotificationAsync(notification);
|
await sutProvider.Sut.PushNotificationAsync(notification);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotification,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.Notification,
|
||||||
expectedSyncNotification,
|
expectedNotification,
|
||||||
$"(template:payload && installationId:{installationId})");
|
$"(template:payload && installationId:{installationId})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
.Received(0)
|
.Received(0)
|
||||||
@ -71,12 +71,12 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
{
|
{
|
||||||
sutProvider.GetDependency<IGlobalSettings>().Installation.Id = installationId;
|
sutProvider.GetDependency<IGlobalSettings>().Installation.Id = installationId;
|
||||||
notification.ClientType = clientType;
|
notification.ClientType = clientType;
|
||||||
var expectedSyncNotification = ToNotificationPushNotification(notification, null, installationId);
|
var expectedNotification = ToNotificationPushNotification(notification, null, installationId);
|
||||||
|
|
||||||
await sutProvider.Sut.PushNotificationAsync(notification);
|
await sutProvider.Sut.PushNotificationAsync(notification);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotification,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.Notification,
|
||||||
expectedSyncNotification,
|
expectedNotification,
|
||||||
$"(template:payload && installationId:{installationId} && clientType:{clientType})");
|
$"(template:payload && installationId:{installationId} && clientType:{clientType})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
.Received(0)
|
.Received(0)
|
||||||
@ -97,12 +97,12 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
notification.ClientType = ClientType.All;
|
notification.ClientType = ClientType.All;
|
||||||
var expectedSyncNotification = ToNotificationPushNotification(notification, null, null);
|
var expectedNotification = ToNotificationPushNotification(notification, null, null);
|
||||||
|
|
||||||
await sutProvider.Sut.PushNotificationAsync(notification);
|
await sutProvider.Sut.PushNotificationAsync(notification);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotification,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.Notification,
|
||||||
expectedSyncNotification,
|
expectedNotification,
|
||||||
$"(template:payload_userId:{notification.UserId})");
|
$"(template:payload_userId:{notification.UserId})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
.Received(0)
|
.Received(0)
|
||||||
@ -121,12 +121,12 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
{
|
{
|
||||||
notification.OrganizationId = null;
|
notification.OrganizationId = null;
|
||||||
notification.ClientType = clientType;
|
notification.ClientType = clientType;
|
||||||
var expectedSyncNotification = ToNotificationPushNotification(notification, null, null);
|
var expectedNotification = ToNotificationPushNotification(notification, null, null);
|
||||||
|
|
||||||
await sutProvider.Sut.PushNotificationAsync(notification);
|
await sutProvider.Sut.PushNotificationAsync(notification);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotification,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.Notification,
|
||||||
expectedSyncNotification,
|
expectedNotification,
|
||||||
$"(template:payload_userId:{notification.UserId} && clientType:{clientType})");
|
$"(template:payload_userId:{notification.UserId} && clientType:{clientType})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
.Received(0)
|
.Received(0)
|
||||||
@ -144,12 +144,12 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
Notification notification)
|
Notification notification)
|
||||||
{
|
{
|
||||||
notification.ClientType = clientType;
|
notification.ClientType = clientType;
|
||||||
var expectedSyncNotification = ToNotificationPushNotification(notification, null, null);
|
var expectedNotification = ToNotificationPushNotification(notification, null, null);
|
||||||
|
|
||||||
await sutProvider.Sut.PushNotificationAsync(notification);
|
await sutProvider.Sut.PushNotificationAsync(notification);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotification,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.Notification,
|
||||||
expectedSyncNotification,
|
expectedNotification,
|
||||||
$"(template:payload_userId:{notification.UserId} && clientType:{clientType})");
|
$"(template:payload_userId:{notification.UserId} && clientType:{clientType})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
.Received(0)
|
.Received(0)
|
||||||
@ -164,12 +164,12 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
{
|
{
|
||||||
notification.UserId = null;
|
notification.UserId = null;
|
||||||
notification.ClientType = ClientType.All;
|
notification.ClientType = ClientType.All;
|
||||||
var expectedSyncNotification = ToNotificationPushNotification(notification, null, null);
|
var expectedNotification = ToNotificationPushNotification(notification, null, null);
|
||||||
|
|
||||||
await sutProvider.Sut.PushNotificationAsync(notification);
|
await sutProvider.Sut.PushNotificationAsync(notification);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotification,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.Notification,
|
||||||
expectedSyncNotification,
|
expectedNotification,
|
||||||
$"(template:payload && organizationId:{notification.OrganizationId})");
|
$"(template:payload && organizationId:{notification.OrganizationId})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
.Received(0)
|
.Received(0)
|
||||||
@ -188,12 +188,12 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
{
|
{
|
||||||
notification.UserId = null;
|
notification.UserId = null;
|
||||||
notification.ClientType = clientType;
|
notification.ClientType = clientType;
|
||||||
var expectedSyncNotification = ToNotificationPushNotification(notification, null, null);
|
var expectedNotification = ToNotificationPushNotification(notification, null, null);
|
||||||
|
|
||||||
await sutProvider.Sut.PushNotificationAsync(notification);
|
await sutProvider.Sut.PushNotificationAsync(notification);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotification,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.Notification,
|
||||||
expectedSyncNotification,
|
expectedNotification,
|
||||||
$"(template:payload && organizationId:{notification.OrganizationId} && clientType:{clientType})");
|
$"(template:payload && organizationId:{notification.OrganizationId} && clientType:{clientType})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
.Received(0)
|
.Received(0)
|
||||||
@ -231,12 +231,12 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
sutProvider.GetDependency<IGlobalSettings>().Installation.Id = installationId;
|
sutProvider.GetDependency<IGlobalSettings>().Installation.Id = installationId;
|
||||||
notification.ClientType = ClientType.All;
|
notification.ClientType = ClientType.All;
|
||||||
|
|
||||||
var expectedSyncNotification = ToNotificationPushNotification(notification, notificationStatus, installationId);
|
var expectedNotification = ToNotificationPushNotification(notification, notificationStatus, installationId);
|
||||||
|
|
||||||
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationStatus,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.NotificationStatus,
|
||||||
expectedSyncNotification,
|
expectedNotification,
|
||||||
$"(template:payload && installationId:{installationId})");
|
$"(template:payload && installationId:{installationId})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
.Received(0)
|
.Received(0)
|
||||||
@ -257,12 +257,12 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
sutProvider.GetDependency<IGlobalSettings>().Installation.Id = installationId;
|
sutProvider.GetDependency<IGlobalSettings>().Installation.Id = installationId;
|
||||||
notification.ClientType = clientType;
|
notification.ClientType = clientType;
|
||||||
|
|
||||||
var expectedSyncNotification = ToNotificationPushNotification(notification, notificationStatus, installationId);
|
var expectedNotification = ToNotificationPushNotification(notification, notificationStatus, installationId);
|
||||||
|
|
||||||
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationStatus,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.NotificationStatus,
|
||||||
expectedSyncNotification,
|
expectedNotification,
|
||||||
$"(template:payload && installationId:{installationId} && clientType:{clientType})");
|
$"(template:payload && installationId:{installationId} && clientType:{clientType})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
.Received(0)
|
.Received(0)
|
||||||
@ -283,12 +283,12 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
notification.ClientType = ClientType.All;
|
notification.ClientType = ClientType.All;
|
||||||
var expectedSyncNotification = ToNotificationPushNotification(notification, notificationStatus, null);
|
var expectedNotification = ToNotificationPushNotification(notification, notificationStatus, null);
|
||||||
|
|
||||||
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationStatus,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.NotificationStatus,
|
||||||
expectedSyncNotification,
|
expectedNotification,
|
||||||
$"(template:payload_userId:{notification.UserId})");
|
$"(template:payload_userId:{notification.UserId})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
.Received(0)
|
.Received(0)
|
||||||
@ -311,7 +311,7 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
|
|
||||||
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationStatus,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.NotificationStatus,
|
||||||
expectedNotification,
|
expectedNotification,
|
||||||
$"(template:payload_userId:{notification.UserId} && clientType:{clientType})");
|
$"(template:payload_userId:{notification.UserId} && clientType:{clientType})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
@ -334,7 +334,7 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
|
|
||||||
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationStatus,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.NotificationStatus,
|
||||||
expectedNotification,
|
expectedNotification,
|
||||||
$"(template:payload_userId:{notification.UserId} && clientType:{clientType})");
|
$"(template:payload_userId:{notification.UserId} && clientType:{clientType})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
@ -355,7 +355,7 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
|
|
||||||
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationStatus,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.NotificationStatus,
|
||||||
expectedNotification,
|
expectedNotification,
|
||||||
$"(template:payload && organizationId:{notification.OrganizationId})");
|
$"(template:payload && organizationId:{notification.OrganizationId})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
@ -380,7 +380,7 @@ public class NotificationHubPushNotificationServiceTests
|
|||||||
|
|
||||||
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
await sutProvider.Sut.PushNotificationStatusAsync(notification, notificationStatus);
|
||||||
|
|
||||||
await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationStatus,
|
await AssertSendTemplateNotificationAsync(sutProvider, PushType.NotificationStatus,
|
||||||
expectedNotification,
|
expectedNotification,
|
||||||
$"(template:payload && organizationId:{notification.OrganizationId} && clientType:{clientType})");
|
$"(template:payload && organizationId:{notification.OrganizationId} && clientType:{clientType})");
|
||||||
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
await sutProvider.GetDependency<IInstallationDeviceRepository>()
|
||||||
|
@ -39,7 +39,7 @@ public class AzureQueuePushNotificationServiceTests
|
|||||||
|
|
||||||
await sutProvider.GetDependency<QueueClient>().Received(1)
|
await sutProvider.GetDependency<QueueClient>().Received(1)
|
||||||
.SendMessageAsync(Arg.Is<string>(message =>
|
.SendMessageAsync(Arg.Is<string>(message =>
|
||||||
MatchMessage(PushType.SyncNotification, message,
|
MatchMessage(PushType.Notification, message,
|
||||||
new NotificationPushNotificationEquals(notification, null, installationId),
|
new NotificationPushNotificationEquals(notification, null, installationId),
|
||||||
deviceIdentifier.ToString())));
|
deviceIdentifier.ToString())));
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ public class AzureQueuePushNotificationServiceTests
|
|||||||
|
|
||||||
await sutProvider.GetDependency<QueueClient>().Received(1)
|
await sutProvider.GetDependency<QueueClient>().Received(1)
|
||||||
.SendMessageAsync(Arg.Is<string>(message =>
|
.SendMessageAsync(Arg.Is<string>(message =>
|
||||||
MatchMessage(PushType.SyncNotification, message,
|
MatchMessage(PushType.Notification, message,
|
||||||
new NotificationPushNotificationEquals(notification, null, null),
|
new NotificationPushNotificationEquals(notification, null, null),
|
||||||
deviceIdentifier.ToString())));
|
deviceIdentifier.ToString())));
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ public class AzureQueuePushNotificationServiceTests
|
|||||||
|
|
||||||
await sutProvider.GetDependency<QueueClient>().Received(1)
|
await sutProvider.GetDependency<QueueClient>().Received(1)
|
||||||
.SendMessageAsync(Arg.Is<string>(message =>
|
.SendMessageAsync(Arg.Is<string>(message =>
|
||||||
MatchMessage(PushType.SyncNotificationStatus, message,
|
MatchMessage(PushType.NotificationStatus, message,
|
||||||
new NotificationPushNotificationEquals(notification, notificationStatus, installationId),
|
new NotificationPushNotificationEquals(notification, notificationStatus, installationId),
|
||||||
deviceIdentifier.ToString())));
|
deviceIdentifier.ToString())));
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ public class AzureQueuePushNotificationServiceTests
|
|||||||
|
|
||||||
await sutProvider.GetDependency<QueueClient>().Received(1)
|
await sutProvider.GetDependency<QueueClient>().Received(1)
|
||||||
.SendMessageAsync(Arg.Is<string>(message =>
|
.SendMessageAsync(Arg.Is<string>(message =>
|
||||||
MatchMessage(PushType.SyncNotificationStatus, message,
|
MatchMessage(PushType.NotificationStatus, message,
|
||||||
new NotificationPushNotificationEquals(notification, notificationStatus, null),
|
new NotificationPushNotificationEquals(notification, notificationStatus, null),
|
||||||
deviceIdentifier.ToString())));
|
deviceIdentifier.ToString())));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user