esl / MongooseIM

MongooseIM is Erlang Solutions' robust, scalable and efficient XMPP server, aimed at large installations. Specifically designed for enterprise purposes, it is fault-tolerant and can utilise the resources of multiple clustered machines.
Other
1.64k stars 422 forks source link

mod_event_pusher HTTP only sends chat type messages #4217

Closed nomanAli95 closed 1 month ago

nomanAli95 commented 3 months ago

Description:

Currently using mod_event_pusher with HTTP backend is not possible to send http requests for groupchat type messages, but only for chat type messages.

Steps to Reproduce:

Expected Behavior:

MongooseIM sends HTTP requests for both type of messages (chat, groupchat) or it allows you to choose the type by any kind of configuration for mod_event_pusher with HTTP backend.

Actual Behavior:

MongooseIM does not send any HTTP requests to the endpoint declared in configuration for groupchat messages

DenysGonchar commented 3 months ago

the current behavior is defined by the callback module, by default it's mod_event_pusher_http_defaults, also at the moment that's the only callback module distributed in the open-source codebase.

and this callback module does exactly what is promised in the documentation: Name of a module which should be used to check whether a notification should be sent. The default callback module, mod_event_pusher_http_defaults, sends notifications for all non-empty chat messages. You can use this module as a starting point for developing a custom one.

as you said, it sends notifications for non-empty chat messages, it is not supposed to send notifications for groupchat messages.


I haven't tested it but I think you can achieve the desired behavior with just a small change to the mod_event_pusher_http_defaults. simply replace the current implementation of should_make_req_type/5 with this one:

should_make_req_type(_Acc, <<"chat">>, Body, _From, _To) when Body /= <<"">> ->
    true;
should_make_req_type(_Acc, <<"groupchat">>, Body, _From, _To) when Body /= <<"">> ->
    true;
should_make_req_type(_Acc, _, _, _, _) ->
    false.
nomanAli95 commented 3 months ago

Great! Many thanks!