Skip to content

haithngn/mod_offline_post

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mod_offline_post

An Ejabberd module that registers an offline_message_hook to intercept offline messages and forwards them via HTTP POST requests to a configured URL.

Features

  • Registers an offline_message_hook to intercept offline messages.
  • Sends HTTP POST requests with form fields: to, from, body, access_token.
  • Configurable URL endpoint and access token.
  • Configurable HTTP timeout.
  • Comprehensive error handling and logging.
  • Non-blocking HTTP requests (spawned processes).

Message Flow

  1. Message Sent: XMPP client sends message to offline user.
  2. Hook Triggered: Ejabberd triggers offline_message_hook.
  3. Filtering: Module filters out chat state messages.
  4. HTTP Forward: Module sends HTTP POST with raw XML stanza.

Installation

  1. Copy mod_offline_post.erl to your Ejabberd modules directory (usually /opt/ejabberd/lib/ejabberd-*/ebin/ or similar).

  2. Compile the module:

    erlc -I /opt/ejabberd/lib/ejabberd-*/include mod_offline_post.erl
  3. Add the module to your ejabberd.yml configuration file:

    modules:
      mod_offline_post:
        post_url: "https://your-server.com/offline-message"
        access_token: "your-secret-token"
        timeout: 5000  # Optional, default is 5000ms
  4. Restart Ejabberd or reload the configuration:

    ejabberdctl restart

Configuration Options

Option Type Default Description
post_url string "" The URL to send HTTP POST requests to.
access_token string "" Access token to include in the POST data.
timeout integer 5000 HTTP request timeout in milliseconds.

HTTP POST Request

When an offline message is stored, the module sends a POST request with the following form data:

Example POST data:

to=user%40example.com&from=sender%40example.com&body=Hello%20World&access_token=your-secret-token

Troubleshooting

Note: This module was tested with Ejabberd 25.08.

Module not loading

  • Check that the module is compiled and in the correct directory.
  • Verify the configuration syntax in ejabberd.yml.
  • Check Ejabberd logs for compilation errors.

HTTP requests not being sent

  • Verify the post_url is configured and reachable.
  • Check Ejabberd debug logs for HTTP request details.
  • Ensure the target server is responding with HTTP 200.

License

This module is GPLv2-Licensed.

About

Ejabberd Module - Offline Message Post

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages