Allow "replying" to an event with a file
Send a pseudo-reply consisting of two messages: a `m.text` which is just a reply with an empty body, then the file event itself. This is a workaround to the restriction imposed by the Matrix API, which prevents us from simply attaching a reply to a media event: https://matrix.org/docs/spec/client_server/latest#rich-replies
This commit is contained in:
@@ -6,8 +6,11 @@ import Qt.labs.platform 1.1
|
||||
HFileDialogOpener {
|
||||
property string userId
|
||||
property string roomId
|
||||
property string replyToEventId: ""
|
||||
property bool destroyWhenDone: false
|
||||
|
||||
signal replied()
|
||||
|
||||
|
||||
fill: false
|
||||
dialog.title: qsTr("Select a file to send")
|
||||
@@ -16,14 +19,17 @@ HFileDialogOpener {
|
||||
onFilesPicked: {
|
||||
for (const file of files) {
|
||||
const path = Qt.resolvedUrl(file).replace(/^file:/, "")
|
||||
const args = [roomId, path, replyToEventId || undefined]
|
||||
|
||||
py.callClientCoro(userId, "send_file", [roomId, path], () => {
|
||||
py.callClientCoro(userId, "send_file", args, () => {
|
||||
if (destroyWhenDone) destroy()
|
||||
|
||||
}, (type, args, error, traceback) => {
|
||||
console.error(`python:\n${traceback}`)
|
||||
if (destroyWhenDone) destroy()
|
||||
})
|
||||
|
||||
if (replyToUserId) replied()
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user