Package org.matrix.android.sdk.api.session.events.model

Types

Link copied to clipboard
@JsonClass(generateAdapter = true)
data class AggregatedAnnotation(    val limited: Boolean? = false,     val count: Int? = 0,     val chunk: List<RelationChunkInfo>? = null) : UnsignedRelationInfo
{ "chunk": [ { "type": "m.reaction", "key": "👍", "count": 3 } ], "limited": false, "count": 1 },
Link copied to clipboard
@JsonClass(generateAdapter = true)
data class AggregatedRelations(    @Json(name = "m.annotation") val annotations: AggregatedAnnotation? = null,     @Json(name = "m.reference") val references: DefaultUnsignedRelationInfo? = null,     @Json(name = "m.replace") val replaces: AggregatedReplace? = null,     @Json(name = "m.thread") val latestThread: LatestThreadUnsignedRelation? = null)

Server side relation aggregation.

Link copied to clipboard
@JsonClass(generateAdapter = true)
data class AggregatedReplace(    @Json(name = "event_id") val eventId: String? = null,     @Json(name = "origin_server_ts") val originServerTs: Long? = null,     @Json(name = "sender") val senderId: String? = null)

Note that there can be multiple events with an m.replace relationship to a given event (for example, if an event is edited multiple times). These should be aggregated by the homeserver. https://spec.matrix.org/v1.4/client-server-api/#server-side-aggregation-of-mreplace-relationships

Link copied to clipboard
typealias Content = JsonDict
Link copied to clipboard
@JsonClass(generateAdapter = true)
data class DefaultUnsignedRelationInfo(    val limited: Boolean? = false,     val count: Int? = 0,     val chunk: List<Map<String, Any>>? = null) : UnsignedRelationInfo
Link copied to clipboard
@JsonClass(generateAdapter = true)
data class Event(    @Json(name = "type") val type: String? = null,     @Json(name = "event_id") val eventId: String? = null,     @Json(name = "content") val content: Content? = null,     @Json(name = "prev_content") val prevContent: Content? = null,     @Json(name = "origin_server_ts") val originServerTs: Long? = null,     @Json(name = "sender") val senderId: String? = null,     @Json(name = "state_key") val stateKey: String? = null,     @Json(name = "room_id") val roomId: String? = null,     @Json(name = "unsigned") val unsignedData: UnsignedData? = null,     @Json(name = "redacts") val redacts: String? = null)

Generic event class with all possible fields for events. The content and prevContent json fields can easily be mapped to a model with toModel method.

Link copied to clipboard
object EventType

Constants defining known event types from Matrix specifications.

Link copied to clipboard
@JsonClass(generateAdapter = true)
data class LatestThreadUnsignedRelation(    val limited: Boolean? = false,     val count: Int? = 0,     @Json(name = "latest_event") val event: Event? = null,     @Json(name = "current_user_participated") val isUserParticipating: Boolean? = false) : UnsignedRelationInfo
Link copied to clipboard
object LocalEcho
Link copied to clipboard
@JsonClass(generateAdapter = true)
data class RelationChunkInfo(    val type: String,     val key: String,     val count: Int)
{ "type": "m.reaction", "key": "👍", "count": 3 }
Link copied to clipboard
object RelationType

Constants defining known event relation types from Matrix specifications.

Link copied to clipboard
data class StableUnstableId(val stable: String, val unstable: String)
Link copied to clipboard
@JsonClass(generateAdapter = true)
data class UnsignedData(    @Json(name = "age") val age: Long?,     @Json(name = "redacted_because") val redactedEvent: Event? = null,     @Json(name = "transaction_id") val transactionId: String? = null,     @Json(name = "prev_content") val prevContent: Map<String, Any>? = null,     @Json(name = "m.relations") val relations: AggregatedRelations? = null,     @Json(name = "replaces_state") val replacesState: String? = null)
Link copied to clipboard
interface UnsignedRelationInfo
Link copied to clipboard
data class ValidDecryptedEvent(    val type: String,     val eventId: String,     val clearContent: Content,     val prevContent: Content? = null,     val originServerTs: Long,     val cryptoSenderKey: String,     val roomId: String,     val unsignedData: UnsignedData? = null,     val redacts: String? = null,     val algorithm: String)

Functions

Link copied to clipboard
fun Event.getMsgType(): String?

Return the value of "content.msgtype", if the Event type is "m.room.message" and if the content has it, and if it is a String.

Link copied to clipboard
fun Event.getPollContent(): MessagePollContent?
Link copied to clipboard
fun Event.getPollQuestion(): String?

Returns the poll question or null otherwise.

Link copied to clipboard
fun Event.getRelationContent(): RelationDefaultContent?
Link copied to clipboard
fun Event.getRelationContentForType(type: String): RelationDefaultContent?

Returns the relation content for a specific type or null otherwise.

Link copied to clipboard
fun Event.getRootThreadEventId(): String?
Link copied to clipboard
fun Event.isAttachmentMessage(): Boolean
Link copied to clipboard
fun Event.isAudioMessage(): Boolean
Link copied to clipboard
fun Event.isContentReportable(): Boolean
Link copied to clipboard
fun Event.isEdition(): Boolean
Link copied to clipboard
fun Event.isFileMessage(): Boolean
Link copied to clipboard
fun Event.isImageMessage(): Boolean
Link copied to clipboard
fun Event.isInvitation(): Boolean
Link copied to clipboard
fun Event.isLiveLocation(): Boolean
Link copied to clipboard
fun Event.isLocationMessage(): Boolean
Link copied to clipboard
fun Event.isPoll(): Boolean
Link copied to clipboard
fun Event.isPollEnd(): Boolean
Link copied to clipboard
fun Event.isPollResponse(): Boolean
Link copied to clipboard
fun Event.isPollStart(): Boolean
Link copied to clipboard
fun UnsignedData?.isRedacted(): Boolean
Link copied to clipboard
fun Event.isReply(): Boolean
Link copied to clipboard
fun Event.isReplyRenderedInThread(): Boolean
Link copied to clipboard
fun Event.isSticker(): Boolean
Link copied to clipboard
fun Event.isTextMessage(): Boolean
Link copied to clipboard
fun Event.isThread(): Boolean
Link copied to clipboard
fun Event.isVideoMessage(): Boolean
Link copied to clipboard
fun Event.isVoiceMessage(): Boolean
Link copied to clipboard
fun Event.supportsNotification(): Boolean
Link copied to clipboard
inline fun <T> T.toContent(): Content

This methods is a facility method to map a model to a json Content.

Link copied to clipboard
inline fun <T> Content?.toModel(catchError: Boolean = true): T?

This methods is a facility method to map a json content to a model.

Link copied to clipboard
fun Event.toValidDecryptedEvent(): ValidDecryptedEvent?