25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

port commit from r2527 to odbc plugin

SVN Revision: 2544
This commit is contained in:
Christophe Romain 2009-08-27 08:26:22 +00:00
parent 3b27670d4d
commit 71e0d7d8e2
2 changed files with 16 additions and 3 deletions

View File

@ -697,7 +697,7 @@ set_subscriptions(NodeId, Owner, Subscription, SubId) ->
case {SubId, SubState#pubsub_state.subscriptions} of case {SubId, SubState#pubsub_state.subscriptions} of
{_, []} -> {_, []} ->
case Subscription of case Subscription of
none -> ok; none -> {error, ?ERR_EXTENDED('bad_request', "not-subscribed")};
_ -> new_subscription(NodeId, Owner, Subscription, SubState) _ -> new_subscription(NodeId, Owner, Subscription, SubState)
end; end;
{"", [{_, SID}]} -> {"", [{_, SID}]} ->

View File

@ -741,8 +741,10 @@ set_subscriptions(NodeId, Owner, Subscription, SubId) ->
SubState = get_state_without_itemids(NodeId, SubKey), SubState = get_state_without_itemids(NodeId, SubKey),
case {SubId, SubState#pubsub_state.subscriptions} of case {SubId, SubState#pubsub_state.subscriptions} of
{_, []} -> {_, []} ->
%% pablo TODO, there seems that commit 2528 was applied to mnesia but not ported to odbc case Subscription of
{error, 'item-not-found'}; none -> {error, ?ERR_EXTENDED('bad_request', "not-subscribed")};
_ -> new_subscription(NodeId, Owner, Subscription, SubState)
end;
{"", [{_, SID}]} -> {"", [{_, SID}]} ->
case Subscription of case Subscription of
none -> unsub_with_subid(NodeId, SID, SubState); none -> unsub_with_subid(NodeId, SID, SubState);
@ -767,6 +769,16 @@ replace_subscription(_, [], Acc) ->
replace_subscription({Sub, SubId}, [{_, SubID} | T], Acc) -> replace_subscription({Sub, SubId}, [{_, SubID} | T], Acc) ->
replace_subscription({Sub, SubId}, T, [{Sub, SubID} | 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, 'internal-server-error'}
end.
unsub_with_subid(NodeId, SubId, SubState) -> unsub_with_subid(NodeId, SubId, SubState) ->
pubsub_subscription_odbc:unsubscribe_node(SubState#pubsub_state.stateid, pubsub_subscription_odbc:unsubscribe_node(SubState#pubsub_state.stateid,
NodeId, SubId), NodeId, SubId),
@ -778,6 +790,7 @@ unsub_with_subid(NodeId, SubId, SubState) ->
_ -> _ ->
set_state(SubState#pubsub_state{subscriptions = NewSubs}) set_state(SubState#pubsub_state{subscriptions = NewSubs})
end. end.
%% @spec (Host, Owner) -> {result, [Node]} | {error, Reason} %% @spec (Host, Owner) -> {result, [Node]} | {error, Reason}
%% Host = host() %% Host = host()
%% Owner = jid() %% Owner = jid()