kongo2002 / ejabberd-mod-mam

Message Archive Management (XEP-0313) for ejabberd using a MongoDB backend
23 stars 10 forks source link

<before> tag works incorrect? #6

Closed DarkSideF closed 8 years ago

DarkSideF commented 9 years ago

Hi, Blank tag in your module works perfect, but with specified ID is return result from wrong order (not as described in http://xmpp.org/extensions/xep-0059.html#backwards)

example:

<iq xmlns="jabber:client" type="get" id="la"><query xmlns="urn:xmpp:mam:tmp"><with>user-6@ch</with><set xmlns="http://jabber.org/protocol/rsm"><max>2</max><before/></set></query></iq></body>

i receive some messages and tag like this:

<set xmlns='http://jabber.org/protocol/rsm'><first>54BD089D1E374104EF000026</first><last>54BD08A81E374104EF000028</last><count>2</count></set>

in server logs we may see order is right:

...
>@mod_mam:find:741 Query: {'$query',{'j.u',<<"user-6">>,'j.s',<<"ch">>,u,<<"user-1">>},'$orderby',{'_id',-1}}

and if i trying to get previous

<iq xmlns="jabber:client" type="get" id="la2"><query xmlns="urn:xmpp:mam:tmp"><with>user-6@ch</with><set xmlns="http://jabber.org/protocol/rsm"><max>1</max><before>54BD089D1E374104EF000026</before></set></query></iq

its return to me first messages of all history

in server logs i may see order is wrong:

...
@mod_mam:find:745 Query: {'$query',{'j.u',<<"user-6">>,'j.s',<<"ch">>,u,<<"user-1">>},'$orderby',{'_id',1}}
kongo2002 commented 9 years ago

Hi, thanks for the detailed report! I will look into this bug as soon as possible.

Just out of interest, how do you test the module right now? I am always searching for a convenient way to test these kind of messages.

Cheers, Gregor

DarkSideF commented 9 years ago

I use Сlient for my site written on JavaScript and based on JSJaC (https://github.com/sstrigler/JSJaC) You may use Jappix client (https://github.com/jappix/jappix) with mod_mam support for it. Jappix also based on JSJaC

For view incoming queries and server responses i use Chrome dev tools or for example Fiddler

Thanks!

kevb commented 9 years ago

DarkSideF - I noticed you've forked and made some commits (https://github.com/DarkSideF/ejabberd/commit/18c8281e6e0fa6f8fc950adf59c1dda3e4d22afa)

Did you have any luck figuring it out?

We are also seeing both bugs as described:

1) Specifying value in query causes tag to be ignored and order to default to ascending.

2) Specifying a value for , e.g. 54BD089D1E374104EF000026 results in oldest page of messages rather than next newest page.

Would very much appreciate a fix if you have the time : )

kevb commented 9 years ago

Also just want to point out that in DarkSideFs second example

<iq xmlns="jabber:client" type="get" id="la2"><query xmlns="urn:xmpp:mam:tmp"><with>user-6@ch</with><set xmlns="http://jabber.org/protocol/rsm"><max>1</max><before>54BD089D1E374104EF000026</before></set></query></iq>

Results in not just the the wrong sort order in the mongodb query, but also it is missing a condition to say (I think) _id < ObjectId("54BD089D1E374104EF000026")

I can see that DarkSideF attempted to fix the sort order in his own branch but it doesn't add the _id < x condition. I don't know how to do this myself, my Erlang skills are poor : )

DarkSideF commented 9 years ago

Hi Kevin, Unfortunately I do not have sufficient knowledge of Erlang that would fix this problem.

I am aware that recently came a version of mod_mam based on Mnesia DB from ejabberd developers: https://github.com/processone/ejabberd-contrib/tree/master/mod_mam Soon I will install it and see how it works.

kevb commented 9 years ago

Is anyone making any progress on this? I tried my hand at the Erlang but just haven't been able to make it work (I think I'm just not quite understanding Erlang!).

I'd love to be able to use this in my app, but I can't find an Erlang dev to help me :)

kongo2002 commented 9 years ago

Hi, sadly I haven't found some spare time to fix this one yet, but it isn't forgotten 😉

Cheers Gregor

kongo2002 commented 8 years ago

I just pushed a fix for this issue along with a migration to ejabberd version 15. Please give it a try with the latest master.

kongo2002 commented 8 years ago

In case the wrong RSM behavior persists please reopen the issue.