Merge branch 'develop' into yostyle/notifications_global_settings

This commit is contained in:
David Langley 2023-08-30 16:55:35 +01:00 committed by GitHub
commit ccd5f6aaa2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 215 additions and 32 deletions

View file

@ -161,6 +161,22 @@ interface MatrixRoom : Closeable {
pollKind: PollKind,
): Result<Unit>
/**
* Send a response to a poll.
*
* @param pollStartId The event ID of the poll start event.
* @param answers The list of answer ids to send.
*/
suspend fun sendPollResponse(pollStartId: EventId, answers: List<String>): Result<Unit>
/**
* Ends a poll in the room.
*
* @param pollStartId The event ID of the poll start event.
* @param text Fallback text of the poll end event.
*/
suspend fun endPoll(pollStartId: EventId, text: String): Result<Unit>
override fun close() = destroy()
}

View file

@ -23,7 +23,8 @@ val oidcConfiguration: OidcConfiguration = OidcConfiguration(
clientName = "Element",
redirectUri = OidcConfig.redirectUri,
clientUri = "https://element.io",
tosUri = "https://element.io/user-terms-of-service",
logoUri = "https://element.io/mobile-icon.png",
tosUri = "https://element.io/acceptable-use-policy-terms",
policyUri = "https://element.io/privacy",
/**
* Some homeservers/auth issuers don't support dynamic client registration, and have to be registered manually

View file

@ -239,7 +239,7 @@ class RustMatrixRoom(
override suspend fun editMessage(originalEventId: EventId?, transactionId: TransactionId?, message: String): Result<Unit> = withContext(roomDispatcher) {
if (originalEventId != null) {
runCatching {
innerRoom.edit(/* TODO use content */ message, originalEventId.value, transactionId?.value)
innerRoom.edit(messageEventContentFromMarkdown(message), originalEventId.value, transactionId?.value)
}
} else {
runCatching {
@ -250,10 +250,8 @@ class RustMatrixRoom(
}
override suspend fun replyMessage(eventId: EventId, message: String): Result<Unit> = withContext(roomDispatcher) {
val transactionId = genTransactionId()
// val content = messageEventContentFromMarkdown(message)
runCatching {
innerRoom.sendReply(/* TODO use content */ message, eventId.value, transactionId)
innerRoom.sendReply(messageEventContentFromMarkdown(message), eventId.value, genTransactionId())
}
}
@ -426,6 +424,32 @@ class RustMatrixRoom(
}
}
override suspend fun sendPollResponse(
pollStartId: EventId,
answers: List<String>
): Result<Unit> = withContext(roomDispatcher) {
runCatching {
innerRoom.sendPollResponse(
pollStartId = pollStartId.value,
answers = answers,
txnId = genTransactionId(),
)
}
}
override suspend fun endPoll(
pollStartId: EventId,
text: String
): Result<Unit> = withContext(roomDispatcher) {
runCatching {
innerRoom.endPoll(
pollStartId = pollStartId.value,
text = text,
txnId = genTransactionId(),
)
}
}
private suspend fun sendAttachment(files: List<File>, handle: () -> SendAttachmentJoinHandle): Result<MediaUploadHandler> {
return runCatching {
MediaUploadHandlerImpl(files, handle())

View file

@ -87,6 +87,8 @@ class FakeMatrixRoom(
private var reportContentResult = Result.success(Unit)
private var sendLocationResult = Result.success(Unit)
private var createPollResult = Result.success(Unit)
private var sendPollResponseResult = Result.success(Unit)
private var endPollResult = Result.success(Unit)
private var progressCallbackValues = emptyList<Pair<Long, Long>>()
val editMessageCalls = mutableListOf<String>()
@ -111,6 +113,12 @@ class FakeMatrixRoom(
private val _createPollInvocations = mutableListOf<CreatePollInvocation>()
val createPollInvocations: List<CreatePollInvocation> = _createPollInvocations
private val _sendPollResponseInvocations = mutableListOf<SendPollResponseInvocation>()
val sendPollResponseInvocations: List<SendPollResponseInvocation> = _sendPollResponseInvocations
private val _endPollInvocations = mutableListOf<EndPollInvocation>()
val endPollInvocations: List<EndPollInvocation> = _endPollInvocations
var invitedUserId: UserId? = null
private set
@ -329,6 +337,22 @@ class FakeMatrixRoom(
return createPollResult
}
override suspend fun sendPollResponse(
pollStartId: EventId,
answers: List<String>
): Result<Unit> = simulateLongTask {
_sendPollResponseInvocations.add(SendPollResponseInvocation(pollStartId, answers))
return sendPollResponseResult
}
override suspend fun endPoll(
pollStartId: EventId,
text: String
): Result<Unit> = simulateLongTask {
_endPollInvocations.add(EndPollInvocation(pollStartId, text))
return endPollResult
}
fun givenLeaveRoomError(throwable: Throwable?) {
this.leaveRoomError = throwable
}
@ -425,6 +449,14 @@ class FakeMatrixRoom(
createPollResult = result
}
fun givenSendPollResponseResult(result: Result<Unit>) {
sendPollResponseResult = result
}
fun givenEndPollResult(result: Result<Unit>) {
endPollResult = result
}
fun givenProgressCallbackValues(values: List<Pair<Long, Long>>) {
progressCallbackValues = values
}
@ -444,3 +476,13 @@ data class CreatePollInvocation(
val maxSelections: Int,
val pollKind: PollKind,
)
data class SendPollResponseInvocation(
val pollStartId: EventId,
val answers: List<String>,
)
data class EndPollInvocation(
val pollStartId: EventId,
val text: String,
)