mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-18 22:15:20 +02:00
Use correct message type for last published items
When sending last published PubSub/PEP items, set the message type that was used for broadcasting those items originally.
This commit is contained in:
parent
e5428c5500
commit
d734f6beca
|
@ -87,7 +87,7 @@
|
||||||
unsubscribe_node/5,
|
unsubscribe_node/5,
|
||||||
publish_item/6,
|
publish_item/6,
|
||||||
delete_item/4,
|
delete_item/4,
|
||||||
send_items/6,
|
send_items/7,
|
||||||
get_items/2,
|
get_items/2,
|
||||||
get_item/3,
|
get_item/3,
|
||||||
get_cached_item/2,
|
get_cached_item/2,
|
||||||
|
@ -864,6 +864,7 @@ send_loop(State) ->
|
||||||
N,
|
N,
|
||||||
NodeId,
|
NodeId,
|
||||||
Type,
|
Type,
|
||||||
|
Options,
|
||||||
LJID,
|
LJID,
|
||||||
last);
|
last);
|
||||||
_ -> ok
|
_ -> ok
|
||||||
|
@ -960,6 +961,7 @@ send_loop(State) ->
|
||||||
Node,
|
Node,
|
||||||
NodeId,
|
NodeId,
|
||||||
Type,
|
Type,
|
||||||
|
Options,
|
||||||
LJID,
|
LJID,
|
||||||
last);
|
last);
|
||||||
true ->
|
true ->
|
||||||
|
@ -2926,7 +2928,8 @@ subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||||
{TNode, {Result, subscribed, SubId, send_last}}} ->
|
{TNode, {Result, subscribed, SubId, send_last}}} ->
|
||||||
NodeId = TNode#pubsub_node.id,
|
NodeId = TNode#pubsub_node.id,
|
||||||
Type = TNode#pubsub_node.type,
|
Type = TNode#pubsub_node.type,
|
||||||
send_items(Host, Node, NodeId, Type, Subscriber, last),
|
Options = TNode#pubsub_node.options,
|
||||||
|
send_items(Host, Node, NodeId, Type, Options, Subscriber, last),
|
||||||
case Result of
|
case Result of
|
||||||
default -> {result, Reply({subscribed, SubId})};
|
default -> {result, Reply({subscribed, SubId})};
|
||||||
_ -> {result, Result}
|
_ -> {result, Result}
|
||||||
|
@ -3388,14 +3391,15 @@ get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) ->
|
||||||
%% Node = pubsubNode()
|
%% Node = pubsubNode()
|
||||||
%% NodeId = pubsubNodeId()
|
%% NodeId = pubsubNodeId()
|
||||||
%% Type = pubsubNodeType()
|
%% Type = pubsubNodeType()
|
||||||
|
%% Options = mod_pubsub:nodeOptions()
|
||||||
%% LJID = {U, S, []}
|
%% LJID = {U, S, []}
|
||||||
%% Number = last | integer()
|
%% Number = last | integer()
|
||||||
%% @doc <p>Resend the items of a node to the user.</p>
|
%% @doc <p>Resend the items of a node to the user.</p>
|
||||||
%% @todo use cache-last-item feature
|
%% @todo use cache-last-item feature
|
||||||
send_items(Host, Node, NodeId, Type, LJID, last) ->
|
send_items(Host, Node, NodeId, Type, Options, LJID, last) ->
|
||||||
case get_cached_item(Host, NodeId) of
|
case get_cached_item(Host, NodeId) of
|
||||||
undefined ->
|
undefined ->
|
||||||
send_items(Host, Node, NodeId, Type, LJID, 1);
|
send_items(Host, Node, NodeId, Type, Options, LJID, 1);
|
||||||
LastItem ->
|
LastItem ->
|
||||||
{ModifNow, ModifUSR} =
|
{ModifNow, ModifUSR} =
|
||||||
LastItem#pubsub_item.modification,
|
LastItem#pubsub_item.modification,
|
||||||
|
@ -3405,9 +3409,9 @@ send_items(Host, Node, NodeId, Type, LJID, last) ->
|
||||||
children =
|
children =
|
||||||
itemsEls([LastItem])}],
|
itemsEls([LastItem])}],
|
||||||
ModifNow, ModifUSR),
|
ModifNow, ModifUSR),
|
||||||
dispatch_items(Host, LJID, Node, Stanza)
|
dispatch_items(Host, LJID, Node, Options, Stanza)
|
||||||
end;
|
end;
|
||||||
send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
send_items(Host, Node, NodeId, Type, Options, LJID, Number) ->
|
||||||
ToSend = case node_action(Host, Type, get_items,
|
ToSend = case node_action(Host, Type, get_items,
|
||||||
[NodeId, LJID])
|
[NodeId, LJID])
|
||||||
of
|
of
|
||||||
|
@ -3435,20 +3439,23 @@ send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||||
attrs = nodeAttr(Node),
|
attrs = nodeAttr(Node),
|
||||||
children = itemsEls(ToSend)}])
|
children = itemsEls(ToSend)}])
|
||||||
end,
|
end,
|
||||||
dispatch_items(Host, LJID, Node, Stanza).
|
dispatch_items(Host, LJID, Node, Options, Stanza).
|
||||||
|
|
||||||
-spec(dispatch_items/4 ::
|
-spec(dispatch_items/5 ::
|
||||||
(
|
(
|
||||||
From :: mod_pubsub:host(),
|
From :: mod_pubsub:host(),
|
||||||
To :: jid(),
|
To :: jid(),
|
||||||
Node :: mod_pubsub:nodeId(),
|
Node :: mod_pubsub:nodeId(),
|
||||||
Stanza :: xmlel() | undefined)
|
Options :: mod_pubsub:nodeOptions(),
|
||||||
|
Stanza :: xmlel() | undefined)
|
||||||
-> any()
|
-> any()
|
||||||
).
|
).
|
||||||
|
|
||||||
dispatch_items(_From, _To, _Node, _Stanza = undefined) -> ok;
|
dispatch_items(_From, _To, _Node, _Options, _Stanza = undefined) -> ok;
|
||||||
dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, Node,
|
dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, Node,
|
||||||
Stanza) ->
|
Options, BaseStanza) ->
|
||||||
|
NotificationType = get_option(Options, notification_type, headline),
|
||||||
|
Stanza = add_message_type(BaseStanza, NotificationType),
|
||||||
C2SPid = case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of
|
C2SPid = case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of
|
||||||
ToPid when is_pid(ToPid) -> ToPid;
|
ToPid when is_pid(ToPid) -> ToPid;
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -3465,7 +3472,9 @@ dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, Node,
|
||||||
service_jid(From), jlib:make_jid(To),
|
service_jid(From), jlib:make_jid(To),
|
||||||
Stanza)
|
Stanza)
|
||||||
end;
|
end;
|
||||||
dispatch_items(From, To, _Node, Stanza) ->
|
dispatch_items(From, To, _Node, Options, BaseStanza) ->
|
||||||
|
NotificationType = get_option(Options, notification_type, headline),
|
||||||
|
Stanza = add_message_type(BaseStanza, NotificationType),
|
||||||
ejabberd_router:route(service_jid(From), jlib:make_jid(To), Stanza).
|
ejabberd_router:route(service_jid(From), jlib:make_jid(To), Stanza).
|
||||||
|
|
||||||
%% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
|
%% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
unsubscribe_node/5,
|
unsubscribe_node/5,
|
||||||
publish_item/6,
|
publish_item/6,
|
||||||
delete_item/4,
|
delete_item/4,
|
||||||
send_items/6,
|
send_items/7,
|
||||||
get_items/2,
|
get_items/2,
|
||||||
get_item/3,
|
get_item/3,
|
||||||
get_cached_item/2,
|
get_cached_item/2,
|
||||||
|
@ -464,12 +464,16 @@ send_loop(State) ->
|
||||||
type =
|
type =
|
||||||
Type,
|
Type,
|
||||||
id =
|
id =
|
||||||
NodeId} =
|
NodeId,
|
||||||
|
options
|
||||||
|
=
|
||||||
|
Options} =
|
||||||
Node,
|
Node,
|
||||||
send_items(H,
|
send_items(H,
|
||||||
N,
|
N,
|
||||||
NodeId,
|
NodeId,
|
||||||
Type,
|
Type,
|
||||||
|
Options,
|
||||||
LJID,
|
LJID,
|
||||||
last);
|
last);
|
||||||
true ->
|
true ->
|
||||||
|
@ -564,6 +568,7 @@ send_loop(State) ->
|
||||||
Node,
|
Node,
|
||||||
NodeId,
|
NodeId,
|
||||||
Type,
|
Type,
|
||||||
|
Options,
|
||||||
LJID,
|
LJID,
|
||||||
last);
|
last);
|
||||||
true ->
|
true ->
|
||||||
|
@ -2550,7 +2555,8 @@ subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||||
{TNode, {Result, subscribed, SubId, send_last}}} ->
|
{TNode, {Result, subscribed, SubId, send_last}}} ->
|
||||||
NodeId = TNode#pubsub_node.id,
|
NodeId = TNode#pubsub_node.id,
|
||||||
Type = TNode#pubsub_node.type,
|
Type = TNode#pubsub_node.type,
|
||||||
send_items(Host, Node, NodeId, Type, Subscriber, last),
|
Options = TNode#pubsub_node.options,
|
||||||
|
send_items(Host, Node, NodeId, Type, Options, Subscriber, last),
|
||||||
case Result of
|
case Result of
|
||||||
default -> {result, Reply({subscribed, SubId})};
|
default -> {result, Reply({subscribed, SubId})};
|
||||||
_ -> {result, Result}
|
_ -> {result, Result}
|
||||||
|
@ -3018,11 +3024,12 @@ get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners, RSM) ->
|
||||||
%% Node = pubsubNode()
|
%% Node = pubsubNode()
|
||||||
%% NodeId = pubsubNodeId()
|
%% NodeId = pubsubNodeId()
|
||||||
%% Type = pubsubNodeType()
|
%% Type = pubsubNodeType()
|
||||||
|
%% Options = mod_pubsubnodeOptions()
|
||||||
%% LJID = {U, S, []}
|
%% LJID = {U, S, []}
|
||||||
%% Number = last | integer()
|
%% Number = last | integer()
|
||||||
%% @doc <p>Resend the items of a node to the user.</p>
|
%% @doc <p>Resend the items of a node to the user.</p>
|
||||||
%% @todo use cache-last-item feature
|
%% @todo use cache-last-item feature
|
||||||
send_items(Host, Node, NodeId, Type, LJID, last) ->
|
send_items(Host, Node, NodeId, Type, Options, LJID, last) ->
|
||||||
Stanza = case get_cached_item(Host, NodeId) of
|
Stanza = case get_cached_item(Host, NodeId) of
|
||||||
undefined ->
|
undefined ->
|
||||||
% special ODBC optimization, works only with node_hometree_odbc, node_flat_odbc and node_pep_odbc
|
% special ODBC optimization, works only with node_hometree_odbc, node_flat_odbc and node_pep_odbc
|
||||||
|
@ -3047,8 +3054,8 @@ send_items(Host, Node, NodeId, Type, LJID, last) ->
|
||||||
itemsEls([LastItem])}],
|
itemsEls([LastItem])}],
|
||||||
ModifNow, ModifUSR)
|
ModifNow, ModifUSR)
|
||||||
end,
|
end,
|
||||||
dispatch_items(Host, LJID, Node, Stanza);
|
dispatch_items(Host, LJID, Node, Options, Stanza);
|
||||||
send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
send_items(Host, Node, NodeId, Type, Options, LJID, Number) ->
|
||||||
ToSend = case node_action(Host, Type, get_items,
|
ToSend = case node_action(Host, Type, get_items,
|
||||||
[NodeId, LJID])
|
[NodeId, LJID])
|
||||||
of
|
of
|
||||||
|
@ -3076,20 +3083,23 @@ send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||||
attrs = nodeAttr(Node),
|
attrs = nodeAttr(Node),
|
||||||
children = itemsEls(ToSend)}])
|
children = itemsEls(ToSend)}])
|
||||||
end,
|
end,
|
||||||
dispatch_items(Host, LJID, Node, Stanza).
|
dispatch_items(Host, LJID, Node, Options, Stanza).
|
||||||
|
|
||||||
-spec(dispatch_items/4 ::
|
-spec(dispatch_items/5 ::
|
||||||
(
|
(
|
||||||
From :: mod_pubsub:host(),
|
From :: mod_pubsub:host(),
|
||||||
To :: jid(),
|
To :: jid(),
|
||||||
Node :: mod_pubsub:nodeId(),
|
Node :: mod_pubsub:nodeId(),
|
||||||
Stanza :: xmlel() | undefined)
|
Options :: mod_pubsub:nodeOptions(),
|
||||||
|
Stanza :: xmlel() | undefined)
|
||||||
-> any()
|
-> any()
|
||||||
).
|
).
|
||||||
|
|
||||||
dispatch_items(_From, _To, _Node, _Stanza = undefined) -> ok;
|
dispatch_items(_From, _To, _Node, _Options, _Stanza = undefined) -> ok;
|
||||||
dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, Node,
|
dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, Node,
|
||||||
Stanza) ->
|
Options, BaseStanza) ->
|
||||||
|
NotificationType = get_option(Options, notification_type, headline),
|
||||||
|
Stanza = add_message_type(BaseStanza, NotificationType),
|
||||||
C2SPid = case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of
|
C2SPid = case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of
|
||||||
ToPid when is_pid(ToPid) -> ToPid;
|
ToPid when is_pid(ToPid) -> ToPid;
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -3106,7 +3116,9 @@ dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, Node,
|
||||||
service_jid(From), jlib:make_jid(To),
|
service_jid(From), jlib:make_jid(To),
|
||||||
Stanza)
|
Stanza)
|
||||||
end;
|
end;
|
||||||
dispatch_items(From, To, _Node, Stanza) ->
|
dispatch_items(From, To, _Node, Options, BaseStanza) ->
|
||||||
|
NotificationType = get_option(Options, notification_type, headline),
|
||||||
|
Stanza = add_message_type(BaseStanza, NotificationType),
|
||||||
ejabberd_router:route(service_jid(From), jlib:make_jid(To), Stanza).
|
ejabberd_router:route(service_jid(From), jlib:make_jid(To), Stanza).
|
||||||
|
|
||||||
%% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
|
%% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user