Remove io.element.thread and add stable m.thread prefix

This commit is contained in:
ariskotsomitopoulos 2022-03-10 12:06:02 +02:00
parent a53d5bdba2
commit 03f293f216
10 changed files with 17 additions and 20 deletions

View File

@ -50,5 +50,5 @@ import com.squareup.moshi.JsonClass
data class AggregatedRelations( data class AggregatedRelations(
@Json(name = "m.annotation") val annotations: AggregatedAnnotation? = null, @Json(name = "m.annotation") val annotations: AggregatedAnnotation? = null,
@Json(name = "m.reference") val references: DefaultUnsignedRelationInfo? = null, @Json(name = "m.reference") val references: DefaultUnsignedRelationInfo? = null,
@Json(name = RelationType.IO_THREAD) val latestThread: LatestThreadUnsignedRelation? = null @Json(name = RelationType.THREAD) val latestThread: LatestThreadUnsignedRelation? = null
) )

View File

@ -392,9 +392,9 @@ fun Event.isReplyRenderedInThread(): Boolean {
return isReply() && getRelationContent()?.inReplyTo?.shouldRenderInThread() == true return isReply() && getRelationContent()?.inReplyTo?.shouldRenderInThread() == true
} }
fun Event.isThread(): Boolean = getRelationContentForType(RelationType.IO_THREAD)?.eventId != null fun Event.isThread(): Boolean = getRelationContentForType(RelationType.THREAD)?.eventId != null
fun Event.getRootThreadEventId(): String? = getRelationContentForType(RelationType.IO_THREAD)?.eventId fun Event.getRootThreadEventId(): String? = getRelationContentForType(RelationType.THREAD)?.eventId
fun Event.isEdition(): Boolean { fun Event.isEdition(): Boolean {
return getRelationContentForType(RelationType.REPLACE)?.eventId != null return getRelationContentForType(RelationType.REPLACE)?.eventId != null

View File

@ -30,7 +30,6 @@ object RelationType {
/** Lets you define an event which is a thread reply to an existing event.*/ /** Lets you define an event which is a thread reply to an existing event.*/
const val THREAD = "m.thread" const val THREAD = "m.thread"
const val IO_THREAD = "io.element.thread"
/** Lets you define an event which adds a response to an existing event.*/ /** Lets you define an event which adds a response to an existing event.*/
const val RESPONSE = "org.matrix.response" const val RESPONSE = "org.matrix.response"

View File

@ -28,7 +28,7 @@ internal object FilterFactory {
limit = numberOfEvents, limit = numberOfEvents,
// senders = listOf(userId), // senders = listOf(userId),
// relationSenders = userId?.let { listOf(it) }, // relationSenders = userId?.let { listOf(it) },
relationTypes = listOf(RelationType.IO_THREAD) relationTypes = listOf(RelationType.THREAD)
) )
} }

View File

@ -52,14 +52,12 @@ data class RoomEventFilter(
* A list of relation types which must be exist pointing to the event being filtered. * A list of relation types which must be exist pointing to the event being filtered.
* If this list is absent then no filtering is done on relation types. * If this list is absent then no filtering is done on relation types.
*/ */
// @Json(name = "related_by_rel_types") val relationTypes: List<String>? = null, @Json(name = "related_by_rel_types") val relationTypes: List<String>? = null,
@Json(name = "io.element.relation_types") val relationTypes: List<String>? = null, // To be replaced with the above line after the release
/** /**
* A list of senders of relations which must exist pointing to the event being filtered. * A list of senders of relations which must exist pointing to the event being filtered.
* If this list is absent then no filtering is done on relation types. * If this list is absent then no filtering is done on relation types.
*/ */
// @Json(name = "related_by_senders") val relationSenders: List<String>? = null, @Json(name = "related_by_senders") val relationSenders: List<String>? = null,
@Json(name = "io.element.relation_senders") val relationSenders: List<String>? = null, // To be replaced with the above line after the release
/** /**
* A list of room IDs to include. If this list is absent then all rooms are included. * A list of room IDs to include. If this list is absent then all rooms are included.

View File

@ -239,7 +239,7 @@ internal interface RoomAPI {
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "rooms/{roomId}/relations/{eventId}/{relationType}") @GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "rooms/{roomId}/relations/{eventId}/{relationType}")
suspend fun getThreadsRelations(@Path("roomId") roomId: String, suspend fun getThreadsRelations(@Path("roomId") roomId: String,
@Path("eventId") eventId: String, @Path("eventId") eventId: String,
@Path("relationType") relationType: String = RelationType.IO_THREAD, @Path("relationType") relationType: String = RelationType.THREAD,
@Query("from") from: String? = null, @Query("from") from: String? = null,
@Query("to") to: String? = null, @Query("to") to: String? = null,
@Query("limit") limit: Int? = null @Query("limit") limit: Int? = null

View File

@ -353,7 +353,7 @@ internal class LocalEchoEventFactory @Inject constructor(
url = attachment.queryUri.toString(), url = attachment.queryUri.toString(),
relatesTo = rootThreadEventId?.let { relatesTo = rootThreadEventId?.let {
RelationDefaultContent( RelationDefaultContent(
type = RelationType.IO_THREAD, type = RelationType.THREAD,
eventId = it, eventId = it,
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it)) inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it))
) )
@ -396,7 +396,7 @@ internal class LocalEchoEventFactory @Inject constructor(
url = attachment.queryUri.toString(), url = attachment.queryUri.toString(),
relatesTo = rootThreadEventId?.let { relatesTo = rootThreadEventId?.let {
RelationDefaultContent( RelationDefaultContent(
type = RelationType.IO_THREAD, type = RelationType.THREAD,
eventId = it, eventId = it,
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it)) inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it))
) )
@ -426,7 +426,7 @@ internal class LocalEchoEventFactory @Inject constructor(
voiceMessageIndicator = if (!isVoiceMessage) null else emptyMap(), voiceMessageIndicator = if (!isVoiceMessage) null else emptyMap(),
relatesTo = rootThreadEventId?.let { relatesTo = rootThreadEventId?.let {
RelationDefaultContent( RelationDefaultContent(
type = RelationType.IO_THREAD, type = RelationType.THREAD,
eventId = it, eventId = it,
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it)) inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it))
) )
@ -446,7 +446,7 @@ internal class LocalEchoEventFactory @Inject constructor(
url = attachment.queryUri.toString(), url = attachment.queryUri.toString(),
relatesTo = rootThreadEventId?.let { relatesTo = rootThreadEventId?.let {
RelationDefaultContent( RelationDefaultContent(
type = RelationType.IO_THREAD, type = RelationType.THREAD,
eventId = it, eventId = it,
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it)) inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it))
) )
@ -479,7 +479,7 @@ internal class LocalEchoEventFactory @Inject constructor(
private fun enhanceStickerIfNeeded(type: String, content: Content?): Content? { private fun enhanceStickerIfNeeded(type: String, content: Content?): Content? {
var newContent: Content? = null var newContent: Content? = null
if (type == EventType.STICKER) { if (type == EventType.STICKER) {
val isThread = (content.toModel<MessageStickerContent>())?.relatesTo?.type == RelationType.IO_THREAD val isThread = (content.toModel<MessageStickerContent>())?.relatesTo?.type == RelationType.THREAD
val rootThreadEventId = (content.toModel<MessageStickerContent>())?.relatesTo?.eventId val rootThreadEventId = (content.toModel<MessageStickerContent>())?.relatesTo?.eventId
if (isThread && rootThreadEventId != null) { if (isThread && rootThreadEventId != null) {
val newRelationalDefaultContent = (content.toModel<MessageStickerContent>())?.relatesTo?.copy( val newRelationalDefaultContent = (content.toModel<MessageStickerContent>())?.relatesTo?.copy(
@ -579,7 +579,7 @@ internal class LocalEchoEventFactory @Inject constructor(
private fun generateReplyRelationContent(eventId: String, rootThreadEventId: String? = null, showAsReply: Boolean): RelationDefaultContent = private fun generateReplyRelationContent(eventId: String, rootThreadEventId: String? = null, showAsReply: Boolean): RelationDefaultContent =
rootThreadEventId?.let { rootThreadEventId?.let {
RelationDefaultContent( RelationDefaultContent(
type = RelationType.IO_THREAD, type = RelationType.THREAD,
eventId = it, eventId = it,
inReplyTo = ReplyToContent(eventId = eventId, renderIn = if (showAsReply) arrayListOf("m.thread") else null)) inReplyTo = ReplyToContent(eventId = eventId, renderIn = if (showAsReply) arrayListOf("m.thread") else null))
} ?: RelationDefaultContent(null, null, ReplyToContent(eventId = eventId)) } ?: RelationDefaultContent(null, null, ReplyToContent(eventId = eventId))

View File

@ -58,7 +58,7 @@ fun TextContent.toThreadTextContent(
format = MessageFormat.FORMAT_MATRIX_HTML.takeIf { formattedText != null }, format = MessageFormat.FORMAT_MATRIX_HTML.takeIf { formattedText != null },
body = text, body = text,
relatesTo = RelationDefaultContent( relatesTo = RelationDefaultContent(
type = RelationType.IO_THREAD, type = RelationType.THREAD,
eventId = rootThreadEventId, eventId = rootThreadEventId,
inReplyTo = ReplyToContent( inReplyTo = ReplyToContent(
eventId = latestThreadEventId eventId = latestThreadEventId

View File

@ -332,7 +332,7 @@ internal class ThreadsAwarenessHandler @Inject constructor(
.findAll() .findAll()
cacheEventRootId.add(rootThreadEventId) cacheEventRootId.add(rootThreadEventId)
return threadList.filter { return threadList.filter {
it.asDomain().getRelationContentForType(RelationType.IO_THREAD)?.inReplyTo?.eventId == currentEventId it.asDomain().getRelationContentForType(RelationType.THREAD)?.inReplyTo?.eventId == currentEventId
} }
} }
@ -350,7 +350,7 @@ internal class ThreadsAwarenessHandler @Inject constructor(
* @param event * @param event
*/ */
private fun isThreadEvent(event: Event): Boolean = private fun isThreadEvent(event: Event): Boolean =
event.content.toModel<MessageRelationContent>()?.relatesTo?.type == RelationType.IO_THREAD event.content.toModel<MessageRelationContent>()?.relatesTo?.type == RelationType.THREAD
/** /**
* Returns the root thread eventId or null otherwise * Returns the root thread eventId or null otherwise

View File

@ -506,7 +506,7 @@ class TimelineViewModel @AssistedInject constructor(
private fun handleSendSticker(action: RoomDetailAction.SendSticker) { private fun handleSendSticker(action: RoomDetailAction.SendSticker) {
val content = initialState.rootThreadEventId?.let { val content = initialState.rootThreadEventId?.let {
action.stickerContent.copy(relatesTo = RelationDefaultContent(RelationType.IO_THREAD, it)) action.stickerContent.copy(relatesTo = RelationDefaultContent(RelationType.THREAD, it))
} ?: action.stickerContent } ?: action.stickerContent
room.sendEvent(EventType.STICKER, content.toContent()) room.sendEvent(EventType.STICKER, content.toContent())