mirror of
https://github.com/bitwarden/server.git
synced 2025-07-19 00:21:35 -05:00
Refactor PendingSecurityTasks
to RefreshSecurityTasks
(#5903)
- Allows for more general use case of security task notifications
This commit is contained in:
@ -31,5 +31,5 @@ public enum PushType : byte
|
||||
Notification = 20,
|
||||
NotificationStatus = 21,
|
||||
|
||||
PendingSecurityTasks = 22
|
||||
RefreshSecurityTasks = 22
|
||||
}
|
||||
|
@ -389,10 +389,10 @@ public interface IPushNotificationService
|
||||
ExcludeCurrentContext = false,
|
||||
});
|
||||
|
||||
Task PushPendingSecurityTasksAsync(Guid userId)
|
||||
Task PushRefreshSecurityTasksAsync(Guid userId)
|
||||
=> PushAsync(new PushNotification<UserPushNotification>
|
||||
{
|
||||
Type = PushType.PendingSecurityTasks,
|
||||
Type = PushType.RefreshSecurityTasks,
|
||||
Target = NotificationTarget.User,
|
||||
TargetId = userId,
|
||||
Payload = new UserPushNotification
|
||||
|
@ -89,7 +89,7 @@ public class CreateManyTaskNotificationsCommand : ICreateManyTaskNotificationsCo
|
||||
}
|
||||
|
||||
// Notify the user that they have pending security tasks
|
||||
await _pushNotificationService.PushPendingSecurityTasksAsync(userId);
|
||||
await _pushNotificationService.PushRefreshSecurityTasksAsync(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class MarkNotificationsForTaskAsDeletedCommand : IMarkNotificationsForTas
|
||||
var uniqueUserIds = userIds.Distinct();
|
||||
foreach (var id in uniqueUserIds)
|
||||
{
|
||||
await _pushNotificationService.PushPendingSecurityTasksAsync(id);
|
||||
await _pushNotificationService.PushRefreshSecurityTasksAsync(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public static class HubHelpers
|
||||
}
|
||||
|
||||
break;
|
||||
case PushType.PendingSecurityTasks:
|
||||
case PushType.RefreshSecurityTasks:
|
||||
var pendingTasksData = JsonSerializer.Deserialize<PushNotificationData<UserPushNotification>>(notificationJson, _deserializerOptions);
|
||||
await hubContext.Clients.User(pendingTasksData.Payload.UserId.ToString())
|
||||
.SendAsync(_receiveMessageMethod, pendingTasksData, cancellationToken);
|
||||
|
@ -166,7 +166,7 @@ public class PushControllerTests
|
||||
yield return UserTyped(PushType.SyncOrgKeys);
|
||||
yield return UserTyped(PushType.SyncSettings);
|
||||
yield return UserTyped(PushType.LogOut);
|
||||
yield return UserTyped(PushType.PendingSecurityTasks);
|
||||
yield return UserTyped(PushType.RefreshSecurityTasks);
|
||||
|
||||
yield return Typed(new PushSendRequestModel<AuthRequestPushNotification>
|
||||
{
|
||||
|
@ -707,7 +707,7 @@ public class AzureQueuePushNotificationServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PushPendingSecurityTasksAsync_SendsExpectedResponse()
|
||||
public async Task PushRefreshSecurityTasksAsync_SendsExpectedResponse()
|
||||
{
|
||||
var userId = Guid.NewGuid();
|
||||
|
||||
@ -722,7 +722,7 @@ public class AzureQueuePushNotificationServiceTests
|
||||
};
|
||||
|
||||
await VerifyNotificationAsync(
|
||||
async sut => await sut.PushPendingSecurityTasksAsync(userId),
|
||||
async sut => await sut.PushRefreshSecurityTasksAsync(userId),
|
||||
expectedPayload
|
||||
);
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ public class NotificationsApiPushNotificationServiceTests : PushTestBase
|
||||
};
|
||||
}
|
||||
|
||||
protected override JsonNode GetPushPendingSecurityTasksResponsePayload(Guid userId)
|
||||
protected override JsonNode GetPushRefreshSecurityTasksResponsePayload(Guid userId)
|
||||
{
|
||||
return new JsonObject
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ public abstract class PushTestBase
|
||||
protected abstract JsonNode GetPushNotificationStatusResponsePayload(Notification notification, NotificationStatus notificationStatus, Guid? userId, Guid? organizationId);
|
||||
protected abstract JsonNode GetPushSyncOrganizationStatusResponsePayload(Organization organization);
|
||||
protected abstract JsonNode GetPushSyncOrganizationCollectionManagementSettingsResponsePayload(Organization organization);
|
||||
protected abstract JsonNode GetPushPendingSecurityTasksResponsePayload(Guid userId);
|
||||
protected abstract JsonNode GetPushRefreshSecurityTasksResponsePayload(Guid userId);
|
||||
|
||||
[Fact]
|
||||
public async Task PushSyncCipherCreateAsync_SendsExpectedResponse()
|
||||
@ -444,13 +444,13 @@ public abstract class PushTestBase
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PushPendingSecurityTasksAsync_SendsExpectedResponse()
|
||||
public async Task PushRefreshSecurityTasksAsync_SendsExpectedResponse()
|
||||
{
|
||||
var userId = Guid.NewGuid();
|
||||
|
||||
await VerifyNotificationAsync(
|
||||
async sut => await sut.PushPendingSecurityTasksAsync(userId),
|
||||
GetPushPendingSecurityTasksResponsePayload(userId)
|
||||
async sut => await sut.PushRefreshSecurityTasksAsync(userId),
|
||||
GetPushRefreshSecurityTasksResponsePayload(userId)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,7 @@ public class RelayPushNotificationServiceTests : PushTestBase
|
||||
};
|
||||
}
|
||||
|
||||
protected override JsonNode GetPushPendingSecurityTasksResponsePayload(Guid userId)
|
||||
protected override JsonNode GetPushRefreshSecurityTasksResponsePayload(Guid userId)
|
||||
{
|
||||
return new JsonObject
|
||||
{
|
||||
|
Reference in New Issue
Block a user