RelationService

interface RelationService

In some cases, events may wish to reference other events. This could be to form a thread of messages for the user to follow along with, or to provide more context as to what a particular event is describing. Relation are used to associate new information with an existing event.

Relations are events which have an m.relates_to mixin in their contents, and the new information they convey is expressed in their usual event type and content.

Three types of relations are defined, each defining different behaviour when aggregated:

m.annotation - lets you define an event which annotates an existing event. When aggregated, groups events together based on key and returns a count. (aka SQL's COUNT) These are primarily intended for handling reactions.

m.replace - lets you define an event which replaces an existing event. When aggregated, returns the most recent replacement event. (aka SQL's MAX) These are primarily intended for handling edits.

m.reference - lets you define an event which references an existing event. When aggregated, currently doesn't do anything special, but in future could bundle chains of references (i.e. threads). These are primarily intended for handling replies (and in future threads).

m.thread - lets you define an event which is a thread reply to an existing event. When aggregated, returns the most thread event

Functions

Link copied to clipboard
abstract fun editPoll(    targetEvent: TimelineEvent,     pollType: PollType,     question: String,     options: List<String>): Cancelable

Edit a poll.

Link copied to clipboard
abstract fun editReply(    replyToEdit: TimelineEvent,     originalTimelineEvent: TimelineEvent,     newBodyText: CharSequence,     newFormattedBodyText: String? = null,     compatibilityBodyText: String = "* "): Cancelable

Edit a reply. This is a special case because replies contains fallback text as a prefix. This method will take the new body (stripped from fallbacks) and re-add them before sending.

Link copied to clipboard
abstract fun editTextMessage(    targetEvent: TimelineEvent,     msgType: String,     newBodyText: CharSequence,     newFormattedBodyText: CharSequence? = null,     newBodyAutoMarkdown: Boolean,     compatibilityBodyText: String = "* "): Cancelable

Edit a text message body. Limited to "m.text" contentType.

Link copied to clipboard
abstract suspend fun fetchEditHistory(eventId: String): List<Event>

Get the edit history of the given event. The return list will contain the original event and all the editions of this event, done by the same sender, sorted in the reverse order (so the original event is the latest element, and the latest edition is the first element of the list)

Link copied to clipboard
abstract fun getEventAnnotationsSummary(eventId: String): EventAnnotationsSummary?

Get the current EventAnnotationsSummary.

Link copied to clipboard
abstract fun getEventAnnotationsSummaryLive(eventId: String): LiveData<Optional<EventAnnotationsSummary>>

Get a LiveData of EventAnnotationsSummary for the specified eventId.

Link copied to clipboard
abstract fun replyInThread(    rootThreadEventId: String,     replyInThreadText: CharSequence,     msgType: String = MessageType.MSGTYPE_TEXT,     autoMarkdown: Boolean = false,     formattedText: String? = null,     eventReplied: TimelineEvent? = null): Cancelable?

Creates a thread reply for an existing timeline event. The replyInThreadText can be a Spannable and contains special spans (MatrixItemSpan) that will be translated by the sdk into pills.

Link copied to clipboard
abstract fun replyToMessage(    eventReplied: TimelineEvent,     replyText: CharSequence,     replyFormattedText: CharSequence? = null,     autoMarkdown: Boolean = false,     showInThread: Boolean = false,     rootThreadEventId: String? = null): Cancelable?

Reply to an event in the timeline (must be in same room) https://matrix.org/docs/spec/client_server/r0.4.0.html#id350 The replyText can be a Spannable and contains special spans (MatrixItemSpan) that will be translated by the sdk into pills.

Link copied to clipboard
abstract fun sendReaction(targetEventId: String, reaction: String): Cancelable

Sends a reaction (emoji) to the targetedEvent. It has no effect if the user has already added the same reaction to the event.

Link copied to clipboard
abstract suspend fun undoReaction(targetEventId: String, reaction: String): Cancelable

Undo a reaction (emoji) to the targetedEvent.