mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 01:55:04 +08:00
Thread awareness, map threads events to replies
This commit is contained in:
parent
8f0074911a
commit
d1f3e3f958
@ -363,11 +363,18 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle
|
||||
}
|
||||
eventIds.add(event.eventId)
|
||||
|
||||
if (event.isEncrypted() && insertType != EventInsertType.INITIAL_SYNC) {
|
||||
val isInitialSync = insertType == EventInsertType.INITIAL_SYNC
|
||||
|
||||
if (event.isEncrypted() && !isInitialSync) {
|
||||
decryptIfNeeded(event, roomId)
|
||||
}
|
||||
|
||||
threadsAwarenessHandler.handleIfNeeded(realm, roomId, event, ::decryptIfNeeded)
|
||||
threadsAwarenessHandler.handleIfNeeded(
|
||||
realm = realm,
|
||||
roomId = roomId,
|
||||
event = event,
|
||||
isInitialSync = isInitialSync,
|
||||
::decryptIfNeeded)
|
||||
|
||||
val ageLocalTs = event.unsignedData?.age?.let { syncLocalTimestampMillis - it }
|
||||
val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, insertType)
|
||||
|
@ -41,7 +41,7 @@ import javax.inject.Inject
|
||||
/**
|
||||
* This handler is responsible for a smooth threads migration. It will map all incoming
|
||||
* threads as replies. So a device without threads enabled/updated will be able to view
|
||||
* threads response as replies to the orighinal message
|
||||
* threads response as replies to the original message
|
||||
*/
|
||||
internal class ThreadsAwarenessHandler @Inject constructor(
|
||||
private val permalinkFactory: PermalinkFactory
|
||||
@ -50,6 +50,7 @@ internal class ThreadsAwarenessHandler @Inject constructor(
|
||||
fun handleIfNeeded(realm: Realm,
|
||||
roomId: String,
|
||||
event: Event,
|
||||
isInitialSync: Boolean,
|
||||
decryptIfNeeded: (event: Event, roomId: String) -> Unit) {
|
||||
|
||||
if (!isThreadEvent(event)) return
|
||||
@ -60,9 +61,8 @@ internal class ThreadsAwarenessHandler @Inject constructor(
|
||||
val rootThreadEventEntity = EventEntity.where(realm, eventId = rootThreadEventId).findFirst() ?: return
|
||||
val rootThreadEvent = EventMapper.map(rootThreadEventEntity)
|
||||
val rootThreadEventSenderId = rootThreadEvent.senderId ?: return
|
||||
val rootThreadEventEventId = rootThreadEvent.eventId ?: return
|
||||
|
||||
Timber.i("------> Thread event detected!")
|
||||
Timber.i("------> Thread event detected! - isInitialSync: $isInitialSync")
|
||||
|
||||
if (rootThreadEvent.isEncrypted()) {
|
||||
decryptIfNeeded(rootThreadEvent, roomId)
|
||||
@ -70,7 +70,7 @@ internal class ThreadsAwarenessHandler @Inject constructor(
|
||||
|
||||
val rootThreadEventBody = getValueFromPayload(rootThreadEvent.mxDecryptionResult?.payload?.toMutableMap(),"body")
|
||||
|
||||
val permalink = permalinkFactory.createPermalink(roomId, rootThreadEventEventId, false)
|
||||
val permalink = permalinkFactory.createPermalink(roomId, rootThreadEventId, false)
|
||||
val userLink = permalinkFactory.createPermalink(rootThreadEventSenderId, false) ?: ""
|
||||
|
||||
val replyFormatted = LocalEchoEventFactory.REPLY_PATTERN.format(
|
||||
|
Loading…
Reference in New Issue
Block a user