can't parse packet/payload on ejabberd 13 (xmlelements)

I'm using the pubsub_publish_item hook (from mod_pubsub @master) and I'm unable to parse the payload/packet.

I've tried using xml:get_tag_attr_s("x", Payload) and other xml:functions with no luck.

This is what I get as payload:

[{xmlel,<<"x">>,[{<<"xmlns">>,<<"jabber:x:data">>},{<<"type">>,<<"result">>}],[{xmlel,<<"field">>,[{<<"var">>,<<"alert_type">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"block">>}]}]},{xmlel,<<"field">>,[{<<"var">>,<<"alert_subtype">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"perm-access">>}]}]},{xmlel,<<"field">>,[{<<"var">>,<<"ip_address">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"189.221.4.50">>}]}]},{xmlel,<<"field">>,[{<<"var">>,<<"subject">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"whatever_reason">>}]}]}]}]

I can access it as a whole, but not in sections/pairs xml style (I cant read a single element).

Basically what I'm trying to achieve is to post this payload to an external url. Currently I'm able to post simple text line OK, but when adding the payload, I'm guessing because of the format, it scrambles everything and get a crash!

If there's something like "urlencode" that I can apply to the payload or a way of "reading" the payload xmlelements, please let me know. I know it sounds stupid, but ejabberd 13 is not making it easy.

I'm using ejabberd 13 community from master.

Thx,

Have you found a solution for

Have you found a solution for this?
I am also trying to develop my first module on ejabberd,
I want to log all pubsub item publishes to an external API.

I got this as my payload, where a number of new lines are found - might be an issue with what i sent.

[{xmlcdata,<<"\n ">>},{xmlel,<<"entry">>,[{<<"xmlns">>,<<"http://www.w3.org/2005/Atom">>}],[{xmlcdata,<<"\n ">>},{xmlel,<<"title">>,[],[{xmlcdata,<<"Soliloquy">>}]},{xmlcdata,<<"\n ">>},{xmlel,<<"summary">>,[],[{xmlcdata,<<"To be, or not to be: that is the question:\n\nWhether 'tis nobler in the mind to suffer\n\nThe slings and arrows of outrageous fortune,\n\nOr to take arms against a sea of troubles,\n\nAnd by opposing end them?">>}]},{xmlcdata,<<"\n ">>},{xmlel,<<"link">>,[{<<"rel">>,<<"alternate">>},{<<"type">>,<<"text/html">>},{<<"href">>,<<"http://denmark.lit/2003/12/13/atom03">>}],[]},{xmlcdata,<<"\n ">>},{xmlel,<<"id">>,[],[{xmlcdata,<<"tag:denmark.lit,2003:entry-32397">>}]},{xmlcdata,<<"\n ">>},{xmlel,<<"published">>,[],[{xmlcdata,<<"2003-12-13T18:30:02Z">>}]},{xmlcdata,<<"\n ">>},{xmlel,<<"updated">>,[],[{xmlcdata,<<"2003-12-13T18:30:02Z">>}]},{xmlcdata,<<"\n ">>}]},{xmlcdata,<<"\n ">>}]

This looks correct to me. The

This looks correct to me. The payload is fine it seems that all is good.

Syndicate content