psi-im / plugins

Officially supported Psi plugins
57 stars 24 forks source link

[Conference Logger, OMEMO] Logging in OMEMO-encrypted conferences not working correctly #93

Closed kssytsrk closed 3 years ago

kssytsrk commented 3 years ago

The Conference Logger plugin does not seem to work with an OMEMO-encrypted MUC/groupchat. It does log messages, but is unable to decrypt them (they decrypted fine when I received them): psipluslogging

AFAIK Profanity and Gaijim don't support logs of OMEMO-encrypted MUCs either (or at least not out-of-the-box), but the Conversations client for Android does. Are there perhaps any workarounds for this problem (aside from copy+paste by hand)? If not, in theory, could an "OMEMO conference logger" plugin be written? I might try to implement that, but would appreciate it if someone who is familiar with Psi's codebase/api provided some pointers.

Ri0n commented 3 years ago

Hi @kssytsrk, Thanks for the report. I believe we won't be able to fix any soon just because of lack of spare time of developers. But I think it has to be quite easy to extend the current OMEMO plugin with logging functionality. maybe even reuse some logging interfaces from other plugins from OMEMO plugin. You help would be highly appreciated.

CC @stigger

kssytsrk commented 3 years ago

Thank you for the reply! I think I'm almost done with it, but I've noticed that the QDomElement &message passed to the OMEMOPlugin::encryptMessageElement function has the attribute of "from" (that is, message.attribute("from")) set to an empty string.

Is this expected behavior? I've been trying to call my logger function from OMEMOPlugin::encryptMessageElement before encrypting the message and I need the "from" attribute to extract the MUC's name (that is, where that message is going to be sent). There might be some other way, but that is how it was implemented in the Conference Logger plugin...

Ri0n commented 3 years ago

Basically when you join a muc, the server associates your full account jid (account@server/resource) with your muc jid (room@muc.server/nickname) and for consequent outgoing messages the "from" attribute in not needed because the server knows everything coming from account@server/resource to the muc room@muc.server is in fact coming from room@muc.server/nickname.

So to have your muc jid you can go next ways:

  1. extract it from the muc dialog (or at least extract nickname. but IIRC full jid should be available too via plugins API)
  2. track presences to the muc to remember own muc jid.
  3. if you need just the "room@muc.server" part then it won't be available in the "from" attribute of an outgoing message. and you rather need to take it from the "to" attribute.

to summarize for messages we have... client -> server

server -> client

Neustradamus commented 3 years ago

@kssytsrk: Thanks a lot for your contributions! :)

Can you look other OMEMO problems?

For example, I have tagged you in some OMEMO tickets, can you look?