mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +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:
parent
897cc13f42
commit
8c326ea928
@ -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>
|
2007-05-14 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
* src/ejd2odbc.erl: Bugfix (thanks to Badlop)
|
* src/ejd2odbc.erl: Bugfix (thanks to Badlop)
|
||||||
|
@ -804,15 +804,22 @@ session_established({xmlstreamelement, El}, StateData) ->
|
|||||||
_ ->
|
_ ->
|
||||||
case Name of
|
case Name of
|
||||||
"presence" ->
|
"presence" ->
|
||||||
|
PresenceEl = ejabberd_hooks:run_fold(
|
||||||
|
c2s_update_presence,
|
||||||
|
Server,
|
||||||
|
NewEl,
|
||||||
|
[User, Server]),
|
||||||
case ToJID of
|
case ToJID of
|
||||||
#jid{user = User,
|
#jid{user = User,
|
||||||
server = Server,
|
server = Server,
|
||||||
resource = ""} ->
|
resource = ""} ->
|
||||||
?DEBUG("presence_update(~p,~n\t~p,~n\t~p)",
|
?DEBUG("presence_update(~p,~n\t~p,~n\t~p)",
|
||||||
[FromJID, NewEl, StateData]),
|
[FromJID, PresenceEl, StateData]),
|
||||||
presence_update(FromJID, NewEl, StateData);
|
presence_update(FromJID, PresenceEl,
|
||||||
|
StateData);
|
||||||
_ ->
|
_ ->
|
||||||
presence_track(FromJID, ToJID, NewEl, StateData)
|
presence_track(FromJID, ToJID, PresenceEl,
|
||||||
|
StateData)
|
||||||
end;
|
end;
|
||||||
"iq" ->
|
"iq" ->
|
||||||
case StateData#state.privacy_list of
|
case StateData#state.privacy_list of
|
||||||
|
@ -970,9 +970,26 @@ is_nick_change(JID, Nick, StateData) ->
|
|||||||
|
|
||||||
add_new_user(From, Nick, {xmlelement, _, Attrs, Els} = Packet, StateData) ->
|
add_new_user(From, Nick, {xmlelement, _, Attrs, Els} = Packet, StateData) ->
|
||||||
Lang = xml:get_attr_s("xml:lang", Attrs),
|
Lang = xml:get_attr_s("xml:lang", Attrs),
|
||||||
|
Affiliation = get_affiliation(From, StateData),
|
||||||
case {is_nick_exists(Nick, StateData),
|
case {is_nick_exists(Nick, StateData),
|
||||||
mod_muc:can_use_nick(StateData#state.host, From, Nick)} of
|
mod_muc:can_use_nick(StateData#state.host, From, Nick),
|
||||||
{true, _} ->
|
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",
|
ErrText = "Nickname is already in use by another occupant",
|
||||||
Err = jlib:make_error_reply(Packet, ?ERRT_CONFLICT(Lang, ErrText)),
|
Err = jlib:make_error_reply(Packet, ?ERRT_CONFLICT(Lang, ErrText)),
|
||||||
ejabberd_router:route(
|
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),
|
jlib:jid_replace_resource(StateData#state.jid, Nick),
|
||||||
From, Err),
|
From, Err),
|
||||||
StateData;
|
StateData;
|
||||||
{_, false} ->
|
{_, false, _} ->
|
||||||
ErrText = "Nickname is registered by another person",
|
ErrText = "Nickname is registered by another person",
|
||||||
Err = jlib:make_error_reply(Packet, ?ERRT_CONFLICT(Lang, ErrText)),
|
Err = jlib:make_error_reply(Packet, ?ERRT_CONFLICT(Lang, ErrText)),
|
||||||
ejabberd_router:route(
|
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),
|
jlib:jid_replace_resource(StateData#state.jid, Nick),
|
||||||
From, Err),
|
From, Err),
|
||||||
StateData;
|
StateData;
|
||||||
_ ->
|
{_, _, Role} ->
|
||||||
Affiliation = get_affiliation(From, StateData),
|
case check_password(Affiliation, Els, StateData) of
|
||||||
Role = get_default_role(Affiliation, StateData),
|
true ->
|
||||||
case Role of
|
NewState =
|
||||||
none ->
|
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(
|
Err = jlib:make_error_reply(
|
||||||
Packet,
|
Packet, ?ERRT_NOT_AUTHORIZED(Lang, ErrText)),
|
||||||
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/""/
|
ejabberd_router:route( % TODO: s/Nick/""/
|
||||||
jlib:jid_replace_resource(StateData#state.jid, Nick),
|
jlib:jid_replace_resource(
|
||||||
|
StateData#state.jid, Nick),
|
||||||
From, Err),
|
From, Err),
|
||||||
StateData;
|
StateData;
|
||||||
_ ->
|
_ ->
|
||||||
case check_password(Affiliation, Els, StateData) of
|
ErrText = "Incorrect password",
|
||||||
true ->
|
Err = jlib:make_error_reply(
|
||||||
NewState =
|
Packet, ?ERRT_NOT_AUTHORIZED(Lang, ErrText)),
|
||||||
add_user_presence(
|
ejabberd_router:route( % TODO: s/Nick/""/
|
||||||
From, Packet,
|
jlib:jid_replace_resource(
|
||||||
add_online_user(From, Nick, Role, StateData)),
|
StateData#state.jid, Nick),
|
||||||
if not (NewState#state.config)#config.anonymous ->
|
From, Err),
|
||||||
WPacket = {xmlelement, "message", [{"type", "groupchat"}],
|
StateData
|
||||||
[{xmlelement, "body", [],
|
end
|
||||||
[{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
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
check_password(owner, _Els, _StateData) ->
|
check_password(owner, _Els, _StateData) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user