aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristophe Romain <christophe.romain@process-one.net>2009-08-27 08:17:44 +0000
committerChristophe Romain <christophe.romain@process-one.net>2009-08-27 08:17:44 +0000
commit670d7c7ebd3c35bc6bb59016898dd9234aa3df81 (patch)
tree6757c50112fd852e9aff5341c12e7efc0c818c7c /src
parentcheck if a room is not persistent before starting a new one with the same nam... (diff)
port commit from r2527 to odbc plugin
SVN Revision: 2543
Diffstat (limited to 'src')
-rw-r--r--src/mod_pubsub/node_hometree.erl2
-rw-r--r--src/mod_pubsub/node_hometree_odbc.erl15
2 files changed, 15 insertions, 2 deletions
diff --git a/src/mod_pubsub/node_hometree.erl b/src/mod_pubsub/node_hometree.erl
index cb7373677..5bb9be056 100644
--- a/src/mod_pubsub/node_hometree.erl
+++ b/src/mod_pubsub/node_hometree.erl
@@ -702,7 +702,7 @@ set_subscriptions(NodeId, Owner, Subscription, SubId) ->
case {SubId, SubState#pubsub_state.subscriptions} of
{_, []} ->
case Subscription of
- none -> ok;
+ none -> {error, ?ERR_EXTENDED(?ERR_BAD_REQUEST, "not-subscribed")};
_ -> new_subscription(NodeId, Owner, Subscription, SubState)
end;
{"", [{_, SID}]} ->
diff --git a/src/mod_pubsub/node_hometree_odbc.erl b/src/mod_pubsub/node_hometree_odbc.erl
index d4ffeca92..a9a815f57 100644
--- a/src/mod_pubsub/node_hometree_odbc.erl
+++ b/src/mod_pubsub/node_hometree_odbc.erl
@@ -740,7 +740,10 @@ set_subscriptions(NodeId, Owner, Subscription, SubId) ->
SubState = get_state_without_itemids(NodeId, SubKey),
case {SubId, SubState#pubsub_state.subscriptions} of
{_, []} ->
- {error, ?ERR_ITEM_NOT_FOUND};
+ case Subscription of
+ none -> {error, ?ERR_EXTENDED(?ERR_BAD_REQUEST, "not-subscribed")};
+ _ -> new_subscription(NodeId, Owner, Subscription, SubState)
+ end;
{"", [{_, SID}]} ->
case Subscription of
none -> unsub_with_subid(NodeId, SID, SubState);
@@ -765,6 +768,16 @@ replace_subscription(_, [], Acc) ->
replace_subscription({Sub, SubId}, [{_, SubID} | T], Acc) ->
replace_subscription({Sub, SubId}, T, [{Sub, SubID} | Acc]).
+new_subscription(NodeId, Owner, Subscription, SubState) ->
+ case pubsub_subscription_odbc:subscribe_node(Owner, NodeId, []) of
+ {result, SubId} ->
+ Subscriptions = SubState#pubsub_state.subscriptions,
+ set_state(SubState#pubsub_state{subscriptions = [{Subscription, SubId} | Subscriptions]}),
+ {Subscription, SubId};
+ _ ->
+ {error, ?ERR_INTERNAL_SERVER_ERROR}
+ end.
+
unsub_with_subid(NodeId, SubId, SubState) ->
pubsub_subscription_odbc:unsubscribe_node(SubState#pubsub_state.stateid,
NodeId, SubId),