Link Search Menu Expand Document

Leave

/api/v2/room/leave

Post

rooms

jwt


Purpose

To allow a user to leave a chat room that he/she is already a member of.

Body Content [input]

{
    uid: string,
    roomID: string
}

Returns if valid [output]

{
    message: string,
    error: 0
}

What the API does

  • Finds the room being referenced by the roomID passed [404].
  • Ensures that uid corresponds to a record in the members field with a status of accepted [403].
  • Generates a messageID and timestamp corresponding to the current date and time.
  • Generates and saves a new object in the messages field of the room using messageID, “uid.${uid} has left the chat” as message, timestamp as created_on and modified_on, “_system” as senderID, false for is_deleted and an empty array for views.
  • Removes the record in the members field corresponding to uid from the room.