Link Search Menu Expand Document

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 the roomID passed [404].
  • Ensures that uid corresponds to a record in the members field of that record with a status of accepted [403].
  • Replaces the value of the message field of each record in the messages and threads fields by an empty string if the value of its is_deleted field is set to true.