-
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
Newly registered users don't receive welcome message #4246
Comments
I've tested with ejabberd 23.10, 24.02 and 24.06. In all cases with the same configuration: modules:
...
mod_register:
ip_access: trusted_network
welcome_message:
subject: "hi you"
body: "Hi\nWelcome Body" I register an account with Tkabber, using In-Band Registration, and it receives the messages with all the tested ejabberd versions. Just for completeness, I've also tested with the container image: podman run --name ejabberd -it -p 5222:5222 ghcr.io/processone/ejabberd live
podman exec -it ejabberd vi /opt/ejabberd/conf/ejabberd.yml and configure mod_register with only this: mod_register:
welcome_message:
body: "This is the body" Then: podman exec -it ejabberd ejabberdctl reload_config When the client registers the account and logins, it receives: <!-- 15:56:34.383 IN (::xmpp::9, admin235@localhost/tka1) -->
<message to='admin235@localhost'
from='localhost'>
<archived by='admin235@localhost'
id='1720187794065880'
xmlns='urn:xmpp:mam:tmp'/>
<stanza-id by='admin235@localhost'
id='1720187794065880'
xmlns='urn:xmpp:sid:0'/>
<delay from='localhost'
stamp='2024-07-05T13:56:34.090684Z'
xmlns='urn:xmpp:delay'>Offline storage</delay>
<body xml:lang='en'>This is the body</body>
</message> Notice that this feature requires mod_offline to be enabled. |
Thank you for your time and comprehensive response. The module ...
modules:
...
mod_offline:
access_max_user_messages: max_user_offline_messages
...
mod_register:
password_strength: 64
captcha_protected: true
registration_watchers:
- "[email protected]"
- "[email protected]"
welcome_message:
subject: "Welcome to domain.tld!"
body: |-
Language 1
text here
* * * * * * *
Language 2
text here
ip_access: all
I also tried with a simplified version - same result. ...
modules:
...
mod_register:
welcome_message:
subject: "Welcome!"
body: "Body text here"
ip_access: all
... What do you think would be a good starting point for debugging such a situation? |
Looking at mod_register:try_register, the code is fairly simple, let's follow it and propose some tests you can try: A) log message is displayed?Do you see in ejabberd.log the line "The account X was registered from IP addresss..." ? Immediately after that the send_welcome_function is executed for account X. B) non-latin1 characters and some bug in ejabberd?Is account X correctly displayed? Maybe it has non-latin1 characters? You can try with simple strings like "[email protected]" C) welcome_message option cannot be retrieved?The send_welcome_message function gets the configured value of welcome_message. Maybe it's incorrectly retrieved for some reason. Start an interactive erlang shell in your ejabberd and check the option:
D) Is the welcome message stored in offline queue?If the option is set, that function immediately sends a message stanza to the account. You could try to register the account using In Band Registration but NOT login yet, and see if the message is stored in the offline table. If your client registers the account and immediately logins, you can try this: setup in your jabber client as presence priority a negative value, like -5 for example. That way, when the client logins, ejabberd does NOT send offline messages to him. Then check if that account has the welcome message stored at his offline queue http://localhost:5280/admin/server/localhost/user/user1/queue/ E) Does client login with positive priority to get offline messages?Login to that account with a zero or positive priority, for example 8, then ejabberd will send to the client the offline messages, including the welcome message. If the account has offline messages stored in the queue, but does not send them to the client after login, then maybe you are setting a negative presence priority. |
I appreciate your time and detailed instructions @badlop! I'm really impressed. TL;DRSince the problem is most likely not related to ejabberd, here are the results so far:
The Long StoryA) log message is displayed?Yes. A log message is displayed. Tested with the client apps mentioned above.
B) non-latin1 characters and some bug in ejabberd?No non-latin1 characters are used in the account name(s). C) welcome_message option cannot be retrieved?I have no experience with the erlang shell and for that the only thing I did was copy/paste the command in the erlang shell.
The output was:
I have no idea what that means. D) Is the welcome message stored in offline queue?Yes. It is stored when an account is only registered, but didn't log in. It doesn't matter if the message is the long version (With subject and body in two different languages) or the short version (only with a short body without subject). Users
If I click on the Offline counter:
I sent a message to And now the interesting part: The moment E) Does client login with positive priority to get offline messages?Gajim's default priority is 0. Changing to 8 doesn't make the welcome message to appear. |
just a FYI, latest Conversations +free is 2.16.4 too 👅 blabber.im is 2 years old, stop using it pls, backup and restore in Conversations |
Thanks @licaon-kter. I am aware of that. Don't worry, they were only used for testing purposes. |
C) FYI, in the erlang shell, type only the command, that ends with a dot D)
You say "he receives", but properly speaking, you only checked what do the XMPP clients show to the human. You didn't check what do the XMPP clients receive from the server, right?. For that, open the client XML Console, or Raw Console, or whatever it's called. At least Gajim has a very good raw xml console. Unfortunately, I cannot test with Gajim (it requires a fully signed certificate and does not accept a self-signed cert, or non-encryption). F) Pidgin receives the welcome message, but shows it as a chat message, so the Subject is not displayed, only the Body. Notice that the welcome message is a message stanza of You can also experiment removing the Subject element. G) If you enabled contributed or custom modules, maybe they affect the stanza forwarding? H) And it would be worth checking if the server sends the stanza or not. I guess you have encrypted traffic, so sniffing the network is useless. If it's a small server, you can set 2024-07-11 16:07:05.077925+02:00 [debug] Route:
#message{id = <<>>,type = normal,lang = <<>>,
from = #jid{user = <<>>,server = <<"localhost">>,resource = <<>>,
luser = <<>>,lserver = <<"localhost">>,lresource = <<>>},
to = #jid{user = <<"admin5">>,server = <<"localhost">>,
resource = <<>>,luser = <<"admin5">>,
lserver = <<"localhost">>,lresource = <<>>},
subject = [#text{lang = <<"en">>,data = <<"Welcome!">>}],
body = [#text{lang = <<"en">>,data = <<"Body text here">>}],
thread = undefined,
sub_els = [#xmlel{name = <<"archived">>,
attrs = [{<<"by">>,<<"admin5@localhost">>},
{<<"id">>,<<"1720706824821547">>},
{<<"xmlns">>,<<"urn:xmpp:mam:tmp">>}],
children = []},
#xmlel{name = <<"stanza-id">>,
attrs = [{<<"by">>,<<"admin5@localhost">>},
{<<"id">>,<<"1720706824821547">>},
{<<"xmlns">>,<<"urn:xmpp:sid:0">>}],
children = []},
#delay{stamp = {1720,706824,865880},
from = #jid{user = <<>>,server = <<"localhost">>,
resource = <<>>,luser = <<>>,
lserver = <<"localhost">>,
lresource = <<>>},
desc = <<"Offline storage">>}],
meta = #{from_offline => true}}
2024-07-11 16:07:05.078198+02:00 [debug] Local route:
#message{id = <<>>,type = normal,lang = <<>>,
from = #jid{user = <<>>,server = <<"localhost">>,resource = <<>>,
luser = <<>>,lserver = <<"localhost">>,lresource = <<>>},
to = #jid{user = <<"admin5">>,server = <<"localhost">>,
resource = <<>>,luser = <<"admin5">>,
lserver = <<"localhost">>,lresource = <<>>},
subject = [#text{lang = <<"en">>,data = <<"Welcome!">>}],
body = [#text{lang = <<"en">>,data = <<"Body text here">>}],
thread = undefined,
sub_els = [#xmlel{name = <<"archived">>,
attrs = [{<<"by">>,<<"admin5@localhost">>},
{<<"id">>,<<"1720706824821547">>},
{<<"xmlns">>,<<"urn:xmpp:mam:tmp">>}],
children = []},
#xmlel{name = <<"stanza-id">>,
attrs = [{<<"by">>,<<"admin5@localhost">>},
{<<"id">>,<<"1720706824821547">>},
{<<"xmlns">>,<<"urn:xmpp:sid:0">>}],
children = []},
#delay{stamp = {1720,706824,865880},
from = #jid{user = <<>>,server = <<"localhost">>,
resource = <<>>,luser = <<>>,
lserver = <<"localhost">>,
lresource = <<>>},
desc = <<"Offline storage">>}],
meta = #{from_offline => true}}
2024-07-11 16:07:05.078561+02:00 [debug] Running hook sm_receive_packet: mod_mam:sm_receive_packet/1
2024-07-11 16:07:05.078720+02:00 [debug] Processing message to bare JID:
#message{id = <<>>,type = normal,lang = <<>>,
from = #jid{user = <<>>,server = <<"localhost">>,resource = <<>>,
luser = <<>>,lserver = <<"localhost">>,lresource = <<>>},
to = #jid{user = <<"admin5">>,server = <<"localhost">>,
resource = <<>>,luser = <<"admin5">>,
lserver = <<"localhost">>,lresource = <<>>},
subject = [#text{lang = <<"en">>,data = <<"Welcome!">>}],
body = [#text{lang = <<"en">>,data = <<"Body text here">>}],
thread = undefined,
sub_els = [#xmlel{name = <<"archived">>,
attrs = [{<<"by">>,<<"admin5@localhost">>},
{<<"id">>,<<"1720706824821547">>},
{<<"xmlns">>,<<"urn:xmpp:mam:tmp">>}],
children = []},
#xmlel{name = <<"stanza-id">>,
attrs = [{<<"by">>,<<"admin5@localhost">>},
{<<"id">>,<<"1720706824821547">>},
{<<"xmlns">>,<<"urn:xmpp:sid:0">>}],
children = []},
#delay{stamp = {1720,706824,865880},
from = #jid{user = <<>>,server = <<"localhost">>,
resource = <<>>,luser = <<>>,
lserver = <<"localhost">>,
lresource = <<>>},
desc = <<"Offline storage">>}],
meta = #{from_offline => true}}
...
2024-07-11 16:07:05.089327+02:00 [notice] (tcp|<0.2616.0>) Send XML on stream = <<"
<message to='admin5@localhost'
from='localhost'>
<archived by='admin5@localhost'
id='1720706824821547'
xmlns='urn:xmpp:mam:tmp' />
<stanza-id by='admin5@localhost'
id='1720706824821547'
xmlns='urn:xmpp:sid:0' />
<delay from='localhost'
stamp='2024-07-11T14:07:04.865880Z'
xmlns='urn:xmpp:delay'>Offline storage</delay>
<body xml:lang='en'>Body text here</body>
<subject xml:lang='en'>Welcome!</subject>
</message>
">>
|
D)You are absolutely right. The welcome message is present in the Gajim's Debug Console. It is simply not displayed to the user by the application. F)The result is as in D). Sending a message from a client to another client with stanza of I see that Removing the Subject makes no change. G)No such modules activated. H)Yes the server sends the stanza and the traffic is encrypted.
|
Aha! In summary:
Then comes the obvious question: how can clients fail to show properly Considering that welcome messages are not expected to be replied, it made sense to send them as In summary, the only method I can find is to send welcome messages as type diff --git a/src/mod_register.erl b/src/mod_register.erl
index 7da8ca74a..d656263bf 100644
--- a/src/mod_register.erl
+++ b/src/mod_register.erl
@@ -412,6 +412,12 @@ send_welcome_message(JID) ->
case mod_register_opt:welcome_message(Host) of
{<<"">>, <<"">>} -> ok;
{Subj, Body} ->
+ ejabberd_router:route(
+ #message{from = jid:make(Host),
+ to = JID,
+ type = chat,
+ subject = xmpp:mk_text(Subj),
+ body = xmpp:mk_text(<<Subj/binary, "\n\n", Body/binary>>)}),
ejabberd_router:route(
#message{from = jid:make(Host),
to = JID, But there's something that puzzles me:
Nothing relevant has changed in mod_register between 23.10 and 24.02. Are you sure those clients received the welcome message in previous versions, or probably they never did? |
I tried sending such a message Do you think it's appropriate to notify the developers of the respective client apps?
In conclusion, I can say: It must be a coincidence. However, during this time, quite a few updates have been made to the client applications as well. I don't think the problem is related to Ejabberd in any way. |
Apparently, some clients don't display 'normal' messages to the user.
Closing as the referenced commit should fix the issue. |
Environment
Errors from error.log/crash.log
No errors
Bug description
Since I updated ejabberd from from version 23.10 to version 24.02, noticed that the option
welcome_message:
of the modulemod_register
no longer works as expected. Newly registered users do not receive the welcome message anymore.No changes have been made during this time to the configuration file, so that's why I am not sharing it here. After updating to version 24.06, the problem persists.
Please, can someone using this feature, confirm that it works so I know if it makes sense to continue looking for the cause on my side?
Thank you!
The text was updated successfully, but these errors were encountered: