2013-03-27 17:53:56 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
%%% File : mod_carboncopy.erl
|
|
|
|
%%% Author : Eric Cestari <ecestari@process-one.net>
|
|
|
|
%%% Purpose : Message Carbons XEP-0280 0.8
|
|
|
|
%%% Created : 5 May 2008 by Mickael Remond <mremond@process-one.net>
|
2013-08-12 14:25:05 +02:00
|
|
|
%%% Usage : Add the following line in modules section of ejabberd.yml:
|
2013-03-27 17:53:56 +01:00
|
|
|
%%% {mod_carboncopy, []}
|
|
|
|
%%%
|
|
|
|
%%%
|
2024-01-22 16:40:01 +01:00
|
|
|
%%% ejabberd, Copyright (C) 2002-2024 ProcessOne
|
2013-03-27 17:53:56 +01:00
|
|
|
%%%
|
|
|
|
%%% This program is free software; you can redistribute it and/or
|
|
|
|
%%% modify it under the terms of the GNU General Public License as
|
|
|
|
%%% published by the Free Software Foundation; either version 2 of the
|
|
|
|
%%% License, or (at your option) any later version.
|
|
|
|
%%%
|
|
|
|
%%% This program is distributed in the hope that it will be useful,
|
|
|
|
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
%%% General Public License for more details.
|
|
|
|
%%%
|
2014-02-22 11:27:40 +01:00
|
|
|
%%% You should have received a copy of the GNU General Public License along
|
|
|
|
%%% with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2013-03-27 17:53:56 +01:00
|
|
|
%%%
|
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
-module (mod_carboncopy).
|
2015-10-07 00:06:58 +02:00
|
|
|
|
2013-03-27 17:53:56 +01:00
|
|
|
-author ('ecestari@process-one.net').
|
2020-04-05 22:52:55 +02:00
|
|
|
-protocol({xep, 280, '0.13.2'}).
|
2013-03-27 17:53:56 +01:00
|
|
|
|
2018-01-31 14:57:43 +01:00
|
|
|
-behaviour(gen_mod).
|
2013-03-27 17:53:56 +01:00
|
|
|
|
|
|
|
%% API:
|
2017-02-22 17:46:47 +01:00
|
|
|
-export([start/2, stop/1, reload/3]).
|
2013-03-27 17:53:56 +01:00
|
|
|
|
2017-01-09 15:02:17 +01:00
|
|
|
-export([user_send_packet/1, user_receive_packet/1,
|
2018-12-01 11:33:44 +01:00
|
|
|
iq_handler/1, disco_features/5,
|
2020-01-12 14:04:31 +01:00
|
|
|
depends/2, mod_options/1, mod_doc/0]).
|
2023-11-20 18:55:07 +01:00
|
|
|
-export([c2s_copy_session/2, c2s_session_opened/1, c2s_session_resumed/1,
|
|
|
|
c2s_inline_features/2, c2s_handle_bind2_inline/1]).
|
2018-12-01 11:33:44 +01:00
|
|
|
%% For debugging purposes
|
|
|
|
-export([list/2]).
|
2013-03-27 17:53:56 +01:00
|
|
|
|
2013-04-08 11:12:54 +02:00
|
|
|
-include("logger.hrl").
|
2020-09-03 13:45:57 +02:00
|
|
|
-include_lib("xmpp/include/xmpp.hrl").
|
2019-06-22 16:08:45 +02:00
|
|
|
-include("translate.hrl").
|
2013-03-27 17:53:56 +01:00
|
|
|
|
2016-07-18 14:01:32 +02:00
|
|
|
-type direction() :: sent | received.
|
2018-12-10 09:53:27 +01:00
|
|
|
-type c2s_state() :: ejabberd_c2s:state().
|
2016-07-18 14:01:32 +02:00
|
|
|
|
2023-08-04 17:53:50 +02:00
|
|
|
start(_Host, _Opts) ->
|
|
|
|
{ok, [{hook, disco_local_features, disco_features, 50},
|
|
|
|
%% why priority 89: to define clearly that we must run BEFORE mod_logdb hook (90)
|
|
|
|
{hook, user_send_packet, user_send_packet, 89},
|
|
|
|
{hook, user_receive_packet, user_receive_packet, 89},
|
|
|
|
{hook, c2s_copy_session, c2s_copy_session, 50},
|
|
|
|
{hook, c2s_session_resumed, c2s_session_resumed, 50},
|
|
|
|
{hook, c2s_session_opened, c2s_session_opened, 50},
|
2023-11-20 18:55:07 +01:00
|
|
|
{hook, c2s_inline_features, c2s_inline_features, 50},
|
|
|
|
{hook, c2s_handle_bind2_inline, c2s_handle_bind2_inline, 50},
|
|
|
|
{iq_handler, ejabberd_sm, ?NS_CARBONS_2, iq_handler}]}.
|
2013-03-27 17:53:56 +01:00
|
|
|
|
2023-08-04 17:53:50 +02:00
|
|
|
stop(_Host) ->
|
|
|
|
ok.
|
2013-03-27 17:53:56 +01:00
|
|
|
|
2018-12-01 11:33:44 +01:00
|
|
|
reload(_Host, _NewOpts, _OldOpts) ->
|
|
|
|
ok.
|
2017-02-22 17:46:47 +01:00
|
|
|
|
2017-01-09 15:02:17 +01:00
|
|
|
-spec disco_features({error, stanza_error()} | {result, [binary()]} | empty,
|
|
|
|
jid(), jid(), binary(), binary()) ->
|
|
|
|
{error, stanza_error()} | {result, [binary()]}.
|
2020-01-12 13:42:00 +01:00
|
|
|
disco_features(empty, From, To, <<"">>, Lang) ->
|
|
|
|
disco_features({result, []}, From, To, <<"">>, Lang);
|
2017-01-09 15:02:17 +01:00
|
|
|
disco_features({result, Feats}, _From, _To, <<"">>, _Lang) ->
|
2020-01-12 13:42:00 +01:00
|
|
|
{result, [?NS_CARBONS_2,?NS_CARBONS_RULES_0|Feats]};
|
2017-01-09 15:02:17 +01:00
|
|
|
disco_features(Acc, _From, _To, _Node, _Lang) ->
|
|
|
|
Acc.
|
|
|
|
|
2016-07-18 14:01:32 +02:00
|
|
|
-spec iq_handler(iq()) -> iq().
|
|
|
|
iq_handler(#iq{type = set, lang = Lang, from = From,
|
|
|
|
sub_els = [El]} = IQ) when is_record(El, carbons_enable);
|
|
|
|
is_record(El, carbons_disable) ->
|
2015-11-24 16:44:13 +01:00
|
|
|
{U, S, R} = jid:tolower(From),
|
2016-07-18 14:01:32 +02:00
|
|
|
Result = case El of
|
2018-12-01 11:33:44 +01:00
|
|
|
#carbons_enable{} -> enable(S, U, R, ?NS_CARBONS_2);
|
|
|
|
#carbons_disable{} -> disable(S, U, R)
|
2016-07-18 14:01:32 +02:00
|
|
|
end,
|
2015-10-07 00:06:58 +02:00
|
|
|
case Result of
|
2016-07-18 14:01:32 +02:00
|
|
|
ok ->
|
|
|
|
xmpp:make_iq_result(IQ);
|
2018-12-01 11:33:44 +01:00
|
|
|
{error, _} ->
|
2019-06-22 16:08:45 +02:00
|
|
|
Txt = ?T("Database failure"),
|
2016-07-18 14:01:32 +02:00
|
|
|
xmpp:make_error(IQ, xmpp:err_internal_server_error(Txt, Lang))
|
2013-03-27 17:53:56 +01:00
|
|
|
end;
|
2016-07-18 14:01:32 +02:00
|
|
|
iq_handler(#iq{type = set, lang = Lang} = IQ) ->
|
2019-06-22 16:08:45 +02:00
|
|
|
Txt = ?T("Only <enable/> or <disable/> tags are allowed"),
|
2016-07-18 14:01:32 +02:00
|
|
|
xmpp:make_error(IQ, xmpp:err_bad_request(Txt, Lang));
|
|
|
|
iq_handler(#iq{type = get, lang = Lang} = IQ)->
|
2019-06-22 16:08:45 +02:00
|
|
|
Txt = ?T("Value 'get' of 'type' attribute is not allowed"),
|
2016-07-18 14:01:32 +02:00
|
|
|
xmpp:make_error(IQ, xmpp:err_not_allowed(Txt, Lang)).
|
2013-03-27 17:53:56 +01:00
|
|
|
|
2017-01-09 15:02:17 +01:00
|
|
|
-spec user_send_packet({stanza(), ejabberd_c2s:state()})
|
|
|
|
-> {stanza(), ejabberd_c2s:state()} | {stop, {stanza(), ejabberd_c2s:state()}}.
|
2020-01-12 14:04:31 +01:00
|
|
|
user_send_packet({#message{meta = #{carbon_copy := true}}, _C2SState} = Acc) ->
|
|
|
|
%% Stop the hook chain, we don't want logging modules to duplicate this
|
|
|
|
%% message.
|
|
|
|
{stop, Acc};
|
2020-01-13 00:31:01 +01:00
|
|
|
user_send_packet({#message{from = From, to = To} = Msg, C2SState}) ->
|
|
|
|
{check_and_forward(From, To, Msg, sent), C2SState};
|
|
|
|
user_send_packet(Acc) ->
|
|
|
|
Acc.
|
2014-04-07 22:10:08 +02:00
|
|
|
|
2017-01-09 15:02:17 +01:00
|
|
|
-spec user_receive_packet({stanza(), ejabberd_c2s:state()})
|
|
|
|
-> {stanza(), ejabberd_c2s:state()} | {stop, {stanza(), ejabberd_c2s:state()}}.
|
2020-01-12 14:04:31 +01:00
|
|
|
user_receive_packet({#message{meta = #{carbon_copy := true}}, _C2SState} = Acc) ->
|
|
|
|
%% Stop the hook chain, we don't want logging modules to duplicate this
|
|
|
|
%% message.
|
|
|
|
{stop, Acc};
|
2020-01-13 00:31:01 +01:00
|
|
|
user_receive_packet({#message{to = To} = Msg, #{jid := JID} = C2SState}) ->
|
|
|
|
{check_and_forward(JID, To, Msg, received), C2SState};
|
|
|
|
user_receive_packet(Acc) ->
|
|
|
|
Acc.
|
2015-10-07 00:06:58 +02:00
|
|
|
|
2018-12-10 09:53:27 +01:00
|
|
|
-spec c2s_copy_session(c2s_state(), c2s_state()) -> c2s_state().
|
|
|
|
c2s_copy_session(State, #{user := U, server := S, resource := R}) ->
|
|
|
|
case ejabberd_sm:get_user_info(U, S, R) of
|
|
|
|
offline -> State;
|
|
|
|
Info ->
|
|
|
|
case lists:keyfind(carboncopy, 1, Info) of
|
|
|
|
{_, CC} -> State#{carboncopy => CC};
|
|
|
|
false -> State
|
|
|
|
end
|
|
|
|
end.
|
|
|
|
|
|
|
|
-spec c2s_session_resumed(c2s_state()) -> c2s_state().
|
|
|
|
c2s_session_resumed(#{user := U, server := S, resource := R,
|
|
|
|
carboncopy := CC} = State) ->
|
|
|
|
ejabberd_sm:set_user_info(U, S, R, carboncopy, CC),
|
|
|
|
maps:remove(carboncopy, State);
|
|
|
|
c2s_session_resumed(State) ->
|
|
|
|
State.
|
|
|
|
|
|
|
|
-spec c2s_session_opened(c2s_state()) -> c2s_state().
|
|
|
|
c2s_session_opened(State) ->
|
|
|
|
maps:remove(carboncopy, State).
|
|
|
|
|
2023-11-20 18:55:07 +01:00
|
|
|
c2s_inline_features({Sasl, Bind} = Acc, Host) ->
|
|
|
|
case gen_mod:is_loaded(Host, ?MODULE) of
|
|
|
|
true ->
|
|
|
|
{Sasl, [#bind2_feature{var = ?NS_CARBONS_2} | Bind]};
|
|
|
|
false ->
|
|
|
|
Acc
|
|
|
|
end.
|
|
|
|
|
|
|
|
c2s_handle_bind2_inline({#{user := U, server := S, resource := R} = State, Els, Results}) ->
|
|
|
|
case lists:keyfind(carbons_enable, 1, Els) of
|
|
|
|
#carbons_enable{} ->
|
|
|
|
enable(S, U, R, ?NS_CARBONS_2),
|
|
|
|
{State, Els, Results};
|
|
|
|
_ ->
|
|
|
|
{State, Els, Results}
|
|
|
|
end.
|
|
|
|
|
2015-10-07 00:06:58 +02:00
|
|
|
% Modified from original version:
|
2013-03-27 17:53:56 +01:00
|
|
|
% - registered to the user_send_packet hook, to be called only once even for multicast
|
|
|
|
% - do not support "private" message mode, and do not modify the original packet in any way
|
|
|
|
% - we also replicate "read" notifications
|
2020-01-13 00:31:01 +01:00
|
|
|
-spec check_and_forward(jid(), jid(), message(), direction()) -> message().
|
|
|
|
check_and_forward(JID, To, Msg, Direction)->
|
|
|
|
case (is_chat_message(Msg) orelse
|
|
|
|
is_received_muc_invite(Msg, Direction)) andalso
|
|
|
|
not is_received_muc_pm(To, Msg, Direction) andalso
|
|
|
|
not xmpp:has_subtag(Msg, #carbons_private{}) andalso
|
|
|
|
not xmpp:has_subtag(Msg, #hint{type = 'no-copy'}) of
|
2014-05-30 23:44:19 +02:00
|
|
|
true ->
|
2020-01-13 00:31:01 +01:00
|
|
|
send_copies(JID, To, Msg, Direction);
|
2020-01-12 14:04:31 +01:00
|
|
|
false ->
|
|
|
|
ok
|
|
|
|
end,
|
2020-01-13 00:31:01 +01:00
|
|
|
Msg.
|
2013-03-27 17:53:56 +01:00
|
|
|
|
|
|
|
%%% Internal
|
|
|
|
%% Direction = received | sent <received xmlns='urn:xmpp:carbons:1'/>
|
2016-07-18 14:01:32 +02:00
|
|
|
-spec send_copies(jid(), jid(), message(), direction()) -> ok.
|
2020-01-13 00:31:01 +01:00
|
|
|
send_copies(JID, To, Msg, Direction)->
|
2015-11-24 16:44:13 +01:00
|
|
|
{U, S, R} = jid:tolower(JID),
|
2014-04-08 23:32:30 +02:00
|
|
|
PrioRes = ejabberd_sm:get_user_present_resources(U, S),
|
2015-02-11 16:12:08 +01:00
|
|
|
{_, AvailRs} = lists:unzip(PrioRes),
|
2016-11-22 19:25:20 +01:00
|
|
|
{MaxPrio, _MaxRes} = case catch lists:max(PrioRes) of
|
2014-11-05 19:04:02 +01:00
|
|
|
{Prio, Res} -> {Prio, Res};
|
|
|
|
_ -> {0, undefined}
|
|
|
|
end,
|
2014-04-08 23:32:30 +02:00
|
|
|
|
2015-02-12 00:14:57 +01:00
|
|
|
%% unavailable resources are handled like bare JIDs
|
2014-04-08 23:32:30 +02:00
|
|
|
IsBareTo = case {Direction, To} of
|
|
|
|
{received, #jid{lresource = <<>>}} -> true;
|
2015-02-12 00:14:57 +01:00
|
|
|
{received, #jid{lresource = LRes}} -> not lists:member(LRes, AvailRs);
|
2014-04-08 23:32:30 +02:00
|
|
|
_ -> false
|
|
|
|
end,
|
2013-03-27 17:53:56 +01:00
|
|
|
%% list of JIDs that should receive a carbon copy of this message (excluding the
|
2014-04-07 22:10:08 +02:00
|
|
|
%% receiver(s) of the original message
|
2020-01-13 00:31:01 +01:00
|
|
|
TargetJIDs = case {IsBareTo, Msg} of
|
2016-11-22 19:25:20 +01:00
|
|
|
{true, #message{meta = #{sm_copy := true}}} ->
|
2014-11-05 19:04:02 +01:00
|
|
|
%% The message was sent to our bare JID, and we currently have
|
|
|
|
%% multiple resources with the same highest priority, so the session
|
|
|
|
%% manager routes the message to each of them. We create carbon
|
2016-11-22 19:25:20 +01:00
|
|
|
%% copies only from one of those resources in order to avoid
|
|
|
|
%% duplicates.
|
2014-11-05 19:04:02 +01:00
|
|
|
[];
|
2016-11-22 19:25:20 +01:00
|
|
|
{true, _} ->
|
|
|
|
OrigTo = fun(Res) -> lists:member({MaxPrio, Res}, PrioRes) end,
|
|
|
|
[ {jid:make({U, S, CCRes}), CC_Version}
|
|
|
|
|| {CCRes, CC_Version} <- list(U, S),
|
|
|
|
lists:member(CCRes, AvailRs), not OrigTo(CCRes) ];
|
2014-11-05 19:04:02 +01:00
|
|
|
{false, _} ->
|
2015-11-24 16:44:13 +01:00
|
|
|
[ {jid:make({U, S, CCRes}), CC_Version}
|
2015-02-11 16:12:08 +01:00
|
|
|
|| {CCRes, CC_Version} <- list(U, S),
|
|
|
|
lists:member(CCRes, AvailRs), CCRes /= R ]
|
2015-11-24 16:44:13 +01:00
|
|
|
%TargetJIDs = lists:delete(JID, [ jid:make({U, S, CCRes}) || CCRes <- list(U, S) ]),
|
2014-04-07 22:10:08 +02:00
|
|
|
end,
|
2013-03-27 17:53:56 +01:00
|
|
|
|
2019-06-14 11:33:26 +02:00
|
|
|
lists:foreach(
|
|
|
|
fun({Dest, _Version}) ->
|
|
|
|
{_, _, Resource} = jid:tolower(Dest),
|
|
|
|
?DEBUG("Sending: ~p =/= ~p", [R, Resource]),
|
|
|
|
Sender = jid:make({U, S, <<>>}),
|
2020-01-13 00:45:33 +01:00
|
|
|
New = build_forward_packet(Msg, Sender, Dest, Direction),
|
2019-06-14 11:33:26 +02:00
|
|
|
ejabberd_router:route(xmpp:set_from_to(New, Sender, Dest))
|
|
|
|
end, TargetJIDs).
|
2013-03-27 17:53:56 +01:00
|
|
|
|
2020-01-13 00:45:33 +01:00
|
|
|
-spec build_forward_packet(message(), jid(), jid(), direction()) -> message().
|
|
|
|
build_forward_packet(#message{type = T} = Msg, Sender, Dest, Direction) ->
|
|
|
|
Forwarded = #forwarded{sub_els = [Msg]},
|
2016-07-18 14:01:32 +02:00
|
|
|
Carbon = case Direction of
|
|
|
|
sent -> #carbons_sent{forwarded = Forwarded};
|
|
|
|
received -> #carbons_received{forwarded = Forwarded}
|
|
|
|
end,
|
2016-11-22 22:21:34 +01:00
|
|
|
#message{from = Sender, to = Dest, type = T, sub_els = [Carbon],
|
|
|
|
meta = #{carbon_copy => true}}.
|
2013-03-27 17:53:56 +01:00
|
|
|
|
2016-07-18 14:01:32 +02:00
|
|
|
-spec enable(binary(), binary(), binary(), binary()) -> ok | {error, any()}.
|
2013-03-27 17:53:56 +01:00
|
|
|
enable(Host, U, R, CC)->
|
2019-09-23 14:17:20 +02:00
|
|
|
?DEBUG("Enabling carbons for ~ts@~ts/~ts", [U, Host, R]),
|
2018-12-01 11:33:44 +01:00
|
|
|
case ejabberd_sm:set_user_info(U, Host, R, carboncopy, CC) of
|
|
|
|
ok -> ok;
|
|
|
|
{error, Reason} = Err ->
|
2019-09-23 14:17:20 +02:00
|
|
|
?ERROR_MSG("Failed to enable carbons for ~ts@~ts/~ts: ~p",
|
2018-12-01 11:33:44 +01:00
|
|
|
[U, Host, R, Reason]),
|
2017-04-14 12:57:52 +02:00
|
|
|
Err
|
|
|
|
end.
|
2013-03-27 17:53:56 +01:00
|
|
|
|
2016-07-18 14:01:32 +02:00
|
|
|
-spec disable(binary(), binary(), binary()) -> ok | {error, any()}.
|
2013-03-27 17:53:56 +01:00
|
|
|
disable(Host, U, R)->
|
2019-09-23 14:17:20 +02:00
|
|
|
?DEBUG("Disabling carbons for ~ts@~ts/~ts", [U, Host, R]),
|
2018-12-01 11:33:44 +01:00
|
|
|
case ejabberd_sm:del_user_info(U, Host, R, carboncopy) of
|
|
|
|
ok -> ok;
|
|
|
|
{error, notfound} -> ok;
|
|
|
|
{error, Reason} = Err ->
|
2019-09-23 14:17:20 +02:00
|
|
|
?ERROR_MSG("Failed to disable carbons for ~ts@~ts/~ts: ~p",
|
2018-12-01 11:33:44 +01:00
|
|
|
[U, Host, R, Reason]),
|
|
|
|
Err
|
|
|
|
end.
|
2013-03-27 17:53:56 +01:00
|
|
|
|
2020-01-13 00:31:01 +01:00
|
|
|
-spec is_chat_message(message()) -> boolean().
|
2016-07-18 14:01:32 +02:00
|
|
|
is_chat_message(#message{type = chat}) ->
|
|
|
|
true;
|
2016-11-18 11:38:08 +01:00
|
|
|
is_chat_message(#message{type = normal, body = [_|_]}) ->
|
|
|
|
true;
|
2020-01-12 13:42:00 +01:00
|
|
|
is_chat_message(#message{type = Type} = Msg) when Type == chat;
|
|
|
|
Type == normal ->
|
|
|
|
has_chatstate(Msg) orelse xmpp:has_subtag(Msg, #receipt_response{});
|
2016-07-18 14:01:32 +02:00
|
|
|
is_chat_message(_) ->
|
|
|
|
false.
|
|
|
|
|
2020-01-12 13:42:00 +01:00
|
|
|
-spec is_received_muc_invite(message(), direction()) -> boolean().
|
2020-01-13 00:31:01 +01:00
|
|
|
is_received_muc_invite(_Msg, sent) ->
|
2020-01-12 13:42:00 +01:00
|
|
|
false;
|
2020-01-13 00:31:01 +01:00
|
|
|
is_received_muc_invite(Msg, received) ->
|
|
|
|
case xmpp:get_subtag(Msg, #muc_user{}) of
|
2020-01-13 00:13:54 +01:00
|
|
|
#muc_user{invites = [_|_]} ->
|
|
|
|
true;
|
|
|
|
_ ->
|
2020-03-18 12:02:16 +01:00
|
|
|
xmpp:has_subtag(Msg, #x_conference{jid = jid:make(<<"">>)})
|
2020-01-13 00:13:54 +01:00
|
|
|
end.
|
2020-01-12 13:42:00 +01:00
|
|
|
|
2018-02-22 00:40:09 +01:00
|
|
|
-spec is_received_muc_pm(jid(), message(), direction()) -> boolean().
|
2020-01-13 00:31:01 +01:00
|
|
|
is_received_muc_pm(#jid{lresource = <<>>}, _Msg, _Direction) ->
|
2016-09-19 22:46:36 +02:00
|
|
|
false;
|
2020-01-13 00:31:01 +01:00
|
|
|
is_received_muc_pm(_To, _Msg, sent) ->
|
2018-02-22 00:40:09 +01:00
|
|
|
false;
|
2020-01-13 00:31:01 +01:00
|
|
|
is_received_muc_pm(_To, Msg, received) ->
|
|
|
|
xmpp:has_subtag(Msg, #muc_user{}).
|
2014-11-24 22:37:14 +01:00
|
|
|
|
2020-01-12 13:42:00 +01:00
|
|
|
-spec has_chatstate(message()) -> boolean().
|
|
|
|
has_chatstate(#message{sub_els = Els}) ->
|
|
|
|
lists:any(fun(El) -> xmpp:get_ns(El) == ?NS_CHATSTATES end, Els).
|
|
|
|
|
2017-04-14 12:57:52 +02:00
|
|
|
-spec list(binary(), binary()) -> [{Resource :: binary(), Namespace :: binary()}].
|
2015-10-07 00:06:58 +02:00
|
|
|
list(User, Server) ->
|
2018-12-01 11:33:44 +01:00
|
|
|
lists:filtermap(
|
|
|
|
fun({Resource, Info}) ->
|
|
|
|
case lists:keyfind(carboncopy, 1, Info) of
|
|
|
|
{_, NS} -> {true, {Resource, NS}};
|
|
|
|
false -> false
|
|
|
|
end
|
|
|
|
end, ejabberd_sm:get_user_info(User, Server)).
|
2015-06-01 14:38:27 +02:00
|
|
|
|
2016-07-07 11:17:38 +02:00
|
|
|
depends(_Host, _Opts) ->
|
|
|
|
[].
|
|
|
|
|
2018-12-01 11:33:44 +01:00
|
|
|
mod_options(_) ->
|
2019-06-14 11:33:26 +02:00
|
|
|
[].
|
2020-01-08 10:24:51 +01:00
|
|
|
|
|
|
|
mod_doc() ->
|
|
|
|
#{desc =>
|
|
|
|
?T("The module implements https://xmpp.org/extensions/xep-0280.html"
|
|
|
|
"[XEP-0280: Message Carbons]. "
|
|
|
|
"The module broadcasts messages on all connected "
|
|
|
|
"user resources (devices).")}.
|