Class ChatNotificationService

java.lang.Object
io.meeds.chat.service.ChatNotificationService

@Service public class ChatNotificationService extends Object
This service creates and manages all different notifications related to the chat application
  • Field Details

    • IN_KEY

      public static String IN_KEY
    • USER_CHAT_NOTIFICATION_SCOPE

      public static final org.exoplatform.commons.api.settings.data.Scope USER_CHAT_NOTIFICATION_SCOPE
    • MUTED_ROOMS

      public static final String MUTED_ROOMS
      See Also:
    • DEFAULT_UNREAD_DELAY_SECONDS

      public static final long DEFAULT_UNREAD_DELAY_SECONDS
      Default delay a message must stay unread before a device pops it, applied when the device defines no delay of its own.
      See Also:
    • CHAT_NOTIFICATION_KIND

      public static final String CHAT_NOTIFICATION_KIND
      See Also:
    • SENDS_YOU_A_CHAT_KEY

      public static final String SENDS_YOU_A_CHAT_KEY
      See Also:
    • MORE_MESSAGES_KEY

      public static final String MORE_MESSAGES_KEY
      See Also:
    • MARK_READ_ACTION

      public static final String MARK_READ_ACTION
      See Also:
    • MARK_READ_LABEL_KEY

      public static final String MARK_READ_LABEL_KEY
      See Also:
    • OPEN_ROOM_CLIENT_ACTION

      public static final String OPEN_ROOM_CLIENT_ACTION
      In-page action of a room popup click (DOM event name the chat quick-actions bundle listens to, see Constants.js ACTION_OPEN_CHAT_ROOM_FROM_PUSH)
      See Also:
    • READ_WATERMARK_KEY_PREFIX

      public static final String READ_WATERMARK_KEY_PREFIX
      See Also:
  • Constructor Details

    • ChatNotificationService

      public ChatNotificationService()
  • Method Details

    • onMatrixPushReceived

      public void onMatrixPushReceived(String eventId, String roomId, String userName, String pushKey)
      Single entry point of the Synapse push-gateway callback for one recipient: resolves the event once server-side, then dispatches — a mention additionally produces the standard on-site/mail notification (its push is opted out), and every message schedules a deferred self-contained popup per subscribed device, cancelled at fire time if read meanwhile. One popup per chatroom: it shows the latest unread message and how many more are unread, replacing the room's previous popup on the device.
      Parameters:
      eventId - the Matrix event ID
      roomId - the Matrix room ID
      userName - the recipient platform username
      pushKey - the recipient device pushkey (JWT), used to resolve private room events
    • markRoomAsRead

      public void markRoomAsRead(String userName, String roomId, String eventId, Long readTimestamp) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Marks a room as read for a user up to an event — the server-side read anchor: (1) the m.read receipt is posted with the user's own Matrix identity so every client converges through sync, (2) the read watermark is recorded durably, (3) the pending popups covered by it are discarded. Idempotent; the watermark only moves forward.
      Parameters:
      userName - the platform user
      roomId - the Matrix room id
      eventId - the event read up to (high-water mark)
      readTimestamp - the timestamp of that event when known, else now
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the room is unknown
      IllegalAccessException - when the user is not a member of the room
    • clearPendingMessages

      public void clearPendingMessages(String userName, String roomId, long upToTimestamp)
      Discards the pending popups of a room up to a timestamp: their deferred sends are cancelled at fire time. Called when the room is read up to that point (read-anchor story).
      Parameters:
      userName - the recipient platform username
      roomId - the Matrix room ID
      upToTimestamp - read watermark (inclusive)
    • isPrivateRoomMutedForUser

      public boolean isPrivateRoomMutedForUser(String userName, String roomId)
    • toggleMutePrivateRoom

      public void toggleMutePrivateRoom(String userName, String roomId)