Fetch All
/api/v2/message/fetch
Post
rooms
jwt
pgn
Purpose
To allow a user to fetch messages and threads from a chat room that he/she is a member of.
Body Content [input]
{
uid: string,
roomID: string
}
Returns if valid [output]
{
messages: {
messageID: string,
senderID: string,
message: string,
created_on: Date,
modified_on: Date,
views: string[],
is_deleted: bool
}[],
threads: {
threadID: string,
senderID: string,
message: string,
created_on: Date,
modified_on: Date,
views: string[],
is_deleted: bool,
reply_to: string
}[],
error: 0,
amount: int
}
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]. - Replaces the value of the
messagefield of each record in themessagesandthreadsfields by an empty string if the value of itsis_deletedfield is set totrue.