25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Fix match of itemid on get_cached_item, fixes 14e771d8

This commit is contained in:
Christophe Romain 2017-02-22 17:44:47 +01:00
parent 56df6e7ba8
commit 87b5e2500b

View File

@ -3423,10 +3423,15 @@ set_cached_item({_, ServerHost, _}, Nidx, ItemId, Publisher, Payload) ->
set_cached_item(ServerHost, Nidx, ItemId, Publisher, Payload);
set_cached_item(Host, Nidx, ItemId, Publisher, Payload) ->
case is_last_item_cache_enabled(Host) of
true -> mnesia:dirty_write({pubsub_last_item, {Host, Nidx}, ItemId,
{p1_time_compat:timestamp(), jid:tolower(jid:remove_resource(Publisher))},
Payload});
_ -> ok
true ->
Stamp = {p1_time_compat:timestamp(), jid:tolower(jid:remove_resource(Publisher))},
Item = #pubsub_last_item{nodeid = {Host, Nidx},
itemid = ItemId,
creation = Stamp,
payload = Payload},
mnesia:dirty_write(Item);
_ ->
ok
end.
-spec unset_cached_item(host(), nodeIdx()) -> ok.
@ -3445,9 +3450,7 @@ get_cached_item(Host, Nidx) ->
case is_last_item_cache_enabled(Host) of
true ->
case mnesia:dirty_read({pubsub_last_item, {Host, Nidx}}) of
[#pubsub_last_item{itemid = {Host, ItemId}, creation = Creation, payload = Payload}] ->
% [{pubsub_last_item, Nidx, ItemId, Creation,
% Payload}] ->
[#pubsub_last_item{itemid = ItemId, creation = Creation, payload = Payload}] ->
#pubsub_item{itemid = {ItemId, Nidx},
payload = Payload, creation = Creation,
modification = Creation};