omemo / gajim-omemo

Gajim plugin for OMEMO Multi-End Message and Object Encryption
87 stars 7 forks source link

Messages stored by MAM while gajim is offline are not shown #36

Closed mapama closed 8 years ago

mapama commented 8 years ago

Steps to reproduce this issue:

Expected behaviour: See the message in the chat history.

Tested with ejabberd 15.10 on Debian Jessie and MAM enabled.

Thanks for the development of this great plugin.

lovetox commented 8 years ago

i cant reproduce this, im on jabber.at

if i go offline, and send a message from my phone using conversations, after i go online with gajim i get a notification with the message.

mapama commented 8 years ago

You're right my steps to reproduce weren't precise enough. I had to exclude the scenario @lovetox described. I think @lovetox scenario is different because there is no other third client catching away the message while gajim is offline. In this case ejabberd stores the message as offline message and deliver it to gajim when coming online.

The situation that didn't work for me is as follows: Bob has two devices, one computer running gajim and one mobile running conversations, gajim is offline while conversations is online. Now Alice sends a message to Bob. Bob receives the message in conversations. Then switches on gajim, but doesn't get the carbon copied message. Without omemo enabled he does. If you would like to test it with one account you have to use a third client. @lovetox could you test this scenario on jabber.at please?

lovetox commented 8 years ago

so do you get the message if gajim and conversations are online in both clients?

also are you using the current branch, or are you using the FTP version 0.4

i cant try this out right now.

mapama commented 8 years ago

Yes if both clients are online I receive the message in both. I am using version 0.4. Right now I can't test it with the current branch.

mapama commented 8 years ago

Ok, tested with the current branch but this doesn't matter. It doesn't work. Tested with two mobile clients running conversations and one client running gajim. Go offline with gajim send a message from one of the mobile clients. The second mobile client receive this message. Go online with gajim but the messages is missed in the chat history.

exul commented 8 years ago

Bob has two devices, one computer running gajim and one mobile running conversations, gajim is offline while conversations is online. Now Alice sends a message to Bob. Bob receives the message in conversations. Then switches on gajim, but doesn't get the carbon copied message.

I can reproduce this on my server that runs prosody:

# dpkg-query -l | grep prosody
ii  prosody                            0.9.4-1~bpo70+1                   amd64        Lightweight Jabber/XMPP server

I logged the output with gajim -l gajim.plugin_system.omemo=DEBUG -v you can see it here: https://gist.github.com/exul/7e751ed9b0b5ff7c5647c998f18c44ca

Gajim version is 0.16.5

If you need an account or more information, just let me know.

amenk commented 8 years ago

I am not sure if the bug is as described.

I have the following case:

Server = Ejabberd with MAM

  1. Go offline in Gajim
  2. Write in Conversations (Android) with OMEMO
  3. Go online in Gajim
  4. Open history in Gajim -> Message is there

But:

If a contact sends the message using Gajim with OMEMO, it is not stored in the MAM (verified using database dump in ejabberd). So it looks like Gajim does not push OMEMO messages to the MAM ?

iNPUTmice commented 8 years ago

So it looks like Gajim does not push OMEMO messages to the MAM ?

I'm not sure if this is related to the rest of the thread but this can be solved by adding the hint to outgoing messages.

amenk commented 8 years ago

[yes, offtopic] Gajim seems to be sending - any clue how that hint can be removed?

iNPUTmice commented 8 years ago

5320144d09002381a9c3ef8ecba34a3c0b301d47 adds the store hint. Not sure if this fixes OPs issue though. (This would require that the sending client in OPs case is gajim)

mapama commented 8 years ago
Go offline in Gajim
Write in Conversations (Android) with OMEMO
Go online in Gajim
Open history in Gajim -> Message is there

Yes, that is not the problem. In this case the OMEMO-message is stored as offline message. As described above the problem occurs if another client is online while gajim is offline. In that case the OMEMO-message is not stored as offline message. But it should be stored via MAM, as it is the case for Non-OMEMO-messages.

amenk commented 8 years ago

I am online also in a second client ...

amenk commented 8 years ago

Thanks for the patch @iNPUTmice - It does not seem to fix the Problem with Gajim - I will have a look at the messages exchanged...

amenk commented 8 years ago

I think the hint has to be outside of the </encrypted> block? See my comparison between what conversations and what gajim sends ... selection_125

iNPUTmice commented 8 years ago

272187ce60df66384ea93bf1db97ed08257cf936

amenk commented 8 years ago

Seems to work! Thank you so much!

mapama commented 8 years ago

I am online also in a second client ...

Strange, in that case the messages don't appear in my chat history in gajim. What could be the problem?

amenk commented 8 years ago

Are you sending from Gajim? Does it work when sending i.e. from Conversations? Then the above patch is for you :D

mapama commented 8 years ago

I tried the patch. But it doesn't help. I am sending from conversations. The recipient is online with conversations and offline with gajim. Going online with gajim, the message is missing in the chat history.

iNPUTmice commented 8 years ago

@mapama What's the chat history? The history in the current chat window or the 'History Manager'?

mapama commented 8 years ago

@iNPUTmice Not the current window. That one I get with Ctrl-H.

lovetox commented 8 years ago

hm seems like my MAM is not working at all gajim querys the server but gets no response at all

<iq xmlns="jabber:client" type="set" id="329">
<query xmlns="urn:xmpp:mam:0" queryid="328">
<x xmlns="jabber:x:data" type="submit">
<field var="FORM_TYPE" type="hidden">
<value>urn:xmpp:mam:0</value>
</field>
</x>
<set xmlns="http://jabber.org/protocol/rsm">
<max>30</max>
<after>1461862207990877</after>
</set>
</query>
</iq>
mapama commented 8 years ago

I can confirm this. It seems that MAM is not working anymore in gajim. I don't understand these strange thing. Even with disabled OMEMO the messages are not stored by MAM.

kalkin commented 8 years ago

If this is a Gajim issue, may be @yann-l can have a look at that?

lovetox commented 8 years ago

it seems jabber.at has a problem with MAM right now they are working on it.

mapama commented 8 years ago

@lovetox did you find out the problem with jabber.at?

lovetox commented 8 years ago

@mapama they had a problem, but its fixed since a few days, does it still not work for you?

lovetox commented 8 years ago

@mapama you are right still not working, but its not jabber.at fault, mam seems to work, the messages come through but the plugin seems to drop them, im looking into this now

iNPUTmice commented 8 years ago

Are MAM messages for the history window even processed trough the normal message hooks?

lovetox commented 8 years ago

no i dont think so, i tested this, and the message never runs to the MessageReiceivedEvent

There is anohter MamMessageReiceivedEvent maybe its that

lovetox commented 8 years ago

yeah thats it, event is mam-message-reiceived

lovetox commented 8 years ago

@mapama if its not to much work for you you could try my branch

https://github.com/lovetox/gajim-omemo/

i included: Fingerprint UI (only shows you the fingerprints for now) You get better notification when OMEMO is disabled or someone writes you unencrypted MAM Messages should work now

if everything works, i plan to make a pull request

mapama commented 8 years ago

Thank you @lovetox MAM is now partially working. The received messages are shown in the history now but not my own carbon copied messages I wrote with conversations. Where do I find the Fingerprint UI?

Thanks a lot for your effort.

lovetox commented 8 years ago

hi i will look into it today or tomorrow, could well be that i missed something

you find it under Plugins -> Omemo -> Configuration select the account, then switch to the fingerprint tab

remember though the buttons "trust" and "untrust" do nothing, every fingerprint is trusted at the moment, even when the UI shows it as false.

lovetox commented 8 years ago

i believe i fixed it https://github.com/lovetox/gajim-omemo/commit/7a7c5c76cb7cf4fce18b41ce428e8612961f34c6

please try it @mapama

mapama commented 8 years ago

Thank you so much @lovetox It seems to work exactly as it should.

lovetox commented 8 years ago

MAM patch is now merged.