Link Search Menu Expand Document

Delete

/api/v2/message/delete

Post

rooms

jwt


Purpose

To allow a user to delete a sent message in a chat room that he/she is a member of.

Body Content [input]

{
    uid: string,
    roomID: string,
    messageID: string,
    is_thread: bool
}

Returns if valid [output]

{
    message: string,
    error: 0
}

What the API does

  • Finds the record from the rooms collection corresponding to the roomID passed [404].
  • Ensures that uid corresponds to a record in the members field of that record with a status of accepted [403].
  • If is_thread has a value of false, find the message being referenced in the messages field having the same value of messageID as that passed, else if is_thread has a value of true find that being referenced from the threads field [404].
  • Checks that the senderID field of the found message has the same value as that of the uid passed [403].
  • If is_thread has a value of false, set the value of the is_deleted field of the object from the messages field of the room corresponding to messageID to true.
  • Else if is_thread has a value of true, set the value of the is_deleted field of the object from the threads field of the room corresponding to messageID to true.