ChatMessage
A type representing a chat message. ChatMessage
is an immutable snapshot of a chat message entity at the given time.
public struct ChatMessage
Inheritance
Hashable
Properties
id
A unique identifier of the message.
public let id: MessageId
cid
The ChannelId this message belongs to. This value can be temporarily nil
for messages that are being removed from
the local cache, or when the local cache is in the process of invalidating.
public let cid: ChannelId?
text
The text of the message.
public let text: String
type
A type of the message.
public let type: MessageType
command
If the message was created by a specific /
command, the command is saved in this variable.
public let command: String?
createdAt
Date when the message was created on the server. This date can differ from locallyCreatedAt
.
public let createdAt: Date
locallyCreatedAt
Date when the message was created locally and scheduled to be send. Applies only for the messages of the current user.
public let locallyCreatedAt: Date?
updatedAt
A date when the message was updated last time.
public let updatedAt: Date
deletedAt
If the message was deleted, this variable contains a timestamp of that event, otherwise nil
.
public let deletedAt: Date?
arguments
If the message was created by a specific /
command, the arguments of the command are stored in this variable.
public let arguments: String?
parentMessageId
The ID of the parent message, if the message is a reply, otherwise nil
.
public let parentMessageId: MessageId?
showReplyInChannel
If the message is a reply and this flag is true
, the message should be also shown in the channel, not only in the
reply thread.
public let showReplyInChannel: Bool
replyCount
Contains the number of replies for this message.
public let replyCount: Int
extraData
Additional data associated with the message.
public let extraData: [String: RawJSON]
quotedMessage
Quoted message.
public var quotedMessage: ChatMessage?
If message is inline reply this property will contain the message quoted by this reply.
isSilent
A flag indicating whether the message is a silent message.
public let isSilent: Bool
Silent messages are special messages that don't increase the unread messages count nor mark a channel as unread.
reactionScores
The reactions to the message created by any user.
public let reactionScores: [MessageReactionType: Int]
author
The user which is the author of the message.
public var author: ChatUser
mentionedUsers
A list of users that are mentioned in this message.
public var mentionedUsers: Set<ChatUser>
threadParticipants
A list of users that participated in this message thread. The last user in the list is the author of the most recent reply.
public var threadParticipants: [ChatUser]
attachmentCounts
The overall attachment count by attachment type.
public var attachmentCounts: [AttachmentType: Int]
latestReplies
A list of latest 25 replies to this message.
public var latestReplies: [ChatMessage]
localState
A possible additional local state of the message. Applies only for the messages of the current user.
public let localState: LocalMessageState?
Most of the time this value is nil
. This value is always nil
for messages not from the current user. A typical
use of this value is to check if a message is pending send/delete, and update the UI accordingly.
isFlaggedByCurrentUser
An indicator whether the message is flagged by the current user.
public let isFlaggedByCurrentUser: Bool
latestReactions
The latest reactions to the message created by any user.
public var latestReactions: Set<ChatMessageReaction>
currentUserReactions
The entire list of reactions to the message left by the current user.
public var currentUserReactions: Set<ChatMessageReaction>
isSentByCurrentUser
true
if the author of the message is the currently logged-in user.
public let isSentByCurrentUser: Bool
pinDetails
The message pinning information. Is nil
if the message is not pinned.
public let pinDetails: MessagePinDetails?
isPinned
Indicates whether the message is pinned or not.
public var isPinned: Bool
imageAttachments
Returns the attachments of .image
type.
var imageAttachments: [ChatMessageImageAttachment]
fileAttachments
Returns the attachments of .file
type.
var fileAttachments: [ChatMessageFileAttachment]
videoAttachments
Returns the attachments of .video
type.
var videoAttachments: [ChatMessageVideoAttachment]
giphyAttachments
Returns the attachments of .giphy
type.
var giphyAttachments: [ChatMessageGiphyAttachment]
linkAttachments
Returns the attachments of .linkPreview
type.
var linkAttachments: [ChatMessageLinkAttachment]
audioAttachments
Returns the attachments of .audio
type.
var audioAttachments: [ChatMessageAudioAttachment]
Methods
attachments(payloadType:)
Returns all the attachments with the payload of the provided type.
func attachments<Payload: AttachmentPayload>(
payloadType: Payload.Type
) -> [ChatMessageAttachment<Payload>]
attachment(with:)
Returns attachment for the given identifier.
func attachment(with id: AttachmentId) -> AnyChatMessageAttachment?
Parameters
id
: Attachment identifier.
Returns
A type-erased attachment.
hash(into:)
public func hash(into hasher: inout Hasher)
Operators
==
public static func == (lhs: Self, rhs: Self) -> Bool