diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2015-09-22 12:18:06 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2015-09-22 12:23:36 +0300 |
commit | 70b1dc479c77b23532b06376a24c9eeb9436db13 (patch) | |
tree | 41e860b44385be4ce84aa30f86db5ddd53b11b7e | |
parent | e57c1896f716bf53d2256feab6a08ce41c358c9e (diff) |
Add MAM (XEP-0313) v0.4 support
-rw-r--r-- | include/ns.hrl | 1 | ||||
-rw-r--r-- | src/mod_mam.erl | 13 |
2 files changed, 10 insertions, 4 deletions
diff --git a/include/ns.hrl b/include/ns.hrl index 71f454cad..0685ae65c 100644 --- a/include/ns.hrl +++ b/include/ns.hrl @@ -143,6 +143,7 @@ -define(NS_BOB, <<"urn:xmpp:bob">>). -define(NS_MAM_TMP, <<"urn:xmpp:mam:tmp">>). -define(NS_MAM_0, <<"urn:xmpp:mam:0">>). +-define(NS_MAM_1, <<"urn:xmpp:mam:1">>). -define(NS_PING, <<"urn:xmpp:ping">>). -define(NS_CARBONS_2, <<"urn:xmpp:carbons:2">>). -define(NS_CARBONS_1, <<"urn:xmpp:carbons:1">>). diff --git a/src/mod_mam.erl b/src/mod_mam.erl index b476ff681..cd9dd7e40 100644 --- a/src/mod_mam.erl +++ b/src/mod_mam.erl @@ -75,6 +75,10 @@ start(Host, Opts) -> ?NS_MAM_0, ?MODULE, process_iq_v0_3, IQDisc), gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MAM_0, ?MODULE, process_iq_v0_3, IQDisc), + gen_iq_handler:add_iq_handler(ejabberd_local, Host, + ?NS_MAM_1, ?MODULE, process_iq_v0_3, IQDisc), + gen_iq_handler:add_iq_handler(ejabberd_sm, Host, + ?NS_MAM_1, ?MODULE, process_iq_v0_3, IQDisc), ejabberd_hooks:add(user_receive_packet, Host, ?MODULE, user_receive_packet, 500), ejabberd_hooks:add(user_send_packet, Host, ?MODULE, @@ -123,6 +127,8 @@ stop(Host) -> gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_MAM_TMP), gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_MAM_0), gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_MAM_0), + gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_MAM_1), + gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_MAM_1), ejabberd_hooks:delete(remove_user, Host, ?MODULE, remove_user, 50), ejabberd_hooks:delete(anonymous_purge_hook, Host, @@ -716,7 +722,7 @@ send(From, To, Msgs, RSM, Count, IsComplete, #iq{sub_el = SubEl} = IQ) -> end, CompleteAttr = if NS == ?NS_MAM_TMP -> []; - NS == ?NS_MAM_0 -> + NS == ?NS_MAM_0; NS == ?NS_MAM_1 -> [{<<"complete">>, jlib:atom_to_binary(IsComplete)}] end, Els = lists:map( @@ -728,14 +734,13 @@ send(From, To, Msgs, RSM, Count, IsComplete, #iq{sub_el = SubEl} = IQ) -> children = [El]}]} end, Msgs), RSMOut = make_rsm_out(Msgs, RSM, Count, QIDAttr ++ CompleteAttr, NS), - case NS of - ?NS_MAM_TMP -> + if NS == ?NS_MAM_TMP; NS == ?NS_MAM_1 -> lists:foreach( fun(El) -> ejabberd_router:route(To, From, El) end, Els), IQ#iq{type = result, sub_el = RSMOut}; - ?NS_MAM_0 -> + NS == ?NS_MAM_0 -> ejabberd_router:route( To, From, jlib:iq_to_xml(IQ#iq{type = result, sub_el = []})), lists:foreach( |