Class DbNotificationPreferenceFilter<T extends NotificationPreferenceBase>

java.lang.Object
io.leandev.appfuse.notification.preference.DbNotificationPreferenceFilter<T>
Type Parameters:
T - 應用宣告的具體偏好 entity(繼承 NotificationPreferenceBase
All Implemented Interfaces:
NotificationPreferenceFilter

public class DbNotificationPreferenceFilter<T extends NotificationPreferenceBase> extends Object implements NotificationPreferenceFilter

DB-backed 通知偏好過濾(Phase 2 預設,opt-out 模型)

NotificationPreferenceBase 的具體實作:有列用其 enabled,無列視為啟用(opt-out)。收件人無 userId 時無從查、一律啟用。

ADR-017:泛型化於 NotificationPreferenceBase,依賴 NotificationPreferenceRepositoryBase。查詢不帶 tenantId—— 租戶範圍由應用 entity 的 @TenantId filter 於 Session 建構時自動限縮(決策三)。isEnabledtenantId 參數保留於 SPI 相容,不參與查詢。

Since:
4.0.0
  • Constructor Details

    • DbNotificationPreferenceFilter

      public DbNotificationPreferenceFilter(NotificationPreferenceRepositoryBase<T> repository)
      Parameters:
      repository - 偏好 repository(應用宣告的具體型別)
  • Method Details

    • isEnabled

      public boolean isEnabled(String type, Recipient recipient, ChannelType channel, String tenantId)
      Description copied from interface: NotificationPreferenceFilter
      此收件人是否願意以此通道收到此型別的通知
      Specified by:
      isEnabled in interface NotificationPreferenceFilter
      Parameters:
      type - 通知型別鍵
      recipient - 收件人(userId 為 null 時通常無從查偏好,實作宜回 true)
      channel - 通道
      tenantId - 所屬租戶(可為 null)
      Returns:
      true = 送;false = 略過此收件人×通道