0
votes

The ejabberd module I'm using, mod_pottymouth is not filtering messages as expected. After adding logging I see a generic handler method being called instead of the one that does the actual filtering. Problem is, I am not able to parse the ejabberd message to ensure the proper function is called. Can anyone help?

on_filter_packet({_From, _To, {xmlel, <<"message">>, _Attrs, Els} = _Packet} = _Msg) ->
  %This is what should be called to filter messages, but is never called
  FilteredEls = filterMessageBodyElements(Els, []),
  {_From, _To, {xmlel, <<"message">>, _Attrs, FilteredEls}};
on_filter_packet(Msg) ->
 % This is what actually gets called
 Msg.

This is using ejabberd 17.01

2
using ejabberd 17.01, and the latest mod_pottymouth from ejabberd-contribbwsmith

2 Answers

2
votes

Starting from 16.12 ejabberd doesn't route xmlel elements. You should process new style records: message, presence or iq. Please read https://docs.ejabberd.im/developer/guide/#ejabberd-router and https://github.com/processone/xmpp/blob/master/README.md

So, basically, your code should look like this:

on_filter_packet(#message{body = Body} = Msg) ->
    NewBody = filterMessageBody(Body),
    Msg#message{body = NewBody};
on_filter_packet(Stanza) ->
    Stanza.
0
votes

Have you tried using xmlel as record instead of tuple ?