mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Merge pull request #3124 from vector-im/feature/bma/fix_readMarker
Fix mandatory parameter in API (#3065)
This commit is contained in:
commit
f7f7994685
3 changed files with 19 additions and 3 deletions
|
@ -22,6 +22,7 @@ Bugfix 🐛:
|
|||
- Handle encrypted reactions (#2509)
|
||||
- Disable URL preview for some domains (#2995)
|
||||
- Fix avatar rendering for DMs, after initial sync (#2693)
|
||||
- Fix mandatory parameter in API (#3065)
|
||||
|
||||
Translations 🗣:
|
||||
-
|
||||
|
|
|
@ -153,6 +153,14 @@ internal interface RoomAPI {
|
|||
suspend fun sendReadMarker(@Path("roomId") roomId: String,
|
||||
@Body markers: Map<String, String>)
|
||||
|
||||
/**
|
||||
* Send receipt to a room
|
||||
*/
|
||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/receipt/{receiptType}/{eventId}")
|
||||
suspend fun sendReceipt(@Path("roomId") roomId: String,
|
||||
@Path("receiptType") receiptType: String,
|
||||
@Path("eventId") eventId: String)
|
||||
|
||||
/**
|
||||
* Invite a user to the given room.
|
||||
* Ref: https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-invite
|
||||
|
|
|
@ -62,7 +62,7 @@ internal class DefaultSetReadMarkersTask @Inject constructor(
|
|||
) : SetReadMarkersTask {
|
||||
|
||||
override suspend fun execute(params: SetReadMarkersTask.Params) {
|
||||
val markers = HashMap<String, String>()
|
||||
val markers = mutableMapOf<String, String>()
|
||||
Timber.v("Execute set read marker with params: $params")
|
||||
val latestSyncedEventId = latestSyncedEventId(params.roomId)
|
||||
val fullyReadEventId = if (params.forceReadMarker) {
|
||||
|
@ -100,7 +100,14 @@ internal class DefaultSetReadMarkersTask @Inject constructor(
|
|||
globalErrorReceiver,
|
||||
canRetry = true
|
||||
) {
|
||||
roomAPI.sendReadMarker(params.roomId, markers)
|
||||
if (markers[READ_MARKER] == null) {
|
||||
if (readReceiptEventId != null) {
|
||||
roomAPI.sendReceipt(params.roomId, READ_RECEIPT, readReceiptEventId)
|
||||
}
|
||||
} else {
|
||||
// "m.fully_read" value is mandatory to make this call
|
||||
roomAPI.sendReadMarker(params.roomId, markers)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +117,7 @@ internal class DefaultSetReadMarkersTask @Inject constructor(
|
|||
TimelineEventEntity.latestEvent(realm, roomId = roomId, includesSending = false)?.eventId
|
||||
}
|
||||
|
||||
private suspend fun updateDatabase(roomId: String, markers: HashMap<String, String>, shouldUpdateRoomSummary: Boolean) {
|
||||
private suspend fun updateDatabase(roomId: String, markers: Map<String, String>, shouldUpdateRoomSummary: Boolean) {
|
||||
monarchy.awaitTransaction { realm ->
|
||||
val readMarkerId = markers[READ_MARKER]
|
||||
val readReceiptId = markers[READ_RECEIPT]
|
||||
|
|
Loading…
Reference in a new issue