I am trying to implement a custom module to log all the messages to a webhook. I've found a good reference to do that, https://github.com/PH-F/mod_offline_http_post/blob/master/src/mod_offline_http_post.erl.
I have some custom tag in the message stanza, and I want to pass this to the webhook too.
But I couldn't figure out how to read the custom field out. Please help and tell me which API I should use to read the text in the "extra" tag, showing below.
Thanks in advance.
The Ejabber Server is latest v18.04.
The Xml format of the message:
<message type="chat" to="[email protected]" id="7521387E-D6D1-41B4-A909-E9AD3251FB84">
<body>Image</body>
<thread>[email protected]</thread>
<x xmlns="jabber:x:event"><offline/></x>
<extra xmlns="ocp:extra"><extra type="image" thumbnail="thumbnailUrl" url="url"></extra></extra>
</message>
The Packet format I got from Ejabberd log:
{message,
<<"7521387E-D6D1-41B4-A909-E9AD3251FB84">>,
chat,
<<"en">>,
{jid,<<"dichen">>,<<"123.123.123.123">>,<<>>,<<"dichen">>,<<"123.123.123.123">>,<<>>},
{jid,<<"johndoe">>,<<"123.123.123.123">>,<<>>,<<"johndoe">>,<<"123.123.123.123">>,<<>>},
[],
[{text,<<>>,<<"Image">>}],
{message_thread,<<>>,<<"[email protected]">>},
[
{xmlel,<<"x">>,[{<<"xmlns">>,<<"jabber:x:event">>}],[{xmlel,<<"offline">>,[],[]}]},
{xmlel,<<"extra">>, [{<<"xmlns">>,<<"ocp:extra">>}], [{xmlcdata,<<"<extra type=\"image\" thumbnail=\"thumbnailUrl\" url=\"url\"></extra>">>}]}
]
...
}
The easiest way I can think:
That will return: