我正在使用的ejabberd模块,mod_pottymouth没有按预期过滤消息。添加日志记录后,我看到一个被调用的通用处理程序方法,而不是执行实际过滤的方法。问题是,我无法解析ejabberd消息以确保调用正确的函数。有人可以帮忙吗?
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.
这是使用ejabberd 17.01
答案 0 :(得分:2)
从16.12开始,ejabberd不会路由xmlel
个元素。您应该处理新的样式记录:message
,presence
或iq
。
请阅读https://docs.ejabberd.im/developer/guide/#ejabberd-router
和https://github.com/processone/xmpp/blob/master/README.md
所以,基本上,你的代码应该是这样的:
on_filter_packet(#message{body = Body} = Msg) ->
NewBody = filterMessageBody(Body),
Msg#message{body = NewBody};
on_filter_packet(Stanza) ->
Stanza.
答案 1 :(得分:0)
您是否尝试过将xmlel用作记录而不是元组?