-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Outcoming chat messages are not always stored in archive #3377
Comments
I am not able to reproduce that problem. I installed ejabberd from git master (there aren't changes in mod_mam.erl since long ago), configured mod_mam like you showed, registered two accounts user1 and user2, logged in both accounts with two clients, send a few messages, and their messages are stored in the "archive" table. Then, with both clients still connected, I use this command, and both outgoing and incoming messages are stored: Finally I close both clients, and execute again that command. In the database, I see both outgoing and incoming messages are stored. Do you see anything relevant in the ejabberd log files? |
Thanks for your test! We also tested with two new registered users (created with the register command), and the incoming and outcoming are stored correctly, you're right. It seems the problem only occurs with our user using JWT as authentication (who doesn't exist in the users table...). |
Here's the log output we have when only the incoming message is stored in mam : There is an error when for incoming message:
|
I think this commit fixed it. If you're able to try it, comment here your results. |
I didn't look into this yet: Shouldn't the user be added to the table as soon as he logged in once?
I'm confused. We now run both the |
I would've thought the problem description is misleading: The problem is not that a message was received but not archived. The problem is that the message wasn't received (but bounced), because from ejabberd's point of view, the recipient doesn't exist. It's obviously correct to not run the Or am I totally overlooking something? |
The outcoming message has to be archived. If not, I'll never be able to send a message to a not connected user with the send_message command. |
This conclusion is the part I don't understand, but that's mostly due to me not being familiar with our JWT implementation. (E.g., users authenticated via
I understood your requirement 😄 I'm just saying that the correct way to solve this problem is making ejabberd aware of that user.
So everything works fine while the user is connected? |
Sorry if I'm not clear enough.
|
Ok, quick look at the code explains the issue. I don't know whether there's a sane way to query a JWT service for user existence. If there isn't, the only solutions I see would be hacks such as checking some local tables or access rules. |
Au contraire, you're totally right! I got so concerned about the command code, that didn't consider it's an auth+mam behaviour. So, my workaround works for that particular case (JWT with only local accounts), but is unacceptable for broad use. |
Yes jwt doesn't really have users table, as those tokens are externally created, and there is no really mechanism that can be used to query which tokens were created. Probably we should make jwt return true to user_exists - or at least offer option to do that, both ways have it's drawbacks (for always false mam/offline and probably some other stuff wouldn't work properly, for true we can store data when user doesn't really exists). Will need to think about this. |
Yes, the user existance cannot be checked with jwt, so indeed, the function should always return true, not false I think. |
A more complex option (on the long run) is to add the user into a known user table, and provide a way to delete them. That table would be consulted by the jwt user exist query. |
This makes `user_check` hook work better with authentication methods that don't have a way to determine if user exists (like is the case for jwt and cert based authentication), and as result will improve mod_offline and mod_mam handling of offline messages to those users. This reuses information stored by `mod_last` for this purpose. Should fix issue #3377.
Commit 12d4745 should help with this (as long as you have mod_last enabled), i will be also adding a way to clear old mod_last data, which i think should be the full solution for this problem. |
Environment
Configuration
Only incoming chat messages are stored in archive table when we send messages with ejabberd send_message command and/or send_message API endpoint.
The outcoming chat messages are only stored when the from user has an active session.
The text was updated successfully, but these errors were encountered: