mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-02 16:37:52 +01:00
subscribing to a node sends only last items (EJAB-700), send_last_items bugfix
SVN Revision: 1473
This commit is contained in:
parent
c6090dd8ca
commit
895e104b6a
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
* src/mod_pubsub/mod_pubsub.erl: remove_user hook removes
|
* src/mod_pubsub/mod_pubsub.erl: remove_user hook removes
|
||||||
subscriptions (EJAB-684), send the last published and not the
|
subscriptions (EJAB-684), send the last published and not the
|
||||||
first published item (EJAB-675), remove the pubsub/nodes tree.
|
first published item (EJAB-675), remove the pubsub/nodes tree,
|
||||||
|
subscribing to a node sends only last items (EJAB-700)
|
||||||
* src/mod_pubsub/node_pep.erl: added acl and jid match on node
|
* src/mod_pubsub/node_pep.erl: added acl and jid match on node
|
||||||
creation permission (EJAB-663)
|
creation permission (EJAB-663)
|
||||||
* src/mod_pubsub/node_default.erl: fix node creation permission
|
* src/mod_pubsub/node_default.erl: fix node creation permission
|
||||||
|
@ -1386,7 +1386,7 @@ subscribe_node(Host, Node, From, JID) ->
|
|||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
{error, Error};
|
{error, Error};
|
||||||
{result, {Result, subscribed, send_last}} ->
|
{result, {Result, subscribed, send_last}} ->
|
||||||
send_all_items(Host, Node, Subscriber),
|
send_last_item(Host, Node, Subscriber),
|
||||||
case Result of
|
case Result of
|
||||||
default -> {result, Reply(subscribed)};
|
default -> {result, Reply(subscribed)};
|
||||||
_ -> {result, Result}
|
_ -> {result, Result}
|
||||||
@ -1733,21 +1733,25 @@ send_last_item(Host, Node, LJID) ->
|
|||||||
|
|
||||||
%% TODO use cache-last-item feature
|
%% TODO use cache-last-item feature
|
||||||
send_items(Host, Node, LJID, Number) ->
|
send_items(Host, Node, LJID, Number) ->
|
||||||
Items = get_items(Host, Node),
|
ToSend = case get_items(Host, Node) of
|
||||||
ToSend = case Number of
|
[] ->
|
||||||
last -> hd(lists:reverse(Items));
|
[];
|
||||||
all -> Items;
|
Items ->
|
||||||
N when N > 0 -> lists:nthtail(length(Items)-N, Items);
|
case Number of
|
||||||
_ -> Items
|
last -> lists:sublist(lists:reverse(Items), 1);
|
||||||
end,
|
all -> Items;
|
||||||
|
N when N > 0 -> lists:nthtail(length(Items)-N, Items);
|
||||||
|
_ -> Items
|
||||||
|
end
|
||||||
|
end,
|
||||||
ItemsEls = lists:map(
|
ItemsEls = lists:map(
|
||||||
fun(#pubsub_item{itemid = {ItemId, _}, payload = Payload}) ->
|
fun(#pubsub_item{itemid = {ItemId, _}, payload = Payload}) ->
|
||||||
ItemAttrs = case ItemId of
|
ItemAttrs = case ItemId of
|
||||||
"" -> [];
|
"" -> [];
|
||||||
_ -> [{"id", ItemId}]
|
_ -> [{"id", ItemId}]
|
||||||
end,
|
end,
|
||||||
{xmlelement, "item", ItemAttrs, Payload}
|
{xmlelement, "item", ItemAttrs, Payload}
|
||||||
end, ToSend),
|
end, ToSend),
|
||||||
Stanza = {xmlelement, "message", [],
|
Stanza = {xmlelement, "message", [],
|
||||||
[{xmlelement, "event", [{"xmlns", ?NS_PUBSUB_EVENT}],
|
[{xmlelement, "event", [{"xmlns", ?NS_PUBSUB_EVENT}],
|
||||||
[{xmlelement, "items", [{"node", node_to_string(Node)}],
|
[{xmlelement, "items", [{"node", node_to_string(Node)}],
|
||||||
|
Loading…
Reference in New Issue
Block a user