Vishesh Madhusudhana
Vishesh Madhusudhana

Reputation: 89

Ejabberd 17: How to create a hook which is called for offline messages?

I want to create a hook which is called whenever an offline message is created. Example: user-a(online) send a message to user-b(offline). Then as per ejabberd the message is stored and sent when user-b comes online. But in this situation, I want to call a local server POST URL with the data. How to create such a hook?

This hook is created so that I can from the local server send a push notification. Thus whenever a user comes online he/she will get the offline message as the push notification.

There is no step by step implementation for this. If anyone knows this it will be of great help.

Upvotes: 0

Views: 416

Answers (2)

MMujtabaRoohani
MMujtabaRoohani

Reputation: 483

Building on Badlop's answer, I have created a module that does exactly what you need to achieve from an offline_hook. Only with a difference that you'll have to connect a component to ejabberd instead of getting messages on REST API.

Upvotes: 1

Badlop
Badlop

Reputation: 4120

There are two hooks called when a message is sent to a local account that is offline: ejabberd_sm calls offline_message_hook. And mod_offline calls store_offline_message. Search for that in the ejabberd source code, and you will find example code to use them.

Upvotes: 1

Related Questions