In earlier versions I have made these enhancements to the mod_admin_extra to enable the publishing of content to a pubsub node. The latest version which has the EJAB-823 fix the code fails and I have spent 3 days trying to figure out why. Below is the code that I am using to call the publish_item. The format of the Payload is the issue.
#ejabberd_commands{name = publish_message, tags = [stanza], desc = "Publish a message to a channel", module = ?MODULE, function = publish_message, args = [{user, string}, {channel, string}, {data,string}], result = {res, rescode}},
...
publish_message(UserString, ChannelString, DataString) -> Host = "pubsub.b.pollzer.com", Domain = "b.pollzer.com", Node = ["home","b.pollzer.com",UserString,ChannelString], [FilteredPayload] = [{xmlcdata, DataString}], io:format("Filtered Payload: ~p~n", [FilteredPayload]), mod_pubsub_odbc:publish_item(Host, Domain, Node, jlib:make_jid(UserString,Domain,""),"",[FilteredPayload]).
Any assistance in how the [FilteredPayload] should be formated would be of great assistance.
Thanks,
John Wyman
Does it show any error
Does it show any error message, either in the ejabberdctl shell or in ejabberd log files?
Error
This is the error that I receive. I have some additional debug statements to help me resolve. The second set of messages is what publish_item is receiving from psi when I try to send a publish_item with the xml console. It looks like it is expecting xml and I have tried to create the same xml but still having issues.
ERROR:
Raw Message: {call,publish_message,
[{struct,[{user,"6"},{channel,"Test"},{data,"This is a test"}]}]}
Filtered Payload: {xmlcdata,"This is a test"}
=ERROR REPORT==== 9-Mar-2010::13:34:26 ===
E(<0.381.0>:mod_pubsub_odbc:3553) : transaction return internal error: {aborted,
{badarg,
[{erlang,
binary_to_list,
[["home",
"b.pollzer.com",
"6", "Test"]]},
{mod_pubsub_odbc,
node_to_string,
1},
{nodetree_tree_odbc,
get_node,
2},
{mod_pubsub_odbc,
tree_call,
3},
{mod_pubsub_odbc,
'-transaction/4-fun-0-',
3},
{ejabberd_odbc,
execute_bloc,
1},
{ejabberd_odbc,
handle_call,
3},
{gen_server,
handle_msg,
5}]}}
=ERROR REPORT==== 9-Mar-2010::13:34:26 ===
W(<0.381.0>:ejabberd_xmlrpc:323) : Error -118
A problem '{error,
{xmlelement,"error",
[{"code","500"},{"type","wait"}],
[{xmlelement,"internal-server-error",
[{"xmlns","urn:ietf:params:xml:ns:xmpp-stanzas"}],
[]}]}}' occurred executing the command publish_message with arguments
[{user,"6"},{channel,"Test"},{data,"This is a test"}]
Valid Send via PSI
=INFO REPORT==== 9-Mar-2010::13:38:13 ===
I(<0.398.0>:ejabberd_c2s:825) : ({socket_state,tls,{tlssock,#Port<0.456>,#Port<0.465>},<0.397.0>}) Opened session for 6@b.pollzer.com/JOHN_WYMAN
PubMsg: [{xmlcdata,<<"\n ">>},
{xmlelement,"entry",[],[{xmlcdata,<<"This is a test Message">>}]},
{xmlcdata,<<"\n ">>}]
From PSI I can publish to the node: home/b.pollzer.com/6/Test
Thanks,
John
Node format
When I call Publish_item passing node as:
Node = ["home", "b.pollzer.com", "6", "Test"]
Publish_item receives node as : ["home", "b.pollzer.com", "6", "Test"]
When a publish from PSI publish_item received node as:
Node = <<"home/b.pollzer.com/6/Test">>
How do I get the Node to format correctly for the call to publish_item.
John
simple conversion
When I call Publish_item passing node as:
Node = ["home", "b.pollzer.com", "6", "Test"]
Publish_item receives node as : ["home", "b.pollzer.com", "6", "Test"]
When a publish from PSI publish_item received node as:
Node = <<"home/b.pollzer.com/6/Test">>
How do I get the Node to format correctly for the call to publish_item.
Simple:
Did The Trick
Thank you very much - that did the trick and everything is working as expected.
John