fix: add file IDs to request parameters for message send (#940)

This commit is contained in:
Harris 2022-08-15 16:54:15 +10:00 committed by GitHub
parent 865a69c49f
commit 7dcb566a57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -404,12 +404,19 @@ object OpenGroupApi {
fileIds: List<String>? = null
): Promise<OpenGroupMessage, Exception> {
val signedMessage = message.sign(room, server, fallbackSigningType = IdPrefix.STANDARD) ?: return Promise.ofFail(Error.SigningFailed)
val parameters = signedMessage.toJSON().toMutableMap()
// add file IDs if there are any (from attachments)
if (!fileIds.isNullOrEmpty()) {
parameters += "files" to fileIds
}
val request = Request(
verb = POST,
room = room,
server = server,
endpoint = Endpoint.RoomMessage(room),
parameters = signedMessage.toJSON()
parameters = parameters
)
return getResponseBodyJson(request).map { json ->
@Suppress("UNCHECKED_CAST") val rawMessage = json as? Map<String, Any>