Allow polls to be edited (#1869)

Polls can be edited if they do not have any votes

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
jonnyandrew 2023-11-24 16:47:58 +00:00 committed by GitHub
parent 4e52244b86
commit 8fcec4a006
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 827 additions and 173 deletions

View file

@ -477,6 +477,30 @@ class RustMatrixRoom(
}
}
override suspend fun editPoll(
pollStartId: EventId,
question: String,
answers: List<String>,
maxSelections: Int,
pollKind: PollKind,
): Result<Unit> = withContext(roomDispatcher) {
runCatching {
val pollStartEvent =
innerRoom.getEventTimelineItemByEventId(
eventId = pollStartId.value
)
pollStartEvent.use {
innerRoom.editPoll(
question = question,
answers = answers,
maxSelections = maxSelections.toUByte(),
pollKind = pollKind.toInner(),
editItem = pollStartEvent,
)
}
}
}
override suspend fun sendPollResponse(
pollStartId: EventId,
answers: List<String>