Events

Moera client may connect to WebSockets endpoint of a node to receive events about everything happening at the node right now: new and updated posts, changed settings etc. This allows client to be more responsive. Typically the client connects to the home node (authentication token is required) and to the node the user views at the moment.

Moera uses STOMP protocol with several additional headers. Any STOMP client should be compatible.

Connecting

Client opens a WebSockets connection to the endpoint located at /events under Moera API root. Then it sends CONNECTED STOMP frame with the following headers:

  • accept-version: - as per STOMP specification;
  • host: - is required to differentiate between virtual domains at the same server;
  • token: - authentication token, if available
  • heart-beat: - recommended, as per STOMP specification.

Subscribing

After successful connection, the client sends SUBSCRIBE STOMP frame with the following headers:

  • id: - as per STOMP specification;
  • destination: /user/queue - required;
  • seen: <queueStartedAt>,<lastEvent> - in the case of reconnection, the client tells the node the queue timestamp and the number of the last event it received from this node. If possible, the node resends all events that the client lost while being disconnected.

Event packet

Events are sent to the client in MESSAGE frames. Each frame contains event packet in JSON form with the following fields:

Type Field Comment
timestamp queueStartedAt The timestamp of the moment when the current event queue was created on the node side. This value is typically changed when the node is restarted. In this case event numbers start again from 0, but combination with the queue timestamp makes them unique.
int ordinal The event ordinal number.
timestamp sentAt The event timestamp.
String cid The client ID. If the event was created as a result of processing a REST API request of some client, this field will contain a copy of cid parameter passed with the request. This mechanism allows client to know that the event is a result of processing its own request. Usually such events are ignored, because they contain information already known to the client.
Event event The event structure itself, see below.

Event

The event structure consists of type field, containing the type of the event and zero or more additional fields, containing more detailed information. See their description below.

Events typically contain minimal amount of information. Since many events are not relevant to the client and are ignored, including too much information would be waste of traffic. The client may make a REST API request, if needed.

COMMENT_ADDED

A comment was added.

Authentication:
none
Type Field Comment
String id the comment ID
String postingId the posting ID
int moment moment of the comment

COMMENT_DELETED

A comment was added.

Authentication:
none
Type Field Comment
String id the comment ID
String postingId the posting ID
int moment moment of the comment

COMMENT_REACTIONS_CHANGED

Reactions to a comment were changed.

Authentication:
none
Type Field Comment
String id the comment ID
String postingId the posting ID
int moment moment of the comment

COMMENT_UPDATED

A comment was deleted.

Authentication:
none
Type Field Comment
String id the comment ID
String postingId the posting ID
int moment moment of the comment

CLIENT_SETTINGS_CHANGED

Some client settings were changed.

Authentication:
admin

DRAFT_POSTING_ADDED

A draft posting was added.

Authentication:
admin
Type Field Comment
String id the posting ID

DRAFT_POSTING_DELETED

A draft posting was deleted.

Authentication:
admin
Type Field Comment
String id the posting ID

DRAFT_POSTING_UPDATED

A draft posting was updated.

Authentication:
admin
Type Field Comment
String id the posting ID

FEED_STATUS_UPDATED

Number of non-viewed/non-read stories in a feed was updated.

Authentication:
admin
Type Field Comment
String feedName name of the feed
int notViewed number of stories that have not been viewed yet.
int notRead number of stories that have not been read yet.

NODE_NAME_CHANGED

The name of the node was changed.

Authentication:
none
Type Field Comment
String name the new name

NODE_SETTINGS_CHANGED

Some node settings were changed.

Authentication:
admin

POSTING_ADDED

A posting was added.

Authentication:
none
Type Field Comment
String id the posting ID

POSTING_COMMENTS_CHANGED

Comments to a posting were changed.

Authentication:
none
Type Field Comment
String id the posting ID
int total the current number of comments

POSTING_DELETED

A posting was deleted.

Authentication:
none
Type Field Comment
String id the posting ID

POSTING_DRAFT_REVISION_DELETED

Draft revision of a posting was deleted.

Authentication:
admin
Type Field Comment
String id the posting ID

POSTING_DRAFT_REVISION_UPDATED

Draft revision of a posting was updated.

Authentication:
admin
Type Field Comment
String id the posting ID

POSTING_REACTIONS_CHANGED

Reactions to a posting were changed.

Authentication:
none
Type Field Comment
String id the posting ID

POSTING_RESTORED

A deleted posting was restored.

Authentication:
none
Type Field Comment
String id the posting ID

POSTING_UPDATED

A posting was updated.

Authentication:
none
Type Field Comment
String id the posting ID

PROFILE_UPDATED

Profile was updated.

Authentication:
none

SUBSCRIBED

Sent immediately after subscribing to update the client about the current queue state and its STOMP session ID.

Authentication:
the subscriber only
Type Field Comment
String sessionId STOMP session ID

REGISTERED_NAME_OPERATION_STATUS

Status of an operation on the registered name of the node was changed.

Authentication:
admin

REMOTE_COMMENT_ADDED

This node added a comment on a remote node

Authentication:
admin
Type Field Comment
String remoteNodeName the remote node name
String remotePostingId the remote posting ID
String remoteCommentId the remote comment ID

REMOTE_COMMENT_DELETED

This node deleted a comment on a remote node

Authentication:
admin
Type Field Comment
String remoteNodeName the remote node name
String remotePostingId the remote posting ID
String remoteCommentId the remote comment ID

REMOTE_COMMENT_UPDATED

This node updated a comment on a remote node

Authentication:
admin
Type Field Comment
String remoteNodeName the remote node name
String remotePostingId the remote posting ID
String remoteCommentId the remote comment ID

REMOTE_COMMENT_VERIFICATION_FAILED

Verification of the signature of a comment on a remote node failed.

Authentication:
admin
Type Field Comment
String id asynchronous operation ID
String nodeName the remote node name
String postingId the posting ID
String commentId the comment ID
String errorCode error code
String errorMessage error message

REMOTE_COMMENT_VERIFIED

Signature of a comment on a remote node was verified.

Authentication:
admin
Type Field Comment
String id asynchronous operation ID
String nodeName the remote node name
String postingId the posting ID
String commentId the comment ID
boolean correct verification result

REMOTE_POSTING_VERIFICATION_FAILED

Verification of the signature of a posting on a remote node failed.

Authentication:
admin
Type Field Comment
String id asynchronous operation ID
String nodeName the remote node name
String receiverName the posting receiver name
String postingId the posting ID
String revisionId the posting revision ID
String errorCode error code
String errorMessage error message

REMOTE_POSTING_VERIFIED

Signature of a posting on a remote node was verified.

Authentication:
admin
Type Field Comment
String id asynchronous operation ID
String nodeName the remote node name
String receiverName the posting receiver name
String postingId the posting ID
String revisionId the posting revision ID
boolean correct verification result

REMOTE_REACTION_ADDED

This node added a reaction on a remote node

Authentication:
admin
Type Field Comment
String remoteNodeName the remote node name
String remotePostingId the remote posting ID
boolean negative true, if the reaction is negative, false, if positive
int emoji reaction code, usually interpreted by clients as emoji code point
timestamp createdAt reaction creation timestamp - the real time when the reaction was created

REMOTE_REACTION_DELETED

This node deleted a reaction on a remote node

Authentication:
admin
Type Field Comment
String remoteNodeName the remote node name
String remotePostingId the remote posting ID

REMOTE_REACTION_VERIFICATION_FAILED

Verification of the signature of a reaction on a remote node failed.

Authentication:
admin
Type Field Comment
String id asynchronous operation ID
String nodeName the remote node name
String postingId the posting ID
String commentId the comment ID, if any
String reactionOwnerName the reaction owner name
String errorCode error code
String errorMessage error message

REMOTE_REACTION_VERIFIED

Signature of a reaction on a remote node was verified.

Authentication:
admin
Type Field Comment
String id asynchronous operation ID
String nodeName the remote node name
String postingId the posting ID
String commentId the comment ID, if any
String reactionOwnerName the reaction owner name
boolean correct verification result

STORIES_STATUS_UPDATED

Viewed/read status of a group of stories in a feed was changed.

Authentication:
admin
Type Field Comment
String feedName name of the feed
boolean viewed new value of the viewed flag (null, if the flag is not changed).
boolean read new value of the read flag (null, if the flag is not changed).
int before flags for all stories before this moment, inclusive were changed.

STORY_ADDED

A story was created.

Authentication:
none
Type Field Comment
String id
String storyType type of the story
String feedName name of the feed
timestamp publishedAt story publication timestamp - the time the story is published under in the feed
boolean pinned true, if the story is pinned (should appear before any non-pinned story in the feed), false otherwise
int moment
String postingId ID of the posting this story is about (may be absent)
boolean viewed (admin only) true, if the story has been viewed by node owner, false otherwise
boolean read (admin only) true, if the story has been read by node owner, false otherwise
String summary user-readable summary of the story
String trackingId ID (visible by node admin only) that may be used to update the story viewed/read status without authentication
String remoteNodeName name of the node this story is about (may be absent)
String remotePostingId ID of the posting at remote node this story is about (may be absent)
String remoteCommentId ID of the comment at remote node this story is about (may be absent)
String -> String[] operations list of the supported operations and the corresponding access hints

STORY_DELETED

A story was deleted.

Authentication:
none
Type Field Comment
String id
String storyType type of the story
String feedName name of the feed
timestamp publishedAt story publication timestamp - the time the story is published under in the feed
boolean pinned true, if the story is pinned (should appear before any non-pinned story in the feed), false otherwise
int moment
String postingId ID of the posting this story is about (may be absent)
boolean viewed (admin only) true, if the story has been viewed by node owner, false otherwise
boolean read (admin only) true, if the story has been read by node owner, false otherwise
String summary user-readable summary of the story
String trackingId ID (visible by node admin only) that may be used to update the story viewed/read status without authentication
String remoteNodeName name of the node this story is about (may be absent)
String remotePostingId ID of the posting at remote node this story is about (may be absent)
String remoteCommentId ID of the comment at remote node this story is about (may be absent)
String -> String[] operations list of the supported operations and the corresponding access hints

STORY_UPDATED

A story was updated.

Authentication:
none
Type Field Comment
String id
String storyType type of the story
String feedName name of the feed
timestamp publishedAt story publication timestamp - the time the story is published under in the feed
boolean pinned true, if the story is pinned (should appear before any non-pinned story in the feed), false otherwise
int moment
String postingId ID of the posting this story is about (may be absent)
boolean viewed (admin only) true, if the story has been viewed by node owner, false otherwise
boolean read (admin only) true, if the story has been read by node owner, false otherwise
String summary user-readable summary of the story
String trackingId ID (visible by node admin only) that may be used to update the story viewed/read status without authentication
String remoteNodeName name of the node this story is about (may be absent)
String remotePostingId ID of the posting at remote node this story is about (may be absent)
String remoteCommentId ID of the comment at remote node this story is about (may be absent)
String -> String[] operations list of the supported operations and the corresponding access hints

SUBSCRIBER_ADDED

A node subscribed to notifications from this node.

Authentication:
none
Type Field Comment
String id subscriber ID
String subscriptionType subscription type
String feedName feed name, if the subscription type requires one
String postingId posting ID, if the subscription type requires one
String nodeName name of the subscribed node
timestamp createdAt subscription creation timestamp

SUBSCRIBER_DELETED

A node unsubscribed from notifications from this node.

Authentication:
none
Type Field Comment
String id subscriber ID
String subscriptionType subscription type
String feedName feed name, if the subscription type requires one
String postingId posting ID, if the subscription type requires one
String nodeName name of the subscribed node
timestamp createdAt subscription creation timestamp

SUBSCRIPTION_ADDED

This node subscribed to notifications from a remote node.

Authentication:
none
Type Field Comment
String id
String subscriptionType subscription type
String feedName
String remoteSubscriberId
String remoteNodeName
String remoteFeedName
String remotePostingId
timestamp createdAt

SUBSCRIPTION_DELETED

This node unsubscribed from notifications from a remote node.

Authentication:
none
Type Field Comment
String id
String subscriptionType subscription type
String feedName
String remoteSubscriberId
String remoteNodeName
String remoteFeedName
String remotePostingId
timestamp createdAt