Reactions
Let users react to messages, posts, and comments which are visible to others.
Reactions are the interactions that you can perform with a message, post, or comment. This can be anything such as like, dislike, love, etc.
MessageRepository
, PostRepository
, and CommentRepository
classes provide a convenient method to add, remove, and query reactions for any content. Currently, reactions are supported for Posts, Messages, and Comments.
Reaction Description
Name | Data Type | Description | Attributes |
|
| ID of a reaction | |
|
| ID of a document | |
|
| Type of document | |
|
| ID of the creator | |
|
| Name of reaction | ' |
|
| Date/time when a reaction is created |
Reaction Data
Each post, comment, message has a set of fields providing detailed info about reactions.
reactionsCount
- how many reactions the post hasmyReactions
- list of reactions you added to the postreactions
- map that tells how many reactions of a certain type a post has
Before you can perform the adding or removing of reactions to the related post or comment, the post or comment must be fetched from the server first using either of these methods:
Methods used for fetching posts
Methods used for fetching comments
Query Reaction
You can fetch a detailed information about reactions and the users who reacted to a post, comment, or message by using the ReactionRepository
class.
You can fetch information about a particular reaction and all the reactions through thequeryReactions
method. This method requires the following parameters:
referenceId
- ID of the post and contentreferenceType
- values can bemessage
,post
andcomment
The response from the query is a collection of reaction models.
Add Reaction
You can add reactions to a given post through the addReaction
method which accepts the following parameters:
postId
/commentId
- ID of the post or comment respectivelyreactionName
- name of the reaction that you will add. Reaction name is case sensitive, i.e "like" & "Like" are two different reactions.
The method returns a promise. If the reaction is successfully added, the method will return true
. Otherwise, it will return false
or an error.
Remove Reaction
You can remove a reaction from a message, post, or comment by calling removeReaction
. This method requires the following parameters:
postId
/commentId
- ID of the post or comment respectivelyreactionName
- name of the reaction that you will remove. Reaction name is case sensitive, i.e "like" & "Like" are two different reactions.
The method returns a promise. If the reaction is successfully removed, the method will return true
. Otherwise, it will return false
or an error.
Last updated