Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-13764] Send Notification When Updating Collection Management Settings #5230

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,11 @@
Description = organization.DisplayBusinessName()
});
}

if (eventType == EventType.Organization_CollectionManagement_Updated)
{
await _pushNotificationService.PushSyncOrganizationCollectionManagementSettingsAsync(organization);
}

Check warning on line 809 in src/Core/AdminConsole/Services/Implementations/OrganizationService.cs

View check run for this annotation

Codecov / codecov/patch

src/Core/AdminConsole/Services/Implementations/OrganizationService.cs#L807-L809

Added lines #L807 - L809 were not covered by tests
}

public async Task UpdateTwoFactorProviderAsync(Organization organization, TwoFactorProviderType type)
Expand Down
1 change: 1 addition & 0 deletions src/Core/Enums/PushType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ public enum PushType : byte

SyncOrganizations = 17,
SyncOrganizationStatusChanged = 18,
SyncOrganizationCollectionSettingChanged = 19,
}
7 changes: 7 additions & 0 deletions src/Core/Models/PushNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,10 @@
public Guid OrganizationId { get; set; }
public bool Enabled { get; set; }
}

public class OrganizationCollectionManagementPushNotification
{
public Guid OrganizationId { get; init; }
public bool LimitCollectionCreation { get; init; }
public bool LimitCollectionDeletion { get; init; }

Check warning on line 64 in src/Core/Models/PushNotification.cs

View check run for this annotation

Codecov / codecov/patch

src/Core/Models/PushNotification.cs#L62-L64

Added lines #L62 - L64 were not covered by tests
}
13 changes: 13 additions & 0 deletions src/Core/NotificationHub/NotificationHubPushNotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@
await SendPayloadToOrganizationAsync(organization.Id, PushType.SyncOrganizationStatusChanged, message, false);
}

public async Task PushSyncOrganizationCollectionManagementSettingsAsync(Organization organization) =>
await SendPayloadToOrganizationAsync(
organization.Id,
PushType.SyncOrganizationCollectionSettingChanged,
new OrganizationCollectionManagementPushNotification
{
OrganizationId = organization.Id,
LimitCollectionCreation = organization.LimitCollectionCreation,
LimitCollectionDeletion = organization.LimitCollectionDeletion
},
false
);

Check warning on line 252 in src/Core/NotificationHub/NotificationHubPushNotificationService.cs

View check run for this annotation

Codecov / codecov/patch

src/Core/NotificationHub/NotificationHubPushNotificationService.cs#L242-L252

Added lines #L242 - L252 were not covered by tests

private string GetContextIdentifier(bool excludeCurrentContext)
{
if (!excludeCurrentContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,12 @@
await SendMessageAsync(PushType.SyncOrganizationStatusChanged, message, false);
}

public async Task PushSyncOrganizationCollectionManagementSettingsAsync(Organization organization) =>
await SendMessageAsync(PushType.SyncOrganizationCollectionSettingChanged,
new OrganizationCollectionManagementPushNotification
{
OrganizationId = organization.Id,
LimitCollectionCreation = organization.LimitCollectionCreation,
LimitCollectionDeletion = organization.LimitCollectionDeletion
}, false);

Check warning on line 243 in src/Core/Platform/Push/Services/AzureQueuePushNotificationService.cs

View check run for this annotation

Codecov / codecov/patch

src/Core/Platform/Push/Services/AzureQueuePushNotificationService.cs#L237-L243

Added lines #L237 - L243 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ public interface IPushNotificationService
Task SendPayloadToOrganizationAsync(string orgId, PushType type, object payload, string identifier,
string deviceId = null);
Task PushSyncOrganizationStatusAsync(Organization organization);
Task PushSyncOrganizationCollectionManagementSettingsAsync(Organization organization);
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@
return Task.FromResult(0);
}

public Task PushSyncOrganizationCollectionManagementSettingsAsync(Organization organization)
{
PushToServices(s => s.PushSyncOrganizationCollectionManagementSettingsAsync(organization));
return Task.CompletedTask;
}

Check warning on line 158 in src/Core/Platform/Push/Services/MultiServicePushNotificationService.cs

View check run for this annotation

Codecov / codecov/patch

src/Core/Platform/Push/Services/MultiServicePushNotificationService.cs#L155-L158

Added lines #L155 - L158 were not covered by tests

private void PushToServices(Func<IPushNotificationService, Task> pushFunc)
{
if (_services != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
return Task.FromResult(0);
}

public Task PushSyncOrganizationCollectionManagementSettingsAsync(Organization organization) => Task.CompletedTask;

Check warning on line 97 in src/Core/Platform/Push/Services/NoopPushNotificationService.cs

View check run for this annotation

Codecov / codecov/patch

src/Core/Platform/Push/Services/NoopPushNotificationService.cs#L97

Added line #L97 was not covered by tests

public Task PushAuthRequestAsync(AuthRequest authRequest)
{
return Task.FromResult(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,13 @@

await SendMessageAsync(PushType.SyncOrganizationStatusChanged, message, false);
}

public async Task PushSyncOrganizationCollectionManagementSettingsAsync(Organization organization) =>
await SendMessageAsync(PushType.SyncOrganizationCollectionSettingChanged,
new OrganizationCollectionManagementPushNotification
{
OrganizationId = organization.Id,
LimitCollectionCreation = organization.LimitCollectionCreation,
LimitCollectionDeletion = organization.LimitCollectionDeletion
}, false);

Check warning on line 252 in src/Core/Platform/Push/Services/NotificationsApiPushNotificationService.cs

View check run for this annotation

Codecov / codecov/patch

src/Core/Platform/Push/Services/NotificationsApiPushNotificationService.cs#L246-L252

Added lines #L246 - L252 were not covered by tests
}
13 changes: 13 additions & 0 deletions src/Core/Platform/Push/Services/RelayPushNotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,17 @@

await SendPayloadToOrganizationAsync(organization.Id, PushType.SyncOrganizationStatusChanged, message, false);
}

public async Task PushSyncOrganizationCollectionManagementSettingsAsync(Organization organization) =>
await SendPayloadToOrganizationAsync(
organization.Id,
PushType.SyncOrganizationCollectionSettingChanged,
new OrganizationCollectionManagementPushNotification
{
OrganizationId = organization.Id,
LimitCollectionCreation = organization.LimitCollectionCreation,
LimitCollectionDeletion = organization.LimitCollectionDeletion
},
false
);

Check warning on line 279 in src/Core/Platform/Push/Services/RelayPushNotificationService.cs

View check run for this annotation

Codecov / codecov/patch

src/Core/Platform/Push/Services/RelayPushNotificationService.cs#L269-L279

Added lines #L269 - L279 were not covered by tests
}
7 changes: 7 additions & 0 deletions src/Notifications/HubHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@
await hubContext.Clients.Group($"Organization_{orgStatusNotification.Payload.OrganizationId}")
.SendAsync("ReceiveMessage", orgStatusNotification, cancellationToken);
break;
case PushType.SyncOrganizationCollectionSettingChanged:
var organizationCollectionSettingsChangedNotification =
JsonSerializer.Deserialize<PushNotificationData<OrganizationStatusPushNotification>>(
notificationJson, _deserializerOptions);
await hubContext.Clients.Group($"Organization_{organizationCollectionSettingsChangedNotification.Payload.OrganizationId}")
.SendAsync("ReceiveMessage", organizationCollectionSettingsChangedNotification, cancellationToken);
break;

Check warning on line 101 in src/Notifications/HubHelpers.cs

View check run for this annotation

Codecov / codecov/patch

src/Notifications/HubHelpers.cs#L96-L101

Added lines #L96 - L101 were not covered by tests
default:
break;
}
Expand Down
Loading