ejabberd_route:route

Hi, I am trying to send a IQ stanza to another user, using ejabberd_route:route, but it seems like the other user never receives it.

Here is my code block

From = jlib:make_jid(LUser, LServer, "fb"),
To = jlib:make_jid(TUser, TServer, "fb"),
FromAddress = jlib:jid_to_string(From),
ToAddress = jlib:jid_to_string(To),
XmlBody = {xmlelement, "iq", [{"type", "get"}, {"id", "up1"}, {"from", FromAddress}, {"to", ToAddress}], [{xmlelement, "save", {"xmlns", ?NS_ARCHIVE}}]},
ejabberd_router:route(From, To, XmlBody),

Script compiles and this block runs inside of mod_archive_odbc. TServer, TUser, LServer, LUser are all valid strings and correct values

Thanks again.

Your initial code is

Your initial code is equivalent to this, and it doesn't work:

test() ->
    LUser = "tom",
    LServer = "localhost",
    From = jlib:make_jid(LUser, LServer, "fb"),
    TUser = "badlop",
    TServer = "localhost",
    To = jlib:make_jid(TUser, TServer, "fb"),
    FromAddress = jlib:jid_to_string(From),
    ToAddress = jlib:jid_to_string(To),
    XmlSave = {xmlelement, "save", {"xmlns", ?NS_ARCHIVE}},
    XmlBody = {xmlelement,
              "iq",
              [{"type", "get"},
               {"id", "up1"},
               {"from", FromAddress},
               {"to", ToAddress}],
              [XmlSave]},
    ejabberd_router:route(From, To, XmlBody).

It doesn't work because XmlSave is wrong: you forgot to add two []. Change that line with this, and it will work:

XmlSave = {xmlelement, "save", [{"xmlns", ?NS_ARCHIVE}], []},
Syndicate content