mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Allow subscriber to create room, then set allow_subscription=true (#1404)
This commit is contained in:
parent
df92d96d4f
commit
fad7612cf1
@ -3702,7 +3702,7 @@ process_iq_vcard(From, #iq{type = set, lang = Lang, sub_els = [SubEl]},
|
|||||||
{ignore, state()}.
|
{ignore, state()}.
|
||||||
process_iq_mucsub(_From, #iq{type = set, lang = Lang,
|
process_iq_mucsub(_From, #iq{type = set, lang = Lang,
|
||||||
sub_els = [#muc_subscribe{}]},
|
sub_els = [#muc_subscribe{}]},
|
||||||
#state{config = #config{allow_subscription = false}}) ->
|
#state{just_created = false, config = #config{allow_subscription = false}}) ->
|
||||||
{error, xmpp:err_not_allowed(<<"Subscriptions are not allowed">>, Lang)};
|
{error, xmpp:err_not_allowed(<<"Subscriptions are not allowed">>, Lang)};
|
||||||
process_iq_mucsub(From,
|
process_iq_mucsub(From,
|
||||||
#iq{type = set, lang = Lang,
|
#iq{type = set, lang = Lang,
|
||||||
@ -3731,7 +3731,8 @@ process_iq_mucsub(From,
|
|||||||
NewStateData = set_subscriber(From, Nick, Nodes, StateData),
|
NewStateData = set_subscriber(From, Nick, Nodes, StateData),
|
||||||
{result, subscribe_result(Packet), NewStateData};
|
{result, subscribe_result(Packet), NewStateData};
|
||||||
error ->
|
error ->
|
||||||
add_new_user(From, Nick, Packet, StateData)
|
SD2 = maybe_enable_subscriptions(StateData),
|
||||||
|
add_new_user(From, Nick, Packet, SD2)
|
||||||
end;
|
end;
|
||||||
process_iq_mucsub(From, #iq{type = set, sub_els = [#muc_unsubscribe{}]},
|
process_iq_mucsub(From, #iq{type = set, sub_els = [#muc_unsubscribe{}]},
|
||||||
StateData) ->
|
StateData) ->
|
||||||
@ -3770,6 +3771,11 @@ process_iq_mucsub(_From, #iq{type = get, lang = Lang}, _StateData) ->
|
|||||||
Txt = <<"Value 'get' of 'type' attribute is not allowed">>,
|
Txt = <<"Value 'get' of 'type' attribute is not allowed">>,
|
||||||
{error, xmpp:err_bad_request(Txt, Lang)}.
|
{error, xmpp:err_bad_request(Txt, Lang)}.
|
||||||
|
|
||||||
|
maybe_enable_subscriptions(#state{just_created = JC, config = #config{allow_subscription = AS}} = SD) ->
|
||||||
|
SD#state{config = (SD#state.config)#config{allow_subscription = true}};
|
||||||
|
maybe_enable_subscriptions(SD) ->
|
||||||
|
SD.
|
||||||
|
|
||||||
remove_subscriptions(StateData) ->
|
remove_subscriptions(StateData) ->
|
||||||
if not (StateData#state.config)#config.allow_subscription ->
|
if not (StateData#state.config)#config.allow_subscription ->
|
||||||
StateData#state{subscribers = ?DICT:new(),
|
StateData#state{subscribers = ?DICT:new(),
|
||||||
|
Loading…
Reference in New Issue
Block a user