Class ChatNotificationService
-
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.voidonAgentPushReceived(String eventId, String roomId, String login) Entry point of a digital worker's push, called by the push gateway once it verified the worker's pusher key.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. A space room's event is read with the administrator account, so the recipient must be a member of the space: the pusher key names the recipient, and nothing else in the push proves it may read that room.- 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)
-
onAgentPushReceived
Entry point of a digital worker's push, called by the push gateway once it verified the worker's pusher key. Hands over to the platform, as thematrix.agent.mentionedevent, a message of a space room that mentions the worker throughm.mentions, is not the worker's own and is not an edit; anything else is ignored.The room kind is decided first, before anything is read from Synapse, and this is the only place the chat add-on decides it for a worker: an unknown room, a disabled one or a direct message returns at once, so a direct message, which has no space and would need the worker's own token, never holds the worker's pusher. A direct-message hand-off would start here. The worker must then be a member of the room's space: the pusher key is the only credential of the push, so the membership is checked here rather than inferred from Synapse pushing only the rooms the account joined. Every Synapse call is bounded, and every failure is logged and swallowed: the push gateway answers a worker's push with a success whatever happens, since Synapse would otherwise retry that event before any later one.
- Parameters:
eventId- the Matrix event idroomId- the Matrix room idlogin- the mentioned worker's login
-
isPrivateRoomMutedForUser
-
toggleMutePrivateRoom
-