detect subscribe request for offline users

I would like to intercept a subscribe request from one user to another, when the other user (to whom the request is being sent) is offline. Is there a specific hook I can use to catch this case? I just want to capture jid of of both )to/from) users and do something with it.

When a user sends a

When a user sends a subscription request to an offline account in the same server, those hooks are run (among others):
* using run: roster_out_subscription
* using run_fold: roster_in_subscription
* also using run_fold: roster_process_item

So we added both hooks

So we added both hooks roster_out_subscription and roster_in_subscription in a module and looks like they are both triggered, no matter if the user to whom subscribe request is being sent to is offline or not. Is that expected behavior? I just need to capture the event/state when user is offline.

There isn't a specific event

There isn't a specific event that is called when a subscription request is sent to an offline user. You have two options: add a hook to the subscription sent, and manually check if the receiver is offline. Or add a hook to the offline storage, and manually check if the message is a subscription request :)

Syndicate content