INotificationStore.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. namespace Abp.Notifications
  5. {
  6. /// <summary>
  7. /// Used to store (persist) notifications.
  8. /// </summary>
  9. public interface INotificationStore
  10. {
  11. /// <summary>
  12. /// Inserts a notification subscription.
  13. /// </summary>
  14. Task InsertSubscriptionAsync(NotificationSubscriptionInfo subscription);
  15. /// <summary>
  16. /// Deletes a notification subscription.
  17. /// </summary>
  18. Task DeleteSubscriptionAsync(UserIdentifier user, string notificationName, string entityTypeName, string entityId);
  19. /// <summary>
  20. /// Inserts a notification.
  21. /// </summary>
  22. Task InsertNotificationAsync(NotificationInfo notification);
  23. /// <summary>
  24. /// Gets a notification by Id, or returns null if not found.
  25. /// </summary>
  26. Task<NotificationInfo> GetNotificationOrNullAsync(Guid notificationId);
  27. /// <summary>
  28. /// Inserts a user notification.
  29. /// </summary>
  30. Task InsertUserNotificationAsync(UserNotificationInfo userNotification);
  31. /// <summary>
  32. /// Gets subscriptions for a notification.
  33. /// </summary>
  34. Task<List<NotificationSubscriptionInfo>> GetSubscriptionsAsync(string notificationName, string entityTypeName, string entityId);
  35. /// <summary>
  36. /// Gets subscriptions for a notification for specified tenant(s).
  37. /// </summary>
  38. Task<List<NotificationSubscriptionInfo>> GetSubscriptionsAsync(int?[] tenantIds, string notificationName, string entityTypeName, string entityId);
  39. /// <summary>
  40. /// Gets subscriptions for a user.
  41. /// </summary>
  42. Task<List<NotificationSubscriptionInfo>> GetSubscriptionsAsync(UserIdentifier user);
  43. /// <summary>
  44. /// Checks if a user subscribed for a notification
  45. /// </summary>
  46. Task<bool> IsSubscribedAsync(UserIdentifier user, string notificationName, string entityTypeName, string entityId);
  47. /// <summary>
  48. /// Updates a user notification state.
  49. /// </summary>
  50. Task UpdateUserNotificationStateAsync(int? tenantId, Guid userNotificationId, UserNotificationState state);
  51. /// <summary>
  52. /// Updates all notification states for a user.
  53. /// </summary>
  54. Task UpdateAllUserNotificationStatesAsync(UserIdentifier user, UserNotificationState state);
  55. /// <summary>
  56. /// Deletes a user notification.
  57. /// </summary>
  58. Task DeleteUserNotificationAsync(int? tenantId, Guid userNotificationId);
  59. /// <summary>
  60. /// Deletes all notifications of a user.
  61. /// </summary>
  62. Task DeleteAllUserNotificationsAsync(UserIdentifier user);
  63. /// <summary>
  64. /// Gets notifications of a user.
  65. /// </summary>
  66. /// <param name="user">User.</param>
  67. /// <param name="skipCount">Skip count.</param>
  68. /// <param name="maxResultCount">Maximum result count.</param>
  69. /// <param name="state">State</param>
  70. Task<List<UserNotificationInfoWithNotificationInfo>> GetUserNotificationsWithNotificationsAsync(UserIdentifier user, UserNotificationState? state = null, int skipCount = 0, int maxResultCount = int.MaxValue);
  71. /// <summary>
  72. /// Gets user notification count.
  73. /// </summary>
  74. /// <param name="user">User.</param>
  75. /// <param name="state">The state.</param>
  76. Task<int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState? state = null);
  77. /// <summary>
  78. /// Gets a user notification.
  79. /// </summary>
  80. /// <param name="tenantId">Tenant Id</param>
  81. /// <param name="userNotificationId">Skip count.</param>
  82. Task<UserNotificationInfoWithNotificationInfo> GetUserNotificationWithNotificationOrNullAsync(int? tenantId, Guid userNotificationId);
  83. /// <summary>
  84. /// Inserts notification for a tenant.
  85. /// </summary>
  86. Task InsertTenantNotificationAsync(TenantNotificationInfo tenantNotificationInfo);
  87. /// <summary>
  88. /// Deletes the notification.
  89. /// </summary>
  90. /// <param name="notification">The notification.</param>
  91. Task DeleteNotificationAsync(NotificationInfo notification);
  92. }
  93. }