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

Support to provide password when subscribing to a room (#1306)

This commit is contained in:
Badlop 2016-11-10 20:48:43 +01:00
parent bd060bc1bb
commit 566ac872fe

View File

@ -4653,7 +4653,8 @@ process_iq_mucsub(From, Packet,
NewStateData = set_subscriber(From, Nick, Nodes, StateData),
{result, subscription_nodes_to_events(Nodes), NewStateData};
error ->
add_new_user(From, Nick, Packet, StateData)
Packet2 = copy_password_xelement(Packet),
add_new_user(From, Nick, Packet2, StateData)
end;
_ ->
Err = ?ERRT_NOT_ALLOWED(Lang, <<"Subscriptions are not allowed">>),
@ -4697,6 +4698,11 @@ process_iq_mucsub(_From, _Packet, #iq{lang = Lang}, _StateData) ->
Txt = <<"Unrecognized subscription command">>,
{error, ?ERRT_BAD_REQUEST(Lang, Txt)}.
copy_password_xelement(Packet) ->
SubsEl = fxml:get_subtag_with_xmlns(Packet, <<"subscribe">>, ?NS_MUCSUB),
XEl = fxml:get_subtag_with_xmlns(SubsEl, <<"x">>, ?NS_MUC),
fxml:append_subtags(Packet, [XEl]).
remove_subscriptions(StateData) ->
if not (StateData#state.config)#config.allow_subscription ->
StateData#state{subscribers = ?DICT:new(),