{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.20"}}},
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.10"}}},
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "dbf173f"}}},
- {xmpp, ".*", {git, "https://github.com/processone/xmpp", {tag, "2bb82b29"}}},
+ {xmpp, ".*", {git, "https://github.com/processone/xmpp", {tag, "0a1c76e"}}},
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.12"}}},
{jiffy, ".*", {git, "https://github.com/davisp/jiffy", {tag, "0.14.8"}}},
{p1_oauth2, ".*", {git, "https://github.com/processone/p1_oauth2", {tag, "0.6.2"}}},
%% gen_mod API
-export([start/2, stop/1, reload/3, depends/2, mod_opt_type/1, mod_options/1]).
%% Hooks
--export([pubsub_publish_item/6, vcard_iq_convert/1, vcard_iq_publish/1]).
+-export([pubsub_publish_item/6, vcard_iq_convert/1, vcard_iq_publish/1,
+ get_sm_features/5]).
-include("xmpp.hrl").
-include("logger.hrl").
ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE,
vcard_iq_convert, 30),
ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE,
- vcard_iq_publish, 100).
+ vcard_iq_publish, 100),
+ ejabberd_hooks:add(disco_sm_features, Host, ?MODULE,
+ get_sm_features, 50).
stop(Host) ->
ejabberd_hooks:delete(pubsub_publish_item, Host, ?MODULE,
pubsub_publish_item, 50),
ejabberd_hooks:delete(vcard_iq_set, Host, ?MODULE, vcard_iq_convert, 30),
- ejabberd_hooks:delete(vcard_iq_set, Host, ?MODULE, vcard_iq_publish, 100).
+ ejabberd_hooks:delete(vcard_iq_set, Host, ?MODULE, vcard_iq_publish, 100),
+ ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE,
+ get_sm_features, 50).
reload(_Host, _NewOpts, _OldOpts) ->
ok.
vcard_iq_publish(Acc) ->
Acc.
+-spec get_sm_features({error, stanza_error()} | empty | {result, [binary()]},
+ jid(), jid(), binary(), binary()) ->
+ {error, stanza_error()} | empty | {result, [binary()]}.
+get_sm_features({error, _Error} = Acc, _From, _To, _Node, _Lang) ->
+ Acc;
+get_sm_features(Acc, _From, _To, <<"">>, _Lang) ->
+ {result, [?NS_DISCO_INFO, ?NS_PEP_VCARD_CONVERSION_0 |
+ case Acc of
+ {result, Features} -> Features;
+ empty -> []
+ end]};
+get_sm_features(Acc, _From, _To, _Node, _Lang) ->
+ Acc.
+
%%%===================================================================
%%% Internal functions
%%%===================================================================
%%%----------------------------------------------------------------------
-module(mod_vcard_xupdate).
-
-behaviour(gen_mod).
+-protocol({xep, 398, '0.2.0'}).
+
%% gen_mod callbacks
-export([start/2, stop/1, reload/3]).
-> {presence(), ejabberd_c2s:state()}.
update_presence({#presence{type = available} = Pres,
#{jid := #jid{luser = LUser, lserver = LServer}} = State}) ->
- Pres1 = case get_xupdate(LUser, LServer) of
- undefined -> xmpp:remove_subtag(Pres, #vcard_xupdate{});
- XUpdate -> xmpp:set_subtag(Pres, XUpdate)
- end,
- {Pres1, State};
+ case xmpp:get_subtag(Pres, #vcard_xupdate{}) of
+ #vcard_xupdate{hash = <<>>} ->
+ %% XEP-0398 forbids overwriting vcard:x:update
+ %% tags with empty <photo/> element
+ {Pres, State};
+ _ ->
+ Pres1 = case get_xupdate(LUser, LServer) of
+ undefined -> xmpp:remove_subtag(Pres, #vcard_xupdate{});
+ XUpdate -> xmpp:set_subtag(Pres, XUpdate)
+ end,
+ {Pres1, State}
+ end;
update_presence(Acc) ->
Acc.