slice / black-hole

XMPP ↔ Discord bridge in Python 3
12 stars 3 forks source link

Support edited XMPP messages #9

Closed lun-4 closed 3 years ago

lun-4 commented 4 years ago

Currently, when an XMPP message is edited, we get a new message with an edited flag, but since the bridge code is unaware of that, it forwards it up to Discord without any flag of sorts. aioxmpp got support for that edited flag but investigation is required to see how do we access that flag.

@vvvvvvivi told me that webhooks now support PATCH, and I can see other people in the Discord API server also talking about it, so it looks legit enough. There aren't any docs, but Mason confirmed the feature: append /messages/{message_id} and watch the magic happen.

Implementation details are dependent on how aioxmpp provides edit info to us. If it's just a flag, I'm not sure how we could do it, but if it provides the old message content, we could create an in-memory dict of (jid, content) => message_id, do a lookup, patch, delete old key, add new key.

Keep in mind this does not equate to supporting edited Discord messages back to XMPP.

lun-4 commented 4 years ago

Messages have IDs, you can use the in the dict, see https://xmpp.org/extensions/xep-0308.html#usecase