I'm trying to save offline ejabberd messages in Riak. I earlier had problems connecting to Riak but those are resolved now with the help of this forum. But now, with my limited Erlang / ejabberd understanding, I'm failing to get the ejabberd packet saved as a string and then put on Riak. Essentially, when the offline_message_hook is latched, I take the Packet argument and then want to put a backslash for each double quote, so that I can then take this revised string and save as a string value on Riak. However I seem to be struggling with modifying the incoming packet to replace the " chars with \".
Is this the right approach? Or am I missing something here in my design? My application relies on the xml format, so should I instead parse the packet using the p1_xml module and reconstruct the xml using the extracted data elements before storing it on Riak.
Apologies for the very basic and multiple questions but appreciate if someone can throw some light here!
The code that I use to try and replace the " with \" in the incoming packet is: (it doesnt quite work):
NewPacket = re:replace(Packet, "\"", "\\\"", [{return, list}, global]),
So essentially, I would be passing the NewPacket as a value to my Riak calls.
{xmlel,<<"message">>,[{<<"type">>,<<"chat">>},{<<"id">>,<<"purplefe7f4130">>},{<<"to">>,<<"[email protected]">>}],[{xmlel,<<"active">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/chatstates">>}],[]},{xmlel,<<"body">>,[],[{xmlcdata,<<"my text message">>}]}]}
– vikram17000