paulfariello / aparte

Simple XMPP console client written in Rust and inspired by Profanity.
Mozilla Public License 2.0
124 stars 16 forks source link

Add support for last message correction #11

Closed paulfariello closed 7 months ago

paulfariello commented 3 years ago

Add support for https://xmpp.org/extensions/xep-0308.html.

Easy impl could be done directly in core.rs handle_message. But the same issue will arise when doing OMEMO and we definitely don't want to handle all OMEMO in core.rs. It's a good opportunity to review the message processing workflow.

Implementation of plugin that support messages with body (LMC, OMEMO, etc) requires that handling of such message has to either:

First solution, requires to be able to share handle_message code in a way and that we can avoid the creation of Message event from the core if the RawMessage has been consumed by any plugin. This is hard (impossible?) since message handling in core is already inside the event loop, when scheduling RawMessage. So it requires to move handle_message in it's own plugin. And to ensure it is called last.

Second solution imply handle_message is called after the event are consumed, again this requires to move handle_message in it's own plugin. And that we can ensure the order of the plugin (LMC before Message, OMEMO before LMC before Message, …)

paulfariello commented 3 years ago

Could also imagine a way for plugin to register to message parsing given a callback that can return a matching value, higher value is choosen first.