esl/MongooseIM

mod_event_pusher HTTP only sends chat type messages

Closed this issue · 2 comments

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

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.

Great! Many thanks!