scheduleMessage

fun scheduleMessage(channelType: String, channelId: String, message: Message, scheduledAt: Date): Call<ScheduledMessage>

Schedules a message to be sent at scheduledAt. Set Message.parentId to schedule a thread reply.

The message is saved locally first, so it is in scheduledMessages right away with the ScheduledMessageStatus.PreparingToSchedule status. It is sent to the server once its attachments are uploaded and the device is online. The server answers later, on the scheduled message: a rejection sets its status to ScheduledMessageStatus.Failed, and ScheduledMessage.failure says why. When scheduledAt has passed by then, the server sends it right away as a normal message.

The message is refused before it is saved when it starts with / in a channel that has commands, when it quotes a message that was deleted, when scheduledAt is further ahead than Config.scheduledMessagesMaxLeadTimeSeconds, or when the user already has as many pending scheduled messages as Config.scheduledMessagesMaxPerChannel in the channel or Config.scheduledMessagesMaxPerUser in all channels, as known from the channel config and messages saved on this device. It is also refused when no user is set.

Return

Executable async Call responsible for scheduling the message, with the scheduled message as saved locally.

Parameters

channelType

The type of the channel.

channelId

The ID of the channel.

message

The message to send. Its attachments can have local files to upload.

scheduledAt

The date when the message is sent. The server rounds it up to the next minute.