Class MessageService
- All Implemented Interfaces:
ZulipService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddEmojiReaction
(long messageId, String emojiName) Adds a emoji reaction to a message.deleteEmojiReaction
(long messageId, String emojiName) Removes a emoji reaction.deleteMessage
(long messageId) Permanently deletes a message.deleteScheduledMessage
(long scheduledMessageId) Deletes and cancels the sending of a previously scheduled message.editMessage
(long messageId) Edits the content or topic of a message.editScheduledMessage
(long scheduledMessageId) Edits an existing scheduled message.fileUpload
(File file) Uploads a file to the Zulip server.getMessage
(long messageId) Gets a single message.getMessageHistory
(long messageId) Gets a message edit history.getMessageReadReceipts
(long messageId) Gets a list containing of IDs for all users who have marked the given message as read.getMessages
(int numBefore, int numAfter, long anchor) Fetch message history from a Zulip server using the specified before message id, after message id and anchor message ID.getMessages
(int numBefore, int numAfter, Anchor anchor) Fetch message history from a Zulip server using the specified before message id, after message id and anchor value.getMessages
(List<Long> messageIds) Gets a messages matching the given message IDs.Fetch all scheduled messages for the current user.Deprecated.markStreamAsRead
(long streamId) Marks a stream as read.markTopicAsRead
(long streamId, String topicName) Marks a topic as read.Searches for and matches messages with a narrow.renderMessage
(String content) Renders a message to HTML.sendChannelMessage
(String content, long channelId, String topic) Sends a channel message to the given channel id and topic.sendChannelMessage
(String content, String channelName, String topic) Sends a channel message to the given channel name and topic.sendDirectMessage
(String content, long... userIds) Sends a direct message to the users matching the given email user ids.sendDirectMessage
(String content, String... userEmails) Sends a direct message to the users matching the given email addresses.sendScheduledMessage
(MessageType type, String content, Instant deliveryTimestamp, long... to) Schedules the sending of a message to a specified stream or users.sendStreamMessage
(String content, long streamId, String topic) Sends a stream message to the given stream id and topic.sendStreamMessage
(String content, String streamName, String topic) Sends a stream message to the given stream name and topic.updateMessageFlags
(MessageFlag flag, Operation operation, long... messageIds) Add or remove personal message flags on a collection of message idsupdateMessageFlagsForNarrow
(int anchor, int numBefore, int numAfter, Operation operation, MessageFlag flag, Narrow... narrows) Add or remove personal message flags with a narrowupdateMessageFlagsForNarrow
(Anchor anchor, int numBefore, int numAfter, Operation operation, MessageFlag flag, Narrow... narrows) Add or remove personal message flags with a narrow
-
Constructor Details
-
MessageService
Constructs aMessageService
.- Parameters:
client
- The Zulip HTTP client
-
-
Method Details
-
addEmojiReaction
Adds a emoji reaction to a message.- Parameters:
messageId
- The id of the message to add an emoji reaction toemojiName
- The name of the emoji to add- Returns:
- The
AddEmojiReactionApiRequest
builder object - See Also:
-
deleteEmojiReaction
Removes a emoji reaction.- Parameters:
messageId
- The id of the message to remove the reaction fromemojiName
- The name of the emoji to remove- Returns:
- The
DeleteEmojiReactionApiRequest
builder object - See Also:
-
deleteMessage
Permanently deletes a message.- Parameters:
messageId
- The id of the message to delete- Returns:
- The
DeleteMessageApiRequest
builder object - See Also:
-
deleteScheduledMessage
Deletes and cancels the sending of a previously scheduled message.- Parameters:
scheduledMessageId
- The id of the scheduled message to delete- Returns:
- The
DeleteMessageApiRequest
builder object - See Also:
-
editMessage
Edits the content or topic of a message.- Parameters:
messageId
- The id of the message to edit- Returns:
- The
EditMessageApiRequest
builder object - See Also:
-
editScheduledMessage
Edits an existing scheduled message.- Parameters:
scheduledMessageId
- The id of the scheduled message to edit- Returns:
- The
EditMessageApiRequest
builder object - See Also:
-
fileUpload
Uploads a file to the Zulip server.- Parameters:
file
- The file to upload- Returns:
- The
FileUploadApiRequest
builder object - See Also:
-
getMessageHistory
Gets a message edit history.- Parameters:
messageId
- The id of the message to get edit history- Returns:
- The
GetMessageHistoryApiRequest
builder object - See Also:
-
getMessage
Gets a single message.- Parameters:
messageId
- The id of the message to get- Returns:
- The
GetMessageApiRequest
builder object - See Also:
-
getMessages
Gets a messages matching the given message IDs.- Parameters:
messageIds
- The IDs of the messages to fetch- Returns:
- The
GetMessagesApiRequest
builder object
-
getMessages
Fetch message history from a Zulip server using the specified before message id, after message id and anchor value.
To refine the list of messages returned, use the returned
GetMessagesApiRequest
builder object to set an anchor and narrow expression.Note that a maximum of 5000 messages can be obtained per request. Therefore Zulip recommends using a numBefore value of <= 1000 and a numAfter value <= 1000.
- Parameters:
numBefore
- The number of messages with IDs less than the anchor to retrievenumAfter
- The number of messages with IDs greater than the anchor to retrieveanchor
- The value for the server to compute the anchor from- Returns:
- The
GetMessagesApiRequest
builder object - See Also:
-
getMessages
Fetch message history from a Zulip server using the specified before message id, after message id and anchor message ID.
To refine the list of messages returned, use the returned
GetMessagesApiRequest
builder object to set an anchor and narrow expression.Note that a maximum of 5000 messages can be obtained per request. Therefore Zulip recommends using a numBefore value of <= 1000 and a numAfter vlaue <= 1000.
- Parameters:
numBefore
- The number of messages with IDs less than the (optional) anchor to retrievenumAfter
- The number of messages with IDs greater than the (optional) anchor to retrieveanchor
- The message ID to anchor fetching of new message- Returns:
- The
GetMessagesApiRequest
builder object - See Also:
-
getScheduledMessages
Fetch all scheduled messages for the current user.- Returns:
- The
GetScheduledMessagesApiRequest
builder object - See Also:
-
markAllAsRead
Deprecated.useupdateMessageFlagsForNarrow
instead.Marks all of the current user unread messages as read.- Returns:
- The
MarkAllAsReadApiRequest
builder object - See Also:
-
markStreamAsRead
Marks a stream as read.- Parameters:
streamId
- The id of the stream to mark as read- Returns:
- The
MarkStreamAsReadApiRequest
builder object - See Also:
-
markTopicAsRead
Marks a topic as read.- Parameters:
streamId
- The id of the stream wher the topic residestopicName
- The name of the topic to mark as read- Returns:
- The
MarkTopicAsReadApiRequest
builder object - See Also:
-
matchMessages
Searches for and matches messages with a narrow.- Returns:
- The
MatchesNarrowApiRequest
builder object - See Also:
-
renderMessage
Renders a message to HTML.- Parameters:
content
- The content to render as HTML- Returns:
- The
RenderMessageApiRequest
builder object - See Also:
-
sendChannelMessage
Sends a channel message to the given channel name and topic.- Parameters:
content
- The content of the messagechannelName
- The name of the channel to send the message totopic
- The name of the message topic- Returns:
- The
SendMessageApiRequest
builder object - See Also:
-
sendChannelMessage
Sends a channel message to the given channel id and topic.- Parameters:
content
- The content of the messagechannelId
- The id of the stream to send the message totopic
- The name of the message topic- Returns:
- The
SendMessageApiRequest
builder object - See Also:
-
sendDirectMessage
Sends a direct message to the users matching the given email addresses.- Parameters:
content
- The content of the messageuserEmails
- The email addresses of the users to send the message to- Returns:
- The
SendMessageApiRequest
builder object - See Also:
-
sendDirectMessage
Sends a direct message to the users matching the given email user ids.- Parameters:
content
- The content of the messageuserIds
- The ids of the users to send the message to- Returns:
- The
SendMessageApiRequest
builder object - See Also:
-
sendScheduledMessage
public SendScheduledMessageApiRequest sendScheduledMessage(MessageType type, String content, Instant deliveryTimestamp, long... to) Schedules the sending of a message to a specified stream or users.- Parameters:
type
- The type of scheduled message to be sentcontent
- The content of the messagedeliveryTimestamp
-Instant
set to the UNIX epoch timestamp for when the message will be sentto
- If the type is 'stream' then this is the id of the stream. Else one or more user ids may be specified- Returns:
- The
SendScheduledMessageApiRequest
-
sendStreamMessage
Sends a stream message to the given stream name and topic.- Parameters:
content
- The content of the messagestreamName
- The name of the stream to send the message totopic
- The name of the message topic- Returns:
- The
SendMessageApiRequest
builder object - See Also:
-
sendStreamMessage
Sends a stream message to the given stream id and topic.- Parameters:
content
- The content of the messagestreamId
- The id of the stream to send the message totopic
- The name of the message topic- Returns:
- The
SendMessageApiRequest
builder object - See Also:
-
updateMessageFlags
public UpdateMessageFlagsApiRequest updateMessageFlags(MessageFlag flag, Operation operation, long... messageIds) Add or remove personal message flags on a collection of message ids- Parameters:
flag
- TheMessageFlag
to add or removeoperation
- TheOperation
to applymessageIds
- The message ids to update flags on- Returns:
- The
UpdateMessageFlagsApiRequest
builder object - See Also:
-
updateMessageFlagsForNarrow
public UpdateMessageFlagsForNarrowApiRequest updateMessageFlagsForNarrow(Anchor anchor, int numBefore, int numAfter, Operation operation, MessageFlag flag, Narrow... narrows) Add or remove personal message flags with a narrow- Parameters:
anchor
- TheAnchor
to usenumBefore
- The number of messages preceding the anchor in the update rangenumAfter
- The number of messages following the anchor in the update rangeoperation
- TheOperation
to apply for theMessageFlag
flag
- TheMessageFlag
to add or remove to the messagesnarrows
- TheNarrow
expressions to use- Returns:
- The
UpdateMessageFlagsApiRequest
builder object - See Also:
-
updateMessageFlagsForNarrow
public UpdateMessageFlagsForNarrowApiRequest updateMessageFlagsForNarrow(int anchor, int numBefore, int numAfter, Operation operation, MessageFlag flag, Narrow... narrows) Add or remove personal message flags with a narrow- Parameters:
anchor
- The message id anchor to filter and restrict messagesnumBefore
- The number of messages preceding the anchor in the update rangenumAfter
- The number of messages following the anchor in the update rangeoperation
- TheOperation
to apply for theMessageFlag
flag
- TheMessageFlag
to add or remove to the messagesnarrows
- TheNarrow
expressions to use- Returns:
- The
UpdateMessageFlagsApiRequest
builder object - See Also:
-
getMessageReadReceipts
Gets a list containing of IDs for all users who have marked the given message as read.- Parameters:
messageId
- The id of the message to get read recipients for- Returns:
- The
GetMessageReadReceiptsApiRequest
builder object - See Also:
-
updateMessageFlagsForNarrow
instead.