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
rooms
collection corresponding to theroomID
passed [404]. - Ensures that
uid
corresponds to a record in themembers
field of that record with astatus
ofaccepted
[403]. - Replaces the value of the
message
field of each record in themessages
andthreads
fields by an empty string if the value of itsis_deleted
field is set totrue
.