mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-02 16:37:52 +01:00
Fix send_last_published_item issue when running on clustered table (EJAB-793)
SVN Revision: 1739
This commit is contained in:
parent
cd1eddde1a
commit
2890c01979
@ -1,3 +1,8 @@
|
|||||||
|
2008-12-19 Christophe Romain <christophe.romain@process-one.net>
|
||||||
|
|
||||||
|
* src/mod_pubsub/mod_pubsub.erl: Fix send_last_published_item issue
|
||||||
|
when running on clustered table (thanks to Vincent Barat)(EJAB-793)
|
||||||
|
|
||||||
2008-12-16 Badlop <badlop@process-one.net>
|
2008-12-16 Badlop <badlop@process-one.net>
|
||||||
|
|
||||||
* src/mod_pubsub/mod_pubsub.erl: Fix update pubsub tables from
|
* src/mod_pubsub/mod_pubsub.erl: Fix update pubsub tables from
|
||||||
|
@ -1728,24 +1728,41 @@ get_items(Host, Node) ->
|
|||||||
%% Host = host()
|
%% Host = host()
|
||||||
%% Node = pubsubNode()
|
%% Node = pubsubNode()
|
||||||
%% LJID = {U,S,""}
|
%% LJID = {U,S,""}
|
||||||
%% @doc <p>Resend the items of a node to the user.</p>
|
%% @doc <p>Resend the last item of a node to the user.</p>
|
||||||
send_all_items(Host, Node, LJID) ->
|
|
||||||
send_items(Host, Node, LJID, all).
|
|
||||||
|
|
||||||
send_last_item(Host, Node, LJID) ->
|
send_last_item(Host, Node, LJID) ->
|
||||||
send_items(Host, Node, LJID, last).
|
send_items(Host, Node, LJID, last).
|
||||||
|
|
||||||
%% TODO use cache-last-item feature
|
%% @spec (Host, Node, LJID) -> any()
|
||||||
|
%% Host = host()
|
||||||
|
%% Node = pubsubNode()
|
||||||
|
%% LJID = {U, S, []}
|
||||||
|
%% @doc <p>Resend the items of a node to the user.</p>
|
||||||
|
%% @todo use cache-last-item feature
|
||||||
send_items(Host, Node, LJID, Number) ->
|
send_items(Host, Node, LJID, Number) ->
|
||||||
ToSend = case get_items(Host, Node) of
|
ToSend = case get_items(Host, Node) of
|
||||||
[] ->
|
[] ->
|
||||||
[];
|
[];
|
||||||
Items ->
|
Items ->
|
||||||
case Number of
|
case Number of
|
||||||
last -> lists:sublist(lists:reverse(Items), 1);
|
last ->
|
||||||
all -> Items;
|
%%% [lists:last(Items)] does not work on clustered table
|
||||||
N when N > 0 -> lists:nthtail(length(Items)-N, Items);
|
[First|Tail] = Items,
|
||||||
_ -> Items
|
[lists:foldl(
|
||||||
|
fun(CurItem, LastItem) ->
|
||||||
|
{_, {LMS, LS, LmS}} = LastItem#pubsub_item.creation,
|
||||||
|
{_, {CMS, CS, CmS}} = CurItem#pubsub_item.creation,
|
||||||
|
LTimestamp = LMS * 1000000 + LS * 1000 + LmS,
|
||||||
|
CTimestamp = CMS * 1000000 + CS * 1000 + CmS,
|
||||||
|
if
|
||||||
|
CTimestamp > LTimestamp -> CurItem;
|
||||||
|
true -> LastItem
|
||||||
|
end
|
||||||
|
end, First, Tail)];
|
||||||
|
N when N > 0 ->
|
||||||
|
%%% This case is buggy on clustered table due to lake of order
|
||||||
|
lists:nthtail(length(Items)-N, Items);
|
||||||
|
_ ->
|
||||||
|
Items
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
ItemsEls = lists:map(
|
ItemsEls = lists:map(
|
||||||
|
Loading…
Reference in New Issue
Block a user