mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Let mod_carboncopy mark copied messages
Carbon copies are now marked with a 'carbon_copy' flag. This makes it easier to identify them.
This commit is contained in:
parent
114ca786ee
commit
3325e69ae6
@ -2645,22 +2645,17 @@ handle_unacked_stanzas(#state{mgmt_state = MgmtState} = StateData)
|
|||||||
Txt = <<"User session terminated">>,
|
Txt = <<"User session terminated">>,
|
||||||
ejabberd_router:route_error(
|
ejabberd_router:route_error(
|
||||||
To, From, El, xmpp:err_service_unavailable(Txt, Lang));
|
To, From, El, xmpp:err_service_unavailable(Txt, Lang));
|
||||||
(From, To, El, Time) ->
|
(From, _To, #message{meta = #{carbon_copy := true}}, _Time) ->
|
||||||
%% We'll drop the stanza if it was <forwarded/> by some
|
%% XEP-0280 says: "When a receiving server attempts to deliver a
|
||||||
%% encapsulating protocol as per XEP-0297. One such protocol is
|
%% forked message, and that message bounces with an error for
|
||||||
%% XEP-0280, which says: "When a receiving server attempts to
|
%% any reason, the receiving server MUST NOT forward that error
|
||||||
%% deliver a forked message, and that message bounces with an
|
%% back to the original sender." Resending such a stanza could
|
||||||
%% error for any reason, the receiving server MUST NOT forward
|
%% easily lead to unexpected results as well.
|
||||||
%% that error back to the original sender." Resending such a
|
|
||||||
%% stanza could easily lead to unexpected results as well.
|
|
||||||
case is_encapsulated_forward(El) of
|
|
||||||
true ->
|
|
||||||
?DEBUG("Dropping forwarded message stanza from ~s",
|
?DEBUG("Dropping forwarded message stanza from ~s",
|
||||||
[jid:to_string(From)]);
|
[jid:to_string(From)]);
|
||||||
false ->
|
(From, To, El, Time) ->
|
||||||
case ejabberd_hooks:run_fold(message_is_archived,
|
case ejabberd_hooks:run_fold(message_is_archived,
|
||||||
StateData#state.server,
|
StateData#state.server, false,
|
||||||
false,
|
|
||||||
[StateData, From,
|
[StateData, From,
|
||||||
StateData#state.jid, El]) of
|
StateData#state.jid, El]) of
|
||||||
true ->
|
true ->
|
||||||
@ -2669,20 +2664,11 @@ handle_unacked_stanzas(#state{mgmt_state = MgmtState} = StateData)
|
|||||||
false ->
|
false ->
|
||||||
ReRoute(From, To, El, Time)
|
ReRoute(From, To, El, Time)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
handle_unacked_stanzas(StateData, F);
|
handle_unacked_stanzas(StateData, F);
|
||||||
handle_unacked_stanzas(_StateData) ->
|
handle_unacked_stanzas(_StateData) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
-spec is_encapsulated_forward(stanza()) -> boolean().
|
|
||||||
is_encapsulated_forward(#message{} = Msg) ->
|
|
||||||
xmpp:has_subtag(Msg, #forwarded{}) orelse
|
|
||||||
xmpp:has_subtag(Msg, #carbons_sent{}) orelse
|
|
||||||
xmpp:has_subtag(Msg, #carbons_received{});
|
|
||||||
is_encapsulated_forward(_El) ->
|
|
||||||
false.
|
|
||||||
|
|
||||||
-spec inherit_session_state(state(), binary()) -> {ok, state()} |
|
-spec inherit_session_state(state(), binary()) -> {ok, state()} |
|
||||||
{error, binary()} |
|
{error, binary()} |
|
||||||
{error, binary(), non_neg_integer()}.
|
{error, binary(), non_neg_integer()}.
|
||||||
|
@ -52,9 +52,10 @@
|
|||||||
-callback list(binary(), binary()) -> [{binary(), binary()}].
|
-callback list(binary(), binary()) -> [{binary(), binary()}].
|
||||||
|
|
||||||
-spec is_carbon_copy(stanza()) -> boolean().
|
-spec is_carbon_copy(stanza()) -> boolean().
|
||||||
is_carbon_copy(Packet) ->
|
is_carbon_copy(#message{meta = #{carbon_copy := true}}) ->
|
||||||
xmpp:has_subtag(Packet, #carbons_sent{}) orelse
|
true;
|
||||||
xmpp:has_subtag(Packet, #carbons_received{}).
|
is_carbon_copy(_) ->
|
||||||
|
false.
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts,fun gen_iq_handler:check_type/1, one_queue),
|
IQDisc = gen_mod:get_opt(iqdisc, Opts,fun gen_iq_handler:check_type/1, one_queue),
|
||||||
@ -203,7 +204,8 @@ build_forward_packet(JID, #message{type = T} = Msg, Sender, Dest, Direction) ->
|
|||||||
sent -> #carbons_sent{forwarded = Forwarded};
|
sent -> #carbons_sent{forwarded = Forwarded};
|
||||||
received -> #carbons_received{forwarded = Forwarded}
|
received -> #carbons_received{forwarded = Forwarded}
|
||||||
end,
|
end,
|
||||||
#message{from = Sender, to = Dest, type = T, sub_els = [Carbon]}.
|
#message{from = Sender, to = Dest, type = T, sub_els = [Carbon],
|
||||||
|
meta = #{carbon_copy => true}}.
|
||||||
|
|
||||||
-spec enable(binary(), binary(), binary(), binary()) -> ok | {error, any()}.
|
-spec enable(binary(), binary(), binary(), binary()) -> ok | {error, any()}.
|
||||||
enable(Host, U, R, CC)->
|
enable(Host, U, R, CC)->
|
||||||
|
Loading…
Reference in New Issue
Block a user