25
1
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:
Christophe Romain 2008-07-23 01:13:36 +00:00
parent c6090dd8ca
commit 895e104b6a
2 changed files with 21 additions and 16 deletions

View File

@ -2,7 +2,8 @@
* src/mod_pubsub/mod_pubsub.erl: remove_user hook removes
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
creation permission (EJAB-663)
* src/mod_pubsub/node_default.erl: fix node creation permission

View File

@ -1386,7 +1386,7 @@ subscribe_node(Host, Node, From, JID) ->
{error, Error} ->
{error, Error};
{result, {Result, subscribed, send_last}} ->
send_all_items(Host, Node, Subscriber),
send_last_item(Host, Node, Subscriber),
case Result of
default -> {result, Reply(subscribed)};
_ -> {result, Result}
@ -1733,12 +1733,16 @@ send_last_item(Host, Node, LJID) ->
%% TODO use cache-last-item feature
send_items(Host, Node, LJID, Number) ->
Items = get_items(Host, Node),
ToSend = case Number of
last -> hd(lists:reverse(Items));
ToSend = case get_items(Host, Node) of
[] ->
[];
Items ->
case Number of
last -> lists:sublist(lists:reverse(Items), 1);
all -> Items;
N when N > 0 -> lists:nthtail(length(Items)-N, Items);
_ -> Items
end
end,
ItemsEls = lists:map(
fun(#pubsub_item{itemid = {ItemId, _}, payload = Payload}) ->