Send
/api/v2/message/send
Post
rooms
notifications
jwt
Purpose
To allow a user to send a message in a chat room that he/she is a member of.
Body Content [input]
{
uid: string,
roomID: string,
message: string,
is_thread: bool,
reply_to: string
}
Returns if valid [output]
{
messageID: string,
error: 0
}
What the API does
- Finds the record from the
roomscollection corresponding to theroomIDpassed [404]. - Ensures that
uidcorresponds to a record in themembersfield of that record with astatusofaccepted[403]. - If
is_threadhas a value oftrue, find themessagebeing referenced in themessagesfield having amessageIDcorresponding toreply_to[404]. - Generates a
messageIDas well as atimestampfor the current date and time. - If
is_threadhas a value offalse, generate and save a new object in themessagesfield of theroomusingmessageID,message,timestampascreated_onandmodified_on,uidassenderID,falseforis_deletedand an empty array forviews. - Else if
is_threadhas a value oftrue, generate and save a new object in thethreadsfield of theroomusingmessageIDasthreadID,message,reply_to,timestampascreated_onandmodified_on,uidassenderID,falseforis_deletedand an empty array forviews.