|
1 | | -using System.Threading.Tasks; |
2 | | -using Microsoft.AspNetCore.Authorization; |
3 | | -using Microsoft.AspNetCore.SignalR; |
4 | | -using SIL.XForge.Scripture.Models; |
| 1 | +using SIL.XForge.Realtime; |
5 | 2 |
|
6 | 3 | namespace SIL.XForge.Scripture.Services; |
7 | 4 |
|
8 | | -[Authorize] |
9 | | -public class NotificationHub : Hub<INotifier>, INotifier |
10 | | -{ |
11 | | - /// <summary> |
12 | | - /// Notifies subscribers to a project of draft build progress. |
13 | | - /// </summary> |
14 | | - /// <param name="projectId">The Scripture Forge project identifier.</param> |
15 | | - /// <param name="buildState">The build state from Serval.</param> |
16 | | - /// <returns>The asynchronous task.</returns> |
17 | | - /// <remarks> |
18 | | - /// This will currently be emitted on the TranslationBuildStarted and TranslationBuildFinished webhooks, |
19 | | - /// and when the draft pre-translations have been retrieved. |
20 | | - /// </remarks> |
21 | | - public async Task NotifyBuildProgress(string projectId, ServalBuildState buildState) => |
22 | | - await Clients.Group(projectId).NotifyBuildProgress(projectId, buildState); |
23 | | - |
24 | | - /// <summary> |
25 | | - /// Notifies subscribers to a project of draft application progress. |
26 | | - /// </summary> |
27 | | - /// <param name="projectId">The Scripture Forge project identifier.</param> |
28 | | - /// <param name="draftApplyState">The state of the draft being applied.</param> |
29 | | - /// <returns>The asynchronous task.</returns> |
30 | | - /// <remarks> |
31 | | - /// This differs from the implementation in <see cref="DraftNotificationHub"/> in that this version |
32 | | - /// does not have stateful reconnection, and so there is no guarantee that the message is received. |
33 | | - /// </remarks> |
34 | | - public async Task NotifyDraftApplyProgress(string projectId, DraftApplyState draftApplyState) => |
35 | | - await Clients.Group(projectId).NotifyDraftApplyProgress(projectId, draftApplyState); |
36 | | - |
37 | | - /// <summary> |
38 | | - /// Notifies subscribers to a project of sync progress. |
39 | | - /// </summary> |
40 | | - /// <param name="projectId">The Scripture Forge project identifier.</param> |
41 | | - /// <param name="progressState"> |
42 | | - /// The progress state, including a string value (Paratext only - not used in SF), or percentage value. |
43 | | - /// </param> |
44 | | - /// <returns>The asynchronous task.</returns> |
45 | | - public async Task NotifySyncProgress(string projectId, ProgressState progressState) => |
46 | | - await Clients.Group(projectId).NotifySyncProgress(projectId, progressState); |
47 | | - |
48 | | - /// <summary> |
49 | | - /// Subscribe to notifications for a project. |
50 | | - /// |
51 | | - /// This is called from the frontend via <c>project-notification.service.ts</c>. |
52 | | - /// </summary> |
53 | | - /// <param name="projectId">The Scripture Forge project identifier.</param> |
54 | | - /// <returns>The asynchronous task.</returns> |
55 | | - public async Task SubscribeToProject(string projectId) => |
56 | | - await Groups.AddToGroupAsync(Context.ConnectionId, projectId); |
57 | | -} |
| 5 | +/// <summary> |
| 6 | +/// The SignalR notification hub for sync and draft notifications. |
| 7 | +/// </summary> |
| 8 | +/// <param name="realtimeService">The realtime service.</param> |
| 9 | +public class NotificationHub(IRealtimeService realtimeService) : NotificationHubBase<INotifier>(realtimeService) { } |
0 commit comments