25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

* src/mod_muc/mod_muc_room.erl: Corrected error messages when

trying to join members-only room (thanks to Badlop)

* src/ejabberd_c2s.erl: Added c2s_update_presence hook

SVN Revision: 770
This commit is contained in:
Alexey Shchepin 2007-05-16 10:13:04 +00:00
parent 897cc13f42
commit 8c326ea928
3 changed files with 87 additions and 76 deletions

View File

@ -1,3 +1,10 @@
2007-05-16 Alexey Shchepin <alexey@sevcom.net>
* src/mod_muc/mod_muc_room.erl: Corrected error messages when
trying to join members-only room (thanks to Badlop)
* src/ejabberd_c2s.erl: Added c2s_update_presence hook
2007-05-14 Alexey Shchepin <alexey@sevcom.net>
* src/ejd2odbc.erl: Bugfix (thanks to Badlop)

View File

@ -804,15 +804,22 @@ session_established({xmlstreamelement, El}, StateData) ->
_ ->
case Name of
"presence" ->
PresenceEl = ejabberd_hooks:run_fold(
c2s_update_presence,
Server,
NewEl,
[User, Server]),
case ToJID of
#jid{user = User,
server = Server,
resource = ""} ->
?DEBUG("presence_update(~p,~n\t~p,~n\t~p)",
[FromJID, NewEl, StateData]),
presence_update(FromJID, NewEl, StateData);
[FromJID, PresenceEl, StateData]),
presence_update(FromJID, PresenceEl,
StateData);
_ ->
presence_track(FromJID, ToJID, NewEl, StateData)
presence_track(FromJID, ToJID, PresenceEl,
StateData)
end;
"iq" ->
case StateData#state.privacy_list of

View File

@ -970,9 +970,26 @@ is_nick_change(JID, Nick, StateData) ->
add_new_user(From, Nick, {xmlelement, _, Attrs, Els} = Packet, StateData) ->
Lang = xml:get_attr_s("xml:lang", Attrs),
Affiliation = get_affiliation(From, StateData),
case {is_nick_exists(Nick, StateData),
mod_muc:can_use_nick(StateData#state.host, From, Nick)} of
{true, _} ->
mod_muc:can_use_nick(StateData#state.host, From, Nick),
get_default_role(Affiliation, StateData)} of
{_, _, none} ->
Err = jlib:make_error_reply(
Packet,
case Affiliation of
outcast ->
ErrText = "You have been banned from this room",
?ERRT_FORBIDDEN(Lang, ErrText);
_ ->
ErrText = "Membership required to enter this room",
?ERRT_REGISTRATION_REQUIRED(Lang, ErrText)
end),
ejabberd_router:route( % TODO: s/Nick/""/
jlib:jid_replace_resource(StateData#state.jid, Nick),
From, Err),
StateData;
{true, _, _} ->
ErrText = "Nickname is already in use by another occupant",
Err = jlib:make_error_reply(Packet, ?ERRT_CONFLICT(Lang, ErrText)),
ejabberd_router:route(
@ -980,7 +997,7 @@ add_new_user(From, Nick, {xmlelement, _, Attrs, Els} = Packet, StateData) ->
jlib:jid_replace_resource(StateData#state.jid, Nick),
From, Err),
StateData;
{_, false} ->
{_, false, _} ->
ErrText = "Nickname is registered by another person",
Err = jlib:make_error_reply(Packet, ?ERRT_CONFLICT(Lang, ErrText)),
ejabberd_router:route(
@ -988,81 +1005,61 @@ add_new_user(From, Nick, {xmlelement, _, Attrs, Els} = Packet, StateData) ->
jlib:jid_replace_resource(StateData#state.jid, Nick),
From, Err),
StateData;
_ ->
Affiliation = get_affiliation(From, StateData),
Role = get_default_role(Affiliation, StateData),
case Role of
none ->
{_, _, Role} ->
case check_password(Affiliation, Els, StateData) of
true ->
NewState =
add_user_presence(
From, Packet,
add_online_user(From, Nick, Role, StateData)),
if not (NewState#state.config)#config.anonymous ->
WPacket = {xmlelement, "message", [{"type", "groupchat"}],
[{xmlelement, "body", [],
[{xmlcdata, translate:translate(
Lang,
"This room is not anonymous")}]},
{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
[{xmlelement, "status", [{"code", "100"}], []}]}]},
ejabberd_router:route(
StateData#state.jid,
From, WPacket);
true ->
ok
end,
send_existing_presences(From, NewState),
send_new_presence(From, NewState),
Shift = count_stanza_shift(Nick, Els, NewState),
case send_history(From, Shift, NewState) of
true ->
ok;
_ ->
send_subject(From, Lang, StateData)
end,
case NewState#state.just_created of
true ->
NewState#state{just_created = false};
false ->
NewState
end;
nopass ->
ErrText = "Password required to enter this room",
Err = jlib:make_error_reply(
Packet,
case Affiliation of
outcast ->
ErrText = "You have been banned from this room",
?ERRT_FORBIDDEN(Lang, ErrText);
_ ->
ErrText = "Membership required to enter this room",
?ERRT_REGISTRATION_REQUIRED(Lang, ErrText)
end),
Packet, ?ERRT_NOT_AUTHORIZED(Lang, ErrText)),
ejabberd_router:route( % TODO: s/Nick/""/
jlib:jid_replace_resource(StateData#state.jid, Nick),
jlib:jid_replace_resource(
StateData#state.jid, Nick),
From, Err),
StateData;
_ ->
case check_password(Affiliation, Els, StateData) of
true ->
NewState =
add_user_presence(
From, Packet,
add_online_user(From, Nick, Role, StateData)),
if not (NewState#state.config)#config.anonymous ->
WPacket = {xmlelement, "message", [{"type", "groupchat"}],
[{xmlelement, "body", [],
[{xmlcdata, translate:translate(
Lang,
"This room is not anonymous")}]},
{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
[{xmlelement, "status", [{"code", "100"}], []}]}]},
ejabberd_router:route(
StateData#state.jid,
From, WPacket);
true ->
ok
end,
send_existing_presences(From, NewState),
send_new_presence(From, NewState),
Shift = count_stanza_shift(Nick, Els, NewState),
case send_history(From, Shift, NewState) of
true ->
ok;
_ ->
send_subject(From, Lang, StateData)
end,
case NewState#state.just_created of
true ->
NewState#state{just_created = false};
false ->
NewState
end;
nopass ->
ErrText = "Password required to enter this room",
Err = jlib:make_error_reply(
Packet, ?ERRT_NOT_AUTHORIZED(Lang, ErrText)),
ejabberd_router:route( % TODO: s/Nick/""/
jlib:jid_replace_resource(
StateData#state.jid, Nick),
From, Err),
StateData;
_ ->
ErrText = "Incorrect password",
Err = jlib:make_error_reply(
Packet, ?ERRT_NOT_AUTHORIZED(Lang, ErrText)),
ejabberd_router:route( % TODO: s/Nick/""/
jlib:jid_replace_resource(
StateData#state.jid, Nick),
From, Err),
StateData
end
end
ErrText = "Incorrect password",
Err = jlib:make_error_reply(
Packet, ?ERRT_NOT_AUTHORIZED(Lang, ErrText)),
ejabberd_router:route( % TODO: s/Nick/""/
jlib:jid_replace_resource(
StateData#state.jid, Nick),
From, Err),
StateData
end
end.
check_password(owner, _Els, _StateData) ->