@ably/chat - v0.10.0
    Preparing search index...

    Interface Message

    Represents a single message in a chat room.

    interface Message {
        action: ChatMessageAction;
        clientId: string;
        createdAt: Date;
        headers: MessageHeaders;
        metadata: MessageMetadata;
        operation?: Operation;
        reactions: MessageReactions;
        serial: string;
        text: string;
        timestamp: Date;
        version: string;
        get deletedAt(): undefined | Date;
        get deletedBy(): undefined | string;
        get isDeleted(): boolean;
        get isUpdated(): boolean;
        get updatedAt(): undefined | Date;
        get updatedBy(): undefined | string;
        after(message: Message): boolean;
        before(message: Message): boolean;
        copy(params?: MessageCopyParams): Message;
        equal(message: Message): boolean;
        isNewerVersionOf(message: Message): boolean;
        isOlderVersionOf(message: Message): boolean;
        isSameAs(message: Message): boolean;
        isSameVersionAs(message: Message): boolean;
        with(
            event: ChatMessageEvent | Message | MessageReactionSummaryEvent,
        ): Message;
    }
    Index

    Properties

    The action type of the message. This can be used to determine if the message was created, updated, or deleted.

    clientId: string

    The clientId of the user who created the message.

    createdAt: Date

    The timestamp at which the message was created.

    The headers of a chat message. Headers enable attaching extra info to a message, which can be used for various features such as linking to a relative point in time of a livestream video or flagging this message as important or pinned.

    Headers are part of the Ably realtime message extras.headers and they can be used for Filtered Subscriptions and similar.

    This value is always set. If there are no headers, this is an empty object.

    Do not use the headers for authoritative information. There is no server-side validation. When reading the headers, treat them like user input.

    metadata: MessageMetadata

    The metadata of a chat message. Allows for attaching extra info to a message, which can be used for various features such as animations, effects, or simply to link it to other resources such as images, relative points in time, etc.

    Metadata is part of the Ably Pub/sub message content and is not read by Ably.

    This value is always set. If there is no metadata, this is an empty object.

    Do not use metadata for authoritative information. There is no server-side validation. When reading the metadata treat it like user input.

    operation?: Operation

    The details of the operation that modified the message. This is only set for update and delete actions. It contains information about the operation: the clientId of the user who performed the operation, a description, and metadata.

    reactions: MessageReactions

    The reactions summary for this message.

    serial: string

    The unique identifier of the message.

    text: string

    The text of the message.

    timestamp: Date

    The timestamp at which this version was updated, deleted, or created.

    version: string

    A unique identifier for the latest version of this message.

    Accessors

    • get deletedAt(): undefined | Date

      The timestamp at which the message was deleted.

      Returns undefined | Date

    • get deletedBy(): undefined | string

      The clientId of the user who deleted the message.

      Returns undefined | string

    • get isDeleted(): boolean

      Indicates if the message has been deleted.

      Returns boolean

    • get isUpdated(): boolean

      Indicates if the message has been updated.

      Returns boolean

    • get updatedAt(): undefined | Date

      The timestamp at which the message was updated.

      Returns undefined | Date

    • get updatedBy(): undefined | string

      The clientId of the user who updated the message.

      Returns undefined | string

    Methods

    • Determines if this message was created after the given message. This comparison is based on global order, so does not necessarily represent the order that messages are received in realtime from the backend.

      Parameters

      • message: Message

        The message to compare against.

      Returns boolean

      true if this message was created after the given message, in global order.

      ErrorInfo if serials of either message is invalid.

    • Determines if this message was created before the given message. This comparison is based on global order, so does not necessarily represent the order that messages are received in realtime from the backend.

      Parameters

      • message: Message

        The message to compare against.

      Returns boolean

      true if this message was created before the given message, in global order.

      ErrorInfo if serials of either message is invalid.

    • Determines if this message is equal to the given message.

      Note that this method compares messages based on Message.serial alone. It returns true if the two messages represent different versions of the same message.

      Parameters

      • message: Message

        The message to compare against.

      Returns boolean

      true if the two messages are the same message.

    • Determines if this message is a newer version of the given message.

      Note that negating this function does not mean that the message is an older version of the same message, as the two may be different messages entirely.

       !message.isNewerVersionOf(other) !== message.isOlderVersionOf(other)
      

      Parameters

      • message: Message

        The message to compare against.

      Returns boolean

      true if the two messages are the same message (isSameAs returns true) and this message is a newer version.

    • Determines if this message is an older version of the given message.

      Note that negating this function does not mean that the message is a newer version of the same message, as the two may be different messages entirely.

       !message.isOlderVersionOf(other) !== message.isNewerVersionOf(other)
      

      Parameters

      • message: Message

        The message to compare against.

      Returns boolean

      true if the two messages are the same message (isSameAs returns true) and this message is an older version.

    • Determines if this message is the same version as the given message.

      Parameters

      • message: Message

        The message to compare against.

      Returns boolean

      true if the two messages are the same message and have the same version.