Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristophe Romain <christophe.romain@process-one.net>2018-03-16 19:17:53 +0300
committerChristophe Romain <christophe.romain@process-one.net>2018-03-16 19:17:53 +0300
commitd8f9219b4f820b7c65782d1aad76c1dae0a0ba9f (patch)
tree7256e252ddebf4f4755a13ac2e5cd86901164471 /src
parentddc29d42dea818c2c88f5da6f4e5baa9b93e7dec (diff)
Refactor publish_item conditions (#2267)
Diffstat (limited to 'src')
-rw-r--r--src/mod_pubsub.erl14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl
index 10c875229..49a460a37 100644
--- a/src/mod_pubsub.erl
+++ b/src/mod_pubsub.erl
@@ -1112,7 +1112,7 @@ iq_pubsub(Host, Access, #iq{from = From, type = IQType, lang = Lang,
Payload, PubOpts, Access)
end;
[] ->
- {error, extended_error(xmpp:err_bad_request(), err_item_required())};
+ publish_item(Host, ServerHost, Node, From, <<>>, [], [], Access);
_ ->
{error, extended_error(xmpp:err_bad_request(), err_invalid_payload())}
end;
@@ -1785,19 +1785,15 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload, PubOpts, Access
PayloadSize > PayloadMaxSize ->
{error, extended_error(xmpp:err_not_acceptable(),
err_payload_too_big())};
- (PayloadCount == 0) and (Payload == []) ->
+ (DeliverPayloads or PersistItems) and (PayloadCount == 0) ->
{error, extended_error(xmpp:err_bad_request(),
- err_payload_required())};
- (PayloadCount > 1) or (PayloadCount == 0) ->
+ err_item_required())};
+ (DeliverPayloads or PersistItems) and (PayloadCount > 1) ->
{error, extended_error(xmpp:err_bad_request(),
err_invalid_payload())};
- (DeliverPayloads == false) and (PersistItems == false) and
- (PayloadSize > 0) ->
+ (not DeliverPayloads) and (PayloadCount > 0) ->
{error, extended_error(xmpp:err_bad_request(),
err_item_forbidden())};
- ((DeliverPayloads == true) or (PersistItems == true)) and (PayloadSize == 0) ->
- {error, extended_error(xmpp:err_bad_request(),
- err_item_required())};
true ->
node_call(Host, Type, publish_item,
[Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload, PubOpts])