Closed dirkmoors closed 8 years ago
Also, this might be interesting approach, what do you guys think?
https://github.com/ChatSecure/ChatSecure-Push-Server/blob/master/docs/v3/README.md
Why don't you use a hook to listen for offline messages and to call a script that sends notifications using any library of your choice?
@nunohorta I've worked with an offline message hook already, but it doesn't work with MUC afaik. In an open MUC room, where there are no 'fixed members', I understand the irrelevance of offline messages, but in my scenario, I only have rooms where there are specific members, that need to be notified if they're not online.
@dirkmoors MUC are indeed presence based. It is indeed not designed to care of offline users. The XMPP Standards Foundation started thinking about what is call MUC2, that would make it possible in a clean way.
To be frank, we have done thing for customers but nothing we have the right to share yet. However, we are willing to work actively on the MUC2 approach and have it implemented by following closely the XEP progress.
@mremond Aren't there any plugins available that are able to trigger a webservice (containing message + offline members), when a message is delivered into a muc room, and not all members are online?
Not that I know of. However, it should be easier to write with the new muc_message_filter
API. However, this trigger is unrelated to the fact that members in the member list are online or not. You would have to do the check in the code before triggering any remote call if you wish to.
@dirkmoors Okay now I understand what you need. I'm actually working on something similar. I've barely started but my idea is to use the new muc_message_filter like @mremond said above. I will also be listening for presence changes on chat rooms(https://github.com/processone/ejabberd/commit/6e61932765f9ae8e290b88cce5c2ed574fb4bbe7), thank you @weiss ! This will work, I hope, because I do all the management of users and chat rooms on my server using php and the ejabberd_xmlrpc module, meaning that the server knows which users are members in each chat room. When a message is sent to a group, I call a script that checks offline users "in" that group and sends push notifications. This will be used in groups with around 50 people max. I believe that this should not affect the server with performance issues.
@nunohorta that is probably what I need too. My use case is similar, but I'll be managing the users from within a Django (python) application, via XMLRPC (actually, I've written an open source python library for that purpose: https://github.com/dirkmoors/pyejabberd). Are you implementing an erlang-based plugin? Or how do you anticipate implementing this feature?
@dirkmoors That looks really good! I'm using a php library that I developed myself but can't share unfortunately because it's part of a software that is not mine. To be more specific I'll listen to presence changes and chat room messages with modules that I developed. Those modules send a post request to a url in my system that caches online/offline users and sends notifications to their devices when offline. The other data I have it stored on a database because I developed a backend to manage user connections and chat rooms with a nice interface. This also runs on php and uses the xmlrpc API to call Ejabberd methods
@nunohorta Yeah I did something similar: the exact approach I tried was running a 'bot' (I've used SleekXMPP, a Python library) that connects to all the rooms to listen to the messages and presence, and updates the local database accordingly, sending push notifications to offline room members. I'm afraid that this approach is not scalable (I have no idea how much MUC rooms this 'bot' can process simultaneously)
@nunohorta it might be easier for you to read StateData
right from muc_message_filter
- which will give you online occupants for "right now". So that list of online users +
thanks @EugeneNews ! I hope to start this over the week. It seems like a good solution!
@EugeneNews could you help using the muc_message_filter? How can I read the body from Stanza argument? This is what I have so far https://gist.github.com/nunohorta/fd8ecf46267deef16d86 . If you could help that would be great.
@nunohorta i'm doing it with mapping list of users
_LISTUSERS = lists:map(
fun({_LJID, Info}) ->
binary_to_list(Info#user.jid#jid.luser) ++ ".."
end,
dict:to_list(MUCState#state.users)),
?DEBUG(" ######### GROUPCHAT _LISTUSERS = ~p~n ####### ", [_LISTUSERS])
you see, I'm using ".." as a separator in the string, because i like to send all users as just 1 parametor in POST request. But if advance fun() you may get LIST/array to convert it to smthn you need...
:8ball: I have the same question.
Is there anyone willing to implement an (open source) Ejabberd plugin that -once a MUC room has MEMBER affiliations- simply triggers a REST/webservice, notifying which MEMBERS are offline, and which message did not get to them. I think a lot of developers would benefit from such a plugin?
If needed I can explain in more detail.
@dirkmoors I think better approach is never to go offline. Client developers should be encouraged to implement XEP-0198. I also do not understand the dance around affiliations. Have you ever seen MUC rooms with 1000 members in the list? Your REST/webservice will die during notifications.
@zinid In many usecases, you're talking of less members. Think intranet chat application, friend-groups, etc. In those usecases, I think it would make perfect sense to notify a webservice?
Moreover, never going offline seems hard in mobile environments, which by nature do not provide stable connectivity?
Moreover, never going offline seems hard in mobile environments, which by nature do not provide stable connectivity?
Actually with XEP-0198 you can be always online. XEP-0198 will transparently resume your session during re-login.
That sounds very interesting! I'm going to look into that XEP definitely.
Nevertheless; triggering a webservice to notify about offline room members would make (mobile) push notifications to mobile devices very straightforward to implement. Or would you suggest another approach to achieve this?
Nevertheless; triggering a webservice to notify about offline room members would make (mobile) push notifications to mobile devices very straightforward to implement. Or would you suggest another approach to achieve this?
I think push notifications should be triggerd when a client is disconnected from the server, but its session is alive (due to XEP-0198 "hibernation").
triggering a webservice to notify about offline room members would make (mobile) push notifications to mobile devices very straightforward to implement.
Is this about making room messages available to offline members, or about generating push notifications to mobile clients, or both? These are somewhat unrelated topics which require separate solutions.
Anyway, it's not quite obvious to me how a web service would be specifically useful to solve either of these things, as opposed to having an ejabberd module do whatever the web service would do. But yes, it could be done this way, just as a web service could handle any other event within ejabberd, of course.
@zinid That might be a good 'trigger to send a push notification' yes, but there still needs to be a party responsible for sending the actual push notification. In my mind, the simple solution would be to offload that responsibility to a seperate (web)service.
Don't know much about erlang, just what I learned in the past week and taking into account all the links and feedback posted I've been able to "build" a mod for what's requested
I also have the same question. Finally i have update 3 files to realize. The module are ejabberd_sm、mod_muc_room、mod_offline.
i have same issue , let me give some more detail. i have implimented ejabberd 15.11, i have used mod_http_offline module to send offline notification. i am able to start and complile my module. but when user send offline message i got below error in my error log, can anyone please suggest whare i am wrong .
2015-12-28 21:13:28.971 [error] <0.37.0>@ejabberd_config:validate_opts:794 unknown option 'loopback' will be likely ignored
2015-12-28 21:13:28.971 [error] <0.37.0>@ejabberd_config:validate_opts:794 unknown option 'local' will be likely ignored
[error] <0.524.0>@ejabberd_hooks:run1:332 {function_clause,[{lists,thing_to_list,[<<>>],[{file,"lists.erl"},{line,601}]},{lists,flatmap,2,[{file,"lists.erl"},{line,1248}]},{lists,flatmap,2,[{file,"lists.erl"},{line,1248}]},{mod_http_offline,post_offline_message,2,[{file,"mod_http_offline.erl"},{line,43}]},{ejabberd_hooks,safe_apply,3,[{file,"src/ejabberd_hooks.erl"},{line,382}]},{ejabberd_hooks,run1,3,[{file,"src/ejabberd_hooks.erl"},{line,329}]},{ejabberd_sm,route,3,[{file,"src/ejabberd_sm.erl"},{line,111}]},{ejabberd_local,route,3,[{file,"src/ejabberd_local.erl"},{line,112}]}]}
running hook: {offline_message_hook,[{jid,<<"911234567891">>,<<"xyz.com">>,<<"42629891761451308446954821">>,<<"111111111111">>,<<"xyz.com">>,<<"42629891761451308446954821">>},{jid,<<"33333333">>,<<"xyz.com">>,<<>>,<<"111111111">>,<<"xyz.com">>,<<>>},{xmlel,<<"message">>,[{<<"id">>,<<"Ge62DNXY">>},{<<"type">>,<<"One2One">>},{<<"to">>,<<"121212121@xyz.com">>}],[{xmlel,<<"msgtype">>,[],[{xmlcdata<<"chat">>}]},{xmlel,<<"body">>,[],[{xmlcdata,<<"T2s=">>}]},{xmlel,<<"FrontParterPic">>,[],[{xmlcdata,<<"57_1447745086.jpg">>}]},{xmlel,<<<"x">>,[{<<"xmlns">>,<<"jabber:x:event">>}],[{xmlel,<<"offline">>,[],[]},{xmlel,<<"delivered">>,[],[]}]}]}]}
@Hiren701 The problem is in https://github.com/raelmax/mod_http_offline/ not in ejabberd. That module is not compliant with latest ejabberd apparently.
@zinid , I am using session resumption with large resumption time - 24 hours. I have a doubt about muc, if I am in group and my client rejoin, do I need to leave and rejoin the group to get the new messages. For non muc stanzas, they are kept in offline storage and delivered as soon as I reconnect. But I am not sure about muc.
If it is not so the case I don't think there is any advantage of being online - except to fetch occupants list. Again I am not sure if I will get occupant joined event if my client was offline.
I am using session resumption with large resumption time - 24 hours. I have a doubt about muc, if I am in group and my client rejoin, do I need to leave and rejoin the group to get the new messages.
No. If your client is resuming the stream management session, then you never left the room and there's no reason to rejoin it. You would receive the missing room messages during resumption.
what i did:
I have doubts that this is the best way to do it
Hello sh-al, could you please share the code you used for steps 2 and 3?
"2. modified mod_muc room so it would route incoming packets for all room members, except the banned one
This sound like a good solution for many of my scenarios Thanks in Advance,
Best Regards
Closing, we are preparing some extension that could help with this in the future.
@mremond Do you have more info about that extension? Where can I learn more about it?
Here is MUC Sub extension: https://blog.process-one.net/xmpp-mobile-groupchat-introducing-muc-subscription/
@mremond, can you describe some examples how to use this extension and implement in ejabberd server some multi-user Group chat with offline message delivery to each member in any Jabber client?
At now our company use Jabber Bot based on https://github.com/punchagan/childrens-park that emulate group chat with offline messages, and it works well for 100+ users with massive every day talks. But bad site is that all chatrooms must be configured manually on server side.
Don't know much about erlang, just what I learned in the past week and taking into account all the links and feedback posted I've been able to "build" a mod for what's requested
Hi,
I want to send offline message to one-to-one user as well as groups. when I tried compiling the module from above github url getting below errors can you help me on this. I am using ejabbered 18.01 version.
c:/Program Files/ejabberd-18.01/lib/ejabberd-18.01/include/mod_muc_room.hrl:96: type message() undefined c:/Program Files/ejabberd-18.01/lib/ejabberd-18.01/include/mod_muc_room.hrl:97: type presence() undefined c:/Program Files/ejabberd-18.01/lib/ejabberd-18.01/include/mod_muc_room.hrl:116: type text() undefined c:/Program Files/ejabberd-18.01/lib/ejabberd-18.01/include/mod_offline_post.erl:4: Warning: undefined callback function depends/2 (behaviour 'gen_mod') c:/Program Files/ejabberd-18.01/lib/ejabberd-18.01/include/mod_offline_post.erl:4: Warning: undefined callback function mod_opt_type/1 (behaviour 'gen_mod')
Thanks in Advance.
@ismailmohammed Why would you use a 3 years old module? You already have mod_offline
included, that and MAM modules should take care of stuff.
If you compile your own do UPDATE to 18.09 and use the config template (that has all the good stuff enabled already) to setup your server.
@licaon-kter I agree with you but mod_offline will store the offline messages and retrived when user is online. but my case is when a user is offline even I should get the message like watsup. when the application is running in the background. 1:1 or group chat when user is offline i want a send a message as notification to the user.
Thank you ismail
Ignore this old useless module and UPDATE to 18.09 and use the config template (that has all the good stuff enabled already) to setup your server.
1:1 or group chat when user is offline i want a send a message as notification to the user.
As @mremond mentioned above, using MUC/Sub solves this issue.
For standard clients that don't use this extension, mod_push_keepalive
tries to work around the problem by keeping the XEP-0198 session online until at least one push notification was sent.
thanks for the update.
you mean to say once upgrade to 18.09 version with given configration user will be able to get 1:1 and group offline notifications to mobile(andriod\IOS)?
Thanks, Ismail
@ismailmohammed Yes, of course.
After you're done with the setup, run it through https://compliance.conversations.im/ and see if everything works ok ;)
I have uninstalled the previous version and installed 18.09 version and changed some configurations settings. Need to test it.
but still, I have doubt how ejabbered will send mobile push notifications to Andriod and IOS mobiles without any configurations like APNS,FCM etc?
Thanks in advance Ismail.
Push config is done in the client application (Conversations on Android from Play store or ChatSecure on iOS)
Hi,
I have started 18.09 with configuration shared. please clarify push notification will work ejabberd Business Edition? or even in community?
one of my colleague who's developing IOS app he is trying to enable push notification from his code and he is getting below error can you please suggest me on this error.
`
@ismailmohammed Have you figure it out a way to trigger HTTP request for group offline messages?
Yes I did.
Thank you.
On Fri 15 Feb, 2019 5:10 pm Lakmal Dharmasena <notifications@github.com wrote:
@ismailmohammed https://github.com/ismailmohammed Have you figure it out a way to trigger HTTP request for group offline messages?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/processone/ejabberd/issues/697#issuecomment-464015546, or mute the thread https://github.com/notifications/unsubscribe-auth/AKBe-VwRkql2U-2gUQ3Va-wo_OycnnULks5vNpyfgaJpZM4FlmGh .
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
What is the recommended way to implement push notifications (e.g. trigger some webservice) to offline users? In my use case, I've got members-only rooms where I want to be able to send messages, and if the message is not delivered right away (because the user is offline, network flaky, etc), Ejabberd should trigger a webservice that dispatches the message as a push notification (Android, iOS, ...).
How would I approach this?
p.s. I don't know any Erlang, otherwise I would have attempted to write a plugin or something....