Ejabberd 20.xx module to send one to one or group chat offline message to user's via POST request to target URL This module can call an api to send e.g. a push message. The request body is in application/x-www-form-urlencoded format. See the example below.
V20.xx Updated and tested in 20.07, I assume it works from 19.05 onwards.
- cd /home/xxxxx/.ejabberd-module/sources/
- git clone https://github.com/codeliter/mod_offline_http_post_notify.git;
- start ejabberd
- bash /path-to-ejabberdctl/ejabberdctl module_install mod_offline_http_post_notify
- restart ejabberd
- cd /home/xxxxx/.ejabberd-module/sources/
- git clone https://github.com/codeliter/mod_offline_http_post_notify.git;
- copy ebin/mod_offline_http_post_notify.beam to ejabberd modules directory
- restart ejabberd
That's it. The module is now installed.
Add the following to ejabberd configuration under modules:
mod_offline_http_post_notify:
auth_token: "source_validate"
post_url: "http://example.com/notify"
confidential: false
- auth_token - user defined, hard coded token that will be sent as part of the request's body. Use this token on the target server to validate that the request arrived from a trusted source.
- post_url - the server's endpoint url
- confidential - boolean parameter; if true, do not send the message body in post data. if false (default), send the message body.
In one to one chat:
Array
(
[type] => chat
[to] => test2
[from] => test1
[vhost] => localhost
[messageId] => purplee060f9e5
[stanzaMessageId] => 1599283860553814
[body] => dfsd
)
In group chat:
Array
(
[type] => groupchat
[to] => test_room
[from] => test1
[offline] => test2|test3
[nick] => test1
[vhost] => localhost
[messageId] => purplee060f9f0
[stanzaMessageId] => 1599284280003783
[body] => sdf
)
NOTE:- offline user name with saperated by "|" pipe.