gkdr / lurch

XEP-0384: OMEMO Encryption for libpurple.
GNU General Public License v3.0
289 stars 32 forks source link

MAM for "catchup" and offline messages support #24

Open andreygursky opened 7 years ago

andreygursky commented 7 years ago

Any plans to move "MAM for "catchup" and offline messages" from Caveats to TODO?

gkdr commented 7 years ago

Well, I can think of a simple way to do it, but it would really be just a catch-up, e.g. setting time of the last received message as a per-account setting, and then querying the server for messages that arrived since, and then write them into the message window directly. Would such a thing be enough?

andreygursky commented 7 years ago

Oh, sorry, that's way over my head to decide (for now). More detailed description of what and how can go wrong now would be helpful.

gkdr commented 7 years ago

Well, I don't think there is much that can go wrong with what I proposed. I just think that if I claim to implement the MAM XEP, a user would expect more functionality, e.g. loading all past messages (since activation of MAM for that account) instead of just the ones that were sent when the device was offline. This of course does not make much sense with encryption, since a new device won't be able to read the messages anyway.

So there are two possible solutions:

  1. Make a separate, general MAM plugin which contains extended querying functionality for the all archived messages. The problems here are:
    • AFAIK, libpurple stores logs as HTML, so it would be kind of tedious to rewrite the logs. I have seen a plugin for SQLite logs, but I'd have to investigate if they can work together.
    • Weird interface. I don't think there is an event such as "scrolled to the top of the log" for automatic loading of previous messages. So the user will have to manually enter a command to load more of the log, or something.
    • Depending on if I can make libpurple think that it received a message when it didn't (I tried using the internal signals briefly, but it didn't seem to work), this might not work with this plugin at all.
  2. Make a "catchup"/"offline message support" plugin which uses MAM to simply fetch the messages which were sent during the time the client was offline.
    • If I cannot make fake incoming messages to libpurple in a separate plugin, I could also just build this functionality into this plugin. This would only concern the encrypted messages though, as it would be weird if the plugin did something unrelated. But there could also be a separate plugin which does the same for unencrypted messages, I guess.
irfus commented 7 years ago

Just wanted to point out that telegram-purple implements similar functionality where archive messages are fetched from the server and displayed when the account is taken online. It doesn't preserve order in the chat view, but timestamps are displayed correctly. So, while not perfect, this is a sufficient implementation for my needs.