[ejabberd] Re: x-tension tags in ejabberd-muc <presence/>

Magnus Henoch mange at freemail.hu
Thu Mar 30 13:48:56 MSD 2006

"Heiner Wolf" <wolf at bluehands.de> writes:

> This is my filter_presence function. Does not tell me too much though
> :-) I suppose somewhere around "case XMLNS of". But I can not yet
> interpret "++ _ ->".
> filter_presence({xmlelement, "presence", Attrs, Els}) ->
>     FEls = lists:filter(
>        fun(El) ->
>          case El of
>        {xmlcdata, _} ->
>            false;
>        {xmlelement, _Name1, Attrs1, _Els1} ->
>            XMLNS = xml:get_attr_s("xmlns", Attrs1),
>            case XMLNS of
>          ?NS_MUC ++ _ ->
>              false;
>          _ ->
>              true
>            end
>          end
>        end, Els),
>     {xmlelement, "presence", Attrs, FEls}.

Oh... I was looking at ejabberd 1.0.0, which behaves as I described,
but this is from SVN.  It really looks like it should do what you
want...  '?NS_MUC ++ _' is a pattern matching any string starting with
?NS_MUC (a macro defined in jlib.hrl).

> Seems to be time for an erlang lesson. But before I start a question
> to the developer: Is it possible to pass unknown tags in the presence
> stanza without rewriting too much code?

Yes.  This function is the only place that (possibly) needs changing.

> And will the server store the entire stanza for new participants?


> BTW: what does the "/1" mean in your hint "Look at
> filter_presence/1"

It means that the function takes one argument.  In Erlang, functions
with the same name but different numbers of arguments are separate
functions, and are referred to with this convention.  In this case
there is only one filter_presence, though...

JID: legoscia at jabber.cd.chalmers.se

More information about the ejabberd mailing list