diff options
author | Christophe Romain <christophe.romain@process-one.net> | 2017-02-22 17:44:47 +0100 |
---|---|---|
committer | Christophe Romain <christophe.romain@process-one.net> | 2017-02-22 17:44:47 +0100 |
commit | 87b5e2500b09c9ca96d8f039e03a45c759c7f77f (patch) | |
tree | 8f84d65bfdcdcd4c166d16c85d099ed9a0c63d30 /src | |
parent | Add missing NOT NULL restrictions (diff) |
Fix match of itemid on get_cached_item, fixes 14e771d8
Diffstat (limited to 'src')
-rw-r--r-- | src/mod_pubsub.erl | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl index 2013ed9c..e512afa0 100644 --- a/src/mod_pubsub.erl +++ b/src/mod_pubsub.erl @@ -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}; |