mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
mod_pubsub: Fix last item cache for multiple hosts
Don't let the last item cache intermix PubSub items of different virtual domains.
This commit is contained in:
parent
56ef607904
commit
14e771d871
@ -166,7 +166,7 @@
|
||||
|
||||
-record(pubsub_last_item,
|
||||
{
|
||||
nodeid ,% :: mod_pubsub:nodeIdx(),
|
||||
nodeid ,% :: {binary(), mod_pubsub:nodeIdx()},
|
||||
itemid ,% :: mod_pubsub:itemId(),
|
||||
creation ,% :: {erlang:timestamp(), jlib:ljid()},
|
||||
payload % :: mod_pubsub:payload()
|
||||
|
@ -177,7 +177,7 @@
|
||||
|
||||
-type(pubsubLastItem() ::
|
||||
#pubsub_last_item{
|
||||
nodeid :: mod_pubsub:nodeIdx(),
|
||||
nodeid :: {binary(), mod_pubsub:nodeIdx()},
|
||||
itemid :: mod_pubsub:itemId(),
|
||||
creation :: {erlang:timestamp(), ljid()},
|
||||
payload :: mod_pubsub:payload()
|
||||
@ -3426,7 +3426,7 @@ 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, Nidx, ItemId,
|
||||
true -> mnesia:dirty_write({pubsub_last_item, {Host, Nidx}, ItemId,
|
||||
{p1_time_compat:timestamp(), jid:tolower(jid:remove_resource(Publisher))},
|
||||
Payload});
|
||||
_ -> ok
|
||||
@ -3437,7 +3437,7 @@ unset_cached_item({_, ServerHost, _}, Nidx) ->
|
||||
unset_cached_item(ServerHost, Nidx);
|
||||
unset_cached_item(Host, Nidx) ->
|
||||
case is_last_item_cache_enabled(Host) of
|
||||
true -> mnesia:dirty_delete({pubsub_last_item, Nidx});
|
||||
true -> mnesia:dirty_delete({pubsub_last_item, {Host, Nidx}});
|
||||
_ -> ok
|
||||
end.
|
||||
|
||||
@ -3447,8 +3447,8 @@ get_cached_item({_, ServerHost, _}, Nidx) ->
|
||||
get_cached_item(Host, Nidx) ->
|
||||
case is_last_item_cache_enabled(Host) of
|
||||
true ->
|
||||
case mnesia:dirty_read({pubsub_last_item, Nidx}) of
|
||||
[#pubsub_last_item{itemid = ItemId, creation = Creation, payload = Payload}] ->
|
||||
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_item{itemid = {ItemId, Nidx},
|
||||
|
Loading…
Reference in New Issue
Block a user