From fd26056d01884b5210520bebad2d3930a693021e Mon Sep 17 00:00:00 2001 From: Badlop Date: Wed, 25 Feb 2009 21:17:14 +0000 Subject: [PATCH] * src/mod_pubsub/mod_pubsub.erl: Fix incorrect implementation of Pubsub payload requirements (thanks to Andy Skelton)(EJAB-823) SVN Revision: 1921 --- ChangeLog | 5 +++++ src/mod_pubsub/mod_pubsub.erl | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a93abae1..a1a8a9114 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-02-25 Badlop + + * src/mod_pubsub/mod_pubsub.erl: Fix incorrect implementation of + Pubsub payload requirements (thanks to Andy Skelton)(EJAB-823) + 2009-02-24 Badlop * src/ejabberd_listener.erl: Fix report message of 'undef' error diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl index f4781b2f3..f2bf6122d 100644 --- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -1492,6 +1492,8 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) -> PublishFeature = lists:member("publish", Features), PublishModel = get_option(Options, publish_model), MaxItems = max_items(Options), + DeliverPayloads = get_option(Options, deliver_payloads), + PersistItems = get_option(Options, persist_items), PayloadCount = payload_xmlelements(Payload), PayloadSize = size(term_to_binary(Payload)), PayloadMaxSize = get_option(Options, max_payload_size), @@ -1510,11 +1512,11 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) -> Payload == "" -> %% Publisher attempts to publish to payload node with no payload {error, extended_error(?ERR_BAD_REQUEST, "payload-required")}; - (MaxItems == 0) and (PayloadSize > 0) -> - % Publisher attempts to publish to transient notification node with item + (DeliverPayloads == 0) and (PersistItems == 0) and (PayloadSize > 0) -> + %% Publisher attempts to publish to transient notification node with item {error, extended_error(?ERR_BAD_REQUEST, "item-forbidden")}; - (MaxItems > 0) and (PayloadSize == 0) -> - % Publisher attempts to publish to persistent node with no item + ((DeliverPayloads == 1) or (PersistItems == 1)) and (PayloadSize == 0) -> + %% Publisher attempts to publish to persistent node with no item {error, extended_error(?ERR_BAD_REQUEST, "item-required")}; true -> node_call(Type, publish_item, [Host, Node, Publisher, PublishModel, MaxItems, ItemId, Payload])