I've attached a patch for XMPP message correction as defined in XEP-308.
Here is a very high-level overview of the changes:
- MessageCorrectionExtension - represents the XMPP extension,
- ...Provider - parses an XML extension and creates a MCE from it,
- OperationSetMessageCorrection with a single method correctMessage.
The received XMPP messages are now created with the ID of the packet; and
the ID of the packet when sending messages is set to the ID of the message.
There are a bunch of changes in various places in order to propagate the
ID's from the UI to the network and vice versa - they are needed when
identifying which message to edit.
This implementation only has UI for editing the last sent message.
In ChatPanel.java: the ID of the last sent message (in order to be able to
edit it) and the currently corrected message, if any, are stored.
- The message ID is added to the HTML in order to be able to find the old
message when trying to replace it.
- A tag with the format <cite id="messageID-editedAt"></cite> is added for
every message as a placeholder for an "Edited at …" message. If it is
corrected, it's replaced with <cite id="newMessageID-editedAt">Edited at
…</cite>. A cite tag is used because an inline one is needed in order for
the text not to wrap on a newline, and most of the other inline tags are
problematic when used in setOuterHTML.
- If UP arrow is pressed when the write area is empty and the protocol
supports message corrections, starts editing last message.
- If DOWN arrow is pressed, currently editing a message and cursor is
after the last position of the text in the write area, stop editing.
Tested with multiple XMPP accounts in Jitsi - message corrections are shown
on both the sending and receiving side correctly.
Tested with the latest version of Swift - works fine. (The official Beta
sends and receives correction packages with their own namespace, but that's
fixed in dev.)
Gmail shows corrections as new messages - as expected.
That's my first patch here, and it got a bit long, so I hope I got
everything (or, at least, most of the things) right Let me know if you
need more info on the code.
messageCorrection.txt (64.3 KB)