iris icon indicating copy to clipboard operation
iris copied to clipboard

MAM: rough draft

Open mcneb10 opened this issue 1 year ago • 11 comments

Here is my take on the MAM implementation so far

mcneb10 avatar Jul 06 '24 01:07 mcneb10

Good to see the @mcneb10 PR :)

Neustradamus avatar Jul 11 '24 20:07 Neustradamus

@Ri0n This PR is almost ready. I do have a few questions though.

  1. How will I test my code?
  2. Should I write a Manager wrapper class around the task?

mcneb10 avatar Jul 14 '24 19:07 mcneb10

wrt testing Psi part is not ready yet, but Psi can load history from local db. So we need some code in Psi which will sync MAM with local db, It will be the first step. If you want to test something right in iris, I believe you need to write tests yourself. Psi has miniclient which can be ported to some integration tests in iris.

Manager sounds like a good idea, having API most suitable to be used by local db synchronizer. Like querying messages is just the first step and eventually it will have a lot of MAM control methods.

Ri0n avatar Jul 14 '24 20:07 Ri0n

alright, i'll add a MAMManager class that simplifies creating querying the MAM archives. As for the testing, I'll try to write a small plugin or patch or something to test the querying

mcneb10 avatar Jul 14 '24 20:07 mcneb10

@Ri0n if it doesn't bother you, can you help me out by modifying a Psi+ plugin or something to test my code? I'm not familiar with the Psi+ codebase, and some other recent changes to Iris are preventing Psi+ from compiling.

mcneb10 avatar Jul 18 '24 04:07 mcneb10

@Ri0n: Really important to finish this XEP support...

Neustradamus avatar Jul 18 '24 10:07 Neustradamus

@mcneb10, that was my plan. I changed my job a few days ago and now completely consume by it. So I can't promise any quick solution. I have some ideas in mind though.

  1. from UI point of view endless chat scrolling must be supported
  2. we need a sort of message buffer per chat. A buffer which keeps for example max 200 messages. It becomes a sort of model for chatview
  3. the model should be signalled from chatview when it needs to loads more messages (more recent or more old)
  4. the model should signal back its busy status
  5. the model queries some sort of Psi's storage/archive manager capable to interact with both local database and iris' mam manager
  6. the manager will detect which exactly time spans are missed in the local db and query iris to retrieve the remaining
  7. local db itself has to be modified to reflect MAM use case and also to keep track of missed time spans (e.g. a message/event can have a state like "edge event" when it was first or last in the result set unless we query from a boundary of another set)
  8. wrt iris. it would be nice to have some methods in the manager like for example loadBeforeStanzaId(string stanzaId, int limit=100) and loadAfterStanzaId. This would secure the endless scrolling more carefully than timestamps.

Ri0n avatar Jul 18 '24 13:07 Ri0n

@mcneb10: What do you think about @Ri0n comment?

Neustradamus avatar Jul 20 '24 12:07 Neustradamus

@mcneb10: What do you think about @Ri0n comment?

I'm not available to work right now, but i did add some of the changes rion requested. I'll push them in a day or two

mcneb10 avatar Jul 20 '24 18:07 mcneb10

@Ri0n i just added the code to iris which should serve the function of what you want in point 8. The two functions getLatestMessagesFromArchive and getMessagesBeforeID i added always scroll backwards, meaning they send the messages in the order of newest to oldest. The other functions have a configurable direction (set both flipPages and backwards to false and it will get messages in oldest to newest order).

As for only fetching messages in a specific time frame, you can simply do getArchiveByTimeRange and set the from to QDateTime() and to to a specific time to get all messages up to a specific point, respecting the order set in the manager constructor. It also applies the other way, so if you set to to QDateTime() and from to a specific time it will get all messages starting at the time you set until the latest message.

mcneb10 avatar Jul 22 '24 00:07 mcneb10

I'm going to be pretty busy for a while. I won't fix these issues for a few weeks

mcneb10 avatar Aug 01 '24 03:08 mcneb10

Im going to see if i can finish this up

mcneb10 avatar Aug 31 '24 18:08 mcneb10

I will not be able to get anywhere near finishing this code until there is a mechanism added somewhere in Psi+ to call my code

mcneb10 avatar Aug 31 '24 20:08 mcneb10

@Ri0n: Can you check?

Neustradamus avatar Aug 31 '24 20:08 Neustradamus

It's important to know that the latest version of iris does not compile with Psi+ due to some changes to the carbons code

mcneb10 avatar Aug 31 '24 20:08 mcneb10

fixed in mam branch

Ri0n avatar Sep 11 '24 20:09 Ri0n

Thank you for the fix! This is very exciting.

mcneb10 avatar Sep 11 '24 21:09 mcneb10

@mcneb10: Good job, an important part has been done!

Thanks @Ri0n for merging, but why not in master?

Can wait next parts ^^

Neustradamus avatar Sep 11 '24 21:09 Neustradamus

I'd say it needs testing first

mcneb10 avatar Sep 11 '24 21:09 mcneb10

A new XEP-0313 version has been released - 1.1.2 (2024-09-18):

  • https://xmpp.org/extensions/xep-0313.html
  • https://www5.aptest.com/standards/htmldiff/htmldiff.pl?oldfile=https://xmpp.org/extensions/attic/xep-0313-1.1.1.html&newfile=https://xmpp.org/extensions/attic/xep-0313-1.1.2.html

It is good?

Neustradamus avatar Nov 10 '24 04:11 Neustradamus

Since the good work done by @mcneb10:

  • https://github.com/psi-im/iris/pull/73

And after XEP-0313 1.1.2 (2024-09-18), a new XEP-0313 version has been released - 1.1.3 (2025-04-09):

  • https://xmpp.org/extensions/xep-0313.html
  • https://www5.aptest.com/standards/htmldiff/htmldiff.pl?oldfile=https://xmpp.org/extensions/attic/xep-0313-1.1.2.html&newfile=https://xmpp.org/extensions/attic/xep-0313-1.1.3.html
  • https://www5.aptest.com/standards/htmldiff/htmldiff.pl?oldfile=https://xmpp.org/extensions/attic/xep-0313-1.1.1.html&newfile=https://xmpp.org/extensions/attic/xep-0313-1.1.2.html

Neustradamus avatar Aug 21 '25 22:08 Neustradamus