Expose global account data get and set on MatrixClient

MatrixClient had no way to read or write global account data although the
underlying client supports it.

Add getAccountData and setAccountData to the interface and implement them in
RustMatrixClient using the same withContext/runCatchingExceptions idiom as the
neighbouring methods. The content is the raw JSON string the SDK returns and
accepts: event types are open ended, so a typed wrapper belongs to whichever
caller needs one. Scope is limited to global account data; the room level
variant and the change notification APIs can follow when a feature needs them.
This commit is contained in:
hayaksi1
2026-08-09 15:10:00 +03:00
parent 044737a3a7
commit 33bdf968c5
5 changed files with 69 additions and 0 deletions
@@ -124,6 +124,8 @@ class FakeMatrixClient(
private val getJoinedRoomIdsResult: () -> Result<Set<RoomId>> = { Result.success(emptySet()) },
private val getRecentEmojisLambda: () -> Result<List<String>> = { Result.success(emptyList()) },
private val addRecentEmojiLambda: (String) -> Result<Unit> = { Result.success(Unit) },
private val getAccountDataLambda: (String) -> Result<String?> = { lambdaError() },
private val setAccountDataLambda: (String, String) -> Result<Unit> = { _, _ -> lambdaError() },
private val markRoomAsFullyReadResult: (RoomId, EventId) -> Result<Unit> = { _, _ -> lambdaError() },
private val markAllRoomsAsReadResult: () -> Result<Unit> = { Result.success(Unit) },
private val performDatabaseVacuumLambda: () -> Result<Unit> = { lambdaError() },
@@ -407,6 +409,14 @@ class FakeMatrixClient(
return getRecentEmojisLambda()
}
override suspend fun getAccountData(eventType: String): Result<String?> {
return getAccountDataLambda(eventType)
}
override suspend fun setAccountData(eventType: String, content: String): Result<Unit> {
return setAccountDataLambda(eventType, content)
}
override suspend fun markRoomAsFullyRead(roomId: RoomId, eventId: EventId): Result<Unit> {
return markRoomAsFullyReadResult(roomId, eventId)
}