psi-im / iris

XMPP network library
GNU Lesser General Public License v2.1
50 stars 25 forks source link

MAM: rough draft #73

Closed mcneb10 closed 3 weeks ago

mcneb10 commented 3 months ago

Here is my take on the MAM implementation so far

Neustradamus commented 2 months ago

Good to see the @mcneb10 PR :)

mcneb10 commented 2 months ago

@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?
Ri0n commented 2 months ago

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.

mcneb10 commented 2 months ago

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 commented 2 months ago

@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.

Neustradamus commented 2 months ago

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

Ri0n commented 2 months ago

@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.
Neustradamus commented 2 months ago

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

mcneb10 commented 2 months ago

@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 commented 2 months ago

@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 commented 2 months ago

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

mcneb10 commented 1 month ago

Im going to see if i can finish this up

mcneb10 commented 1 month ago

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

Neustradamus commented 1 month ago

@Ri0n: Can you check?

mcneb10 commented 1 month ago

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

Ri0n commented 3 weeks ago

fixed in mam branch

mcneb10 commented 3 weeks ago

Thank you for the fix! This is very exciting.

Neustradamus commented 3 weeks ago

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

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

Can wait next parts ^^

mcneb10 commented 3 weeks ago

I'd say it needs testing first