Package io.meeds.chat.service
Class ChatNotificationService
java.lang.Object
io.meeds.chat.service.ChatNotificationService
This service creates and manages all different notifications related to the
chat application
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final longDefault delay a message must stay unread before a device pops it, applied when the device defines no delay of its own.static Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringIn-page action of a room popup click (DOM event name the chat quick-actions bundle listens to, seeConstants.js ACTION_OPEN_CHAT_ROOM_FROM_PUSH)static final Stringstatic final Stringstatic final org.exoplatform.commons.api.settings.data.Scope -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearPendingMessages(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.booleanisPrivateRoomMutedForUser(String userName, String roomId) voidmarkRoomAsRead(String userName, String roomId, String eventId, Long readTimestamp) Marks a room as read for a user up to an event — the server-side read anchor: (1) them.readreceipt 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.voidonMatrixPushReceived(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.voidtoggleMutePrivateRoom(String userName, String roomId)
-
Field Details
-
IN_KEY
-
USER_CHAT_NOTIFICATION_SCOPE
public static final org.exoplatform.commons.api.settings.data.Scope USER_CHAT_NOTIFICATION_SCOPE -
MUTED_ROOMS
- See Also:
-
DEFAULT_UNREAD_DELAY_SECONDS
public static final long DEFAULT_UNREAD_DELAY_SECONDSDefault 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
- See Also:
-
SENDS_YOU_A_CHAT_KEY
- See Also:
-
MORE_MESSAGES_KEY
- See Also:
-
MARK_READ_ACTION
- See Also:
-
MARK_READ_LABEL_KEY
- See Also:
-
OPEN_ROOM_CLIENT_ACTION
In-page action of a room popup click (DOM event name the chat quick-actions bundle listens to, seeConstants.js ACTION_OPEN_CHAT_ROOM_FROM_PUSH)- See Also:
-
READ_WATERMARK_KEY_PREFIX
- See Also:
-
-
Constructor Details
-
ChatNotificationService
public ChatNotificationService()
-
-
Method Details
-
onMatrixPushReceived
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 IDroomId- the Matrix room IDuserName- the recipient platform usernamepushKey- 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) them.readreceipt 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 userroomId- the Matrix room ideventId- 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 unknownIllegalAccessException- when the user is not a member of the room
-
clearPendingMessages
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 usernameroomId- the Matrix room IDupToTimestamp- read watermark (inclusive)
-
isPrivateRoomMutedForUser
-
toggleMutePrivateRoom
-