Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error starting escalus story when user have offline messages #197

Open
pdorofiejczyk opened this issue Dec 21, 2018 · 3 comments
Open

Error starting escalus story when user have offline messages #197

pdorofiejczyk opened this issue Dec 21, 2018 · 3 comments

Comments

@pdorofiejczyk
Copy link

pdorofiejczyk commented Dec 21, 2018

I'm trying to test offline messages using escalus. When I'm trying to start escalus story for user who have offline messages, I'm getting following error:

     ** (ErlangError) Erlang error: {:assertion_failed, :assert, :is_presence, {:xmlel, "message", [{"xml:lang", "en"}, {"to", "[email protected]/res1"}, {"from", "[email protected]/res1"}], [{:xmlel, "archived", [{"by", "[email protected]"}, {"id", "8512ba7a-04fd-11e9-bc0e-69dacdbc2072"}, {"xmlns", "urn:xmpp:mam:tmp"}], []}, {:xmlel, "stanza-id", [{"by", "[email protected]"}, {"id", "8512ba7a-04fd-11e9-bc0e-69dacdbc2072"}, {"xmlns", "urn:xmpp:sid:0"}], []}, {:xmlel, "seq", [{"id", "2"}, {"xmlns", "urn:message:seq"}], []}, {:xmlel, "delay", [{"from", "example2.com"}, {"stamp", "2018-12-21T08:50:51.830393Z"}, {"xmlns", "urn:xmpp:delay"}], [xmlcdata: "Offline storage"]}, {:xmlel, "body", [], [xmlcdata: "offline message"]}]}, '<message xml:lang=\'en\' to=\'[email protected]/res1\' from=\'[email protected]/res1\'><archived by=\'[email protected]\' id=\'8512ba7a-04fd-11e9-bc0e-69dacdbc2072\' xmlns=\'urn:xmpp:mam:tmp\'/><stanza-id by=\'[email protected]\' id=\'8512ba7a-04fd-11e9-bc0e-69dacdbc2072\' xmlns=\'urn:xmpp:sid:0\'/><seq id=\'2\' xmlns=\'urn:message:seq\'/><delay from=\'example2.com\' stamp=\'2018-12-21T08:50:51.830393Z\' xmlns=\'urn:xmpp:delay\'>Offline storage</delay><body>offline message</body></message>'}

Short investigation shows that escalus story aways wait for presences after starting client (https://github.com/esl/escalus/blob/master/src/escalus_story.erl#L136) but this behaviour is not fully correct in my case.

@michalwski
Copy link
Contributor

Sorry for such a late response. Usually, regular XMPP clients sends initial presence to the server just after establishing the session and waits for the presence reply. This is what escalus_story tries to simulate in https://github.com/esl/escalus/blob/master/src/escalus_story.erl#L133-L134. You can set your own initial_activity if you don't want to send the initial presence.

@pdorofiejczyk
Copy link
Author

It is ok that client sends initial presence. The wrong thing is that escalus waits ONLY for presence reply. It means that server should not send offline messages to client until it send presence reply first. I 'm using ejabberd server version 18.04 and default mod_offline, sends offline messages before presence reply. What's more this behaviour of escalus is not consistent with XEP-0160 (https://xmpp.org/extensions/xep-0160.html).

@michalwski
Copy link
Contributor

I see your point. You can change the way escalus_story behaves by providing other function to initial_activity by setting is in escalus_overrides. Sth like the following should work

[{escalus_overrides, 
  [{initial_activity, [{your_module, your_function}]}]} | Config]

In your function you can stop sending the initial presence, or send it but consume all the offline messages.

Please consult the escalus_overridables module for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants