Fetch One
/api/v2/room/fetch/one
Post
rooms
jwt
Purpose
To allow a user to fetch a chat room that he/she is a member of or to have some details it if it is otherwise public.
Body Content [input]
{
uid: string,
roomID: string
}
Returns if valid [output]
{
roomID: string,
name: string,
description: string,
privacy: string,
icon: string,
members: {
uid: string,
is_admin: bool,
status: string
}[],
messages: [],
threads: [],
error: 0
}
What the API does
- Finds all records from the
rooms
collection. - Filters out all records not having a
uid
in themembers
field corresponding to the one passed if they have a value ofprivate
for theirprivacy
field. - Finds the
room
being referenced using the value of theroomID
field passed [404]. - Removes the
has_muted
field for each record in theirmembers
field. - Replaces the value of the
message
field inmessages
andthreads
by an empty string if the value in theis_deleted
field is set totrue
. - Sets empty values for
members
ifuid
does not correspond to a record in themembers
field with astatus
ofaccepted
. - Sets empty values for the
messages
andthreads
fields.