Skip to content

Commit fe0e89a

Browse files
author
Nimrod Dayan
committed
Updated readme
1 parent 377b5cb commit fe0e89a

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

README.md

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,52 @@
1-
mod_http_offline
2-
================
1+
Ejabberd 16.08 module to send offline user's message via POST request to target URL.
2+
The main motivation for this module is to use it with push notifications. The request body is in JSON format. See the example below.
33

4-
Ejabberd module to send a post if users was offline.
54

5+
Installation
6+
------------
67

7-
This module is based on [Adam Duke mod_interact](https://github.com/adamvduke/mod_interact), [Jason Rowe's post](http://jasonrowe.com/2011/12/30/ejabberd-offline-messages/) and a lot of pieces of code and tips from the web to adapts to work with Ejabber 14.12.
8+
1. Clone the repository into your Ejabberd's modules sources' folder. On Mac OS X, this folder is `~/.ejabberd-modules/sources/`.
9+
2. Run command: `ejabberdctl module_install mod_offline_http_post`
810

9-
Installing
10-
----------
11+
That's it. The module is now installed.
1112

12-
Clone this repository:
13+
Configuration
14+
-------------
1315

14-
``` git clone git@github.com:raelmax/mod_http_offline.git```
16+
Add the following to ejabberd configuration under `modules:`
1517

16-
Change the ```'[your-url-here]'``` string in ```mod_http_offline.erl``` file.
18+
```
19+
mod_offline_http_post:
20+
auth_token: "secret"
21+
post_url: "http://example.com/notify"
22+
```
1723

18-
To compile this I downloaded the code at my home directory and run:
24+
- 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.
25+
- post_url - the server's endpoint url
1926

20-
```
21-
erlc -I /lib/ejabberd/include/ -pa ~/ejabberd/deps/lager/ebin/ mod_http_offline.erl
27+
Example of the outgoing request:
28+
--------------------------------
29+
30+
```
31+
{'to':'user2','from':'user1','body':'hi there!','message_id':'purple9ca5e35b','access_token':'secret'}
2232
```
2333

24-
Move the .beam file to ejabberd ebin folder:
34+
Build and extend this module
35+
----------------------------
2536

26-
```
27-
sudo mv mod_http_offline.beam /lib/ejabberd/ebin/
37+
The assumption is that you're developing on Mac OS X and installed Ejabberd via homebrew.
38+
To build this module for development use the script `build.sh`. Please note that this script is configured to Ejabberd installation on Mac OS X. For other OS, you'll have to modify the dependencies path to point to your Ejabberd installation.
39+
40+
build.sh
41+
```
42+
/usr/local/Cellar/ejabberd/16.08/lib/lager-3.2.1/ebin/
43+
/usr/local/Cellar/ejabberd/16.08/lib/fast_xml-1.1.14/ebin/
2844
```
2945

30-
Add "mod_http_offline" to your ejabberd.yml config at "modules" section:
46+
You will also need to modify the path of Ejabberd `include` folder in `Emakefile`.
3147

3248
```
33-
mod_http_offline: {}
49+
{'src/mod_offline_http_post', [{outdir, "ebin"},{i,"/usr/local/Cellar/ejabberd/16.08/lib/ejabberd-16.08/include"}]}.
3450
```
3551

36-
Restart ejabberd! \o/
37-
38-
This is tested with ejabberd 14.12 and ubuntu server 14.04.
52+
Note that the scripts are pointing to Ejabberd version 16.08. If you're building against newer versions, you'll need to modify the paths in both `build.sh` and `Emakefile` regardless of whether you're on Mac OS X or not.

0 commit comments

Comments
 (0)