mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
* src/mod_muc/mod_muc_room.erl: Bugfix, updated error codes
(thanks to Sergei Golovan) * src/jlib.hrl: Updated error codes (thanks to Sergei Golovan) SVN Revision: 199
This commit is contained in:
parent
c7d15b12df
commit
7a002470e6
@ -1,3 +1,10 @@
|
||||
2004-01-17 Alexey Shchepin <alexey@sevcom.net>
|
||||
|
||||
* src/mod_muc/mod_muc_room.erl: Bugfix, updated error codes
|
||||
(thanks to Sergei Golovan)
|
||||
|
||||
* src/jlib.hrl: Updated error codes (thanks to Sergei Golovan)
|
||||
|
||||
2004-01-11 Alexey Shchepin <alexey@sevcom.net>
|
||||
|
||||
* src/ejabberd_c2s.erl: Fixed bind namespace
|
||||
|
64
src/jlib.hrl
64
src/jlib.hrl
@ -49,37 +49,47 @@
|
||||
[{xmlelement, Condition, [{"xmlns", ?NS_STANZAS}], []}]}).
|
||||
|
||||
-define(ERR_BAD_REQUEST,
|
||||
?STANZA_ERROR("400", "modify", "bad-request")).
|
||||
?STANZA_ERROR("400", "modify", "bad-request")).
|
||||
-define(ERR_CONFLICT,
|
||||
?STANZA_ERROR("409", "cancel", "conflict")).
|
||||
?STANZA_ERROR("409", "cancel", "conflict")).
|
||||
-define(ERR_FEATURE_NOT_IMPLEMENTED,
|
||||
?STANZA_ERROR("501", "cancel", "feature-not-implemented")).
|
||||
?STANZA_ERROR("501", "cancel", "feature-not-implemented")).
|
||||
-define(ERR_FORBIDDEN,
|
||||
?STANZA_ERROR("403", "auth", "forbidden")).
|
||||
?STANZA_ERROR("403", "auth", "forbidden")).
|
||||
-define(ERR_GONE,
|
||||
?STANZA_ERROR("302", "modify", "gone")).
|
||||
-define(ERR_INTERNAL_SERVER_ERROR,
|
||||
?STANZA_ERROR("500", "wait", "internal-server-error")).
|
||||
?STANZA_ERROR("500", "wait", "internal-server-error")).
|
||||
-define(ERR_ITEM_NOT_FOUND,
|
||||
?STANZA_ERROR("404", "cancel", "item-not-found")).
|
||||
?STANZA_ERROR("404", "cancel", "item-not-found")).
|
||||
-define(ERR_JID_MALFORMED,
|
||||
?STANZA_ERROR("400", "modify", "jid-malformed")).
|
||||
?STANZA_ERROR("400", "modify", "jid-malformed")).
|
||||
-define(ERR_NOT_ACCEPTABLE,
|
||||
?STANZA_ERROR("406", "modify", "not-acceptable")).
|
||||
-define(ERR_NOT_ALLOWED,
|
||||
?STANZA_ERROR("405", "cancel", "not-allowed")).
|
||||
?STANZA_ERROR("405", "cancel", "not-allowed")).
|
||||
-define(ERR_NOT_AUTHORIZED,
|
||||
?STANZA_ERROR("401", "auth", "not-authorized")).
|
||||
-define(ERR_PAYMENT_REQUIRED,
|
||||
?STANZA_ERROR("402", "auth", "payment-required")).
|
||||
-define(ERR_RECIPIENT_UNAVAILABLE,
|
||||
?STANZA_ERROR("404", "wait", "recipient-unavailable")).
|
||||
?STANZA_ERROR("404", "wait", "recipient-unavailable")).
|
||||
-define(ERR_REDIRECT,
|
||||
?STANZA_ERROR("302", "modify", "redirect")).
|
||||
-define(ERR_REGISTRATION_REQUIRED,
|
||||
?STANZA_ERROR("407", "auth", "registration-required")).
|
||||
?STANZA_ERROR("407", "auth", "registration-required")).
|
||||
-define(ERR_REMOTE_SERVER_NOT_FOUND,
|
||||
?STANZA_ERROR("404", "cancel", "remote-server-not-found")).
|
||||
?STANZA_ERROR("404", "cancel", "remote-server-not-found")).
|
||||
-define(ERR_REMOTE_SERVER_TIMEOUT,
|
||||
?STANZA_ERROR("504", "wait", "remote-server-timeout")).
|
||||
?STANZA_ERROR("504", "wait", "remote-server-timeout")).
|
||||
-define(ERR_RESOURCE_CONSTRAINT,
|
||||
?STANZA_ERROR("0", "wait", "resource-constraint")).
|
||||
?STANZA_ERROR("500", "wait", "resource-constraint")).
|
||||
-define(ERR_SERVICE_UNAVAILABLE,
|
||||
?STANZA_ERROR("503", "cancel", "service-unavailable")).
|
||||
?STANZA_ERROR("503", "cancel", "service-unavailable")).
|
||||
-define(ERR_SUBSCRIPTION_REQUIRED,
|
||||
?STANZA_ERROR("0", "auth", "subscription-required")).
|
||||
?STANZA_ERROR("407", "auth", "subscription-required")).
|
||||
-define(ERR_UNEXPECTED_REQUEST,
|
||||
?STANZA_ERROR("0", "wait", "unexpected-request")).
|
||||
?STANZA_ERROR("400", "wait", "unexpected-request")).
|
||||
%-define(ERR_,
|
||||
% ?STANZA_ERROR("", "", "")).
|
||||
|
||||
@ -103,8 +113,16 @@
|
||||
-define(STREAM_ERROR(Condition),
|
||||
{xmlelement, "stream:error",
|
||||
[],
|
||||
[{xmlelement, Condition, [{"xmlns", ?NS_STANZAS}], []}]}).
|
||||
[{xmlelement, Condition, [{"xmlns", ?NS_STREAMS}], []}]}).
|
||||
|
||||
-define(SERR_BAD_FORMAT,
|
||||
?STREAM_ERROR("bad-format")).
|
||||
-define(SERR_BAD_NAMESPACE_PREFIX,
|
||||
?STREAM_ERROR("bad-namespace-prefix")).
|
||||
-define(SERR_CONFLICT,
|
||||
?STREAM_ERROR("conflict")).
|
||||
-define(SERR_CONNECTION_TIMEOUT,
|
||||
?STREAM_ERROR("connection-timeout")).
|
||||
-define(SERR_HOST_GONE,
|
||||
?STREAM_ERROR("host-gone")).
|
||||
-define(SERR_HOST_UNKNOWN,
|
||||
@ -113,23 +131,31 @@
|
||||
?STREAM_ERROR("improper-addressing")).
|
||||
-define(SERR_INTERNAL_SERVER_ERROR,
|
||||
?STREAM_ERROR("internal-server-error")).
|
||||
-define(SERR_INVALID_FROM,
|
||||
?STREAM_ERROR("invalid-from")).
|
||||
-define(SERR_INVALID_ID,
|
||||
?STREAM_ERROR("invalid-id")).
|
||||
-define(SERR_INVALID_NAMESPACE,
|
||||
?STREAM_ERROR("invalid-namespace")).
|
||||
-define(SERR_NONMATCHING_HOSTS,
|
||||
?STREAM_ERROR("nonmatching-hosts")).
|
||||
-define(SERR_INVALID_XML,
|
||||
?STREAM_ERROR("invalid-xml")).
|
||||
-define(SERR_NOT_AUTHORIZED,
|
||||
?STREAM_ERROR("not-authorized")).
|
||||
-define(SERR_POLICY_VIOLATION,
|
||||
?STREAM_ERROR("policy-violation")).
|
||||
-define(SERR_REMOTE_CONNECTION_FAILED,
|
||||
?STREAM_ERROR("remote-connection-failed")).
|
||||
-define(SERR_RESOURSE_CONSTRAINT,
|
||||
?STREAM_ERROR("resource-constraint")).
|
||||
-define(SERR_RESTRICTED_XML,
|
||||
?STREAM_ERROR("restricted-xml")).
|
||||
% TODO: include hostname or IP
|
||||
-define(SERR_SEE_OTHER_HOST,
|
||||
?STREAM_ERROR("see-other-host")).
|
||||
-define(SERR_SYSTEM_SHUTDOWN,
|
||||
?STREAM_ERROR("system-shutdown")).
|
||||
-define(SERR_UNSUPPORTED_ENCODING,
|
||||
?STREAM_ERROR("unsupported-encoding")).
|
||||
-define(SERR_UNSUPPORTED_STANZA_TYPE,
|
||||
?STREAM_ERROR("unsupported-stanza-type")).
|
||||
-define(SERR_UNSUPPORTED_VERSION,
|
||||
|
@ -68,23 +68,6 @@
|
||||
subject_author = ""}).
|
||||
|
||||
|
||||
-define(OLD_ERROR(Code, Desc),
|
||||
{xmlelement, "error",
|
||||
[{"code", Code}],
|
||||
[{xmlcdata, Desc}]}).
|
||||
|
||||
-define(ERR_MUC_NICK_CONFLICT,
|
||||
?OLD_ERROR("409", "Please choose a different nickname.")).
|
||||
-define(ERR_MUC_NICK_CHANGE_CONFLICT,
|
||||
?OLD_ERROR("409", "Nickname already in use.")).
|
||||
-define(ERR_MUC_BANNED,
|
||||
?OLD_ERROR("403", "You have been banned from this room.")).
|
||||
-define(ERR_MUC_NOT_MEMBER,
|
||||
?OLD_ERROR("407", "Membership required to enter this room.")).
|
||||
-define(ERR_MUC_BAD_PASSWORD,
|
||||
?OLD_ERROR("401", "Bad password.")).
|
||||
|
||||
|
||||
%-define(DBGFSM, true).
|
||||
|
||||
-ifdef(DBGFSM).
|
||||
@ -357,7 +340,7 @@ normal_state({route, From, Nick,
|
||||
true ->
|
||||
Err = jlib:make_error_reply(
|
||||
Packet,
|
||||
?ERR_MUC_NICK_CHANGE_CONFLICT),
|
||||
?ERR_CONFLICT),
|
||||
ejabberd_router:route(
|
||||
jlib:jid_replace_resource(
|
||||
StateData#state.jid,
|
||||
@ -392,7 +375,8 @@ normal_state({route, From, Nick,
|
||||
normal_state({route, From, ToNick,
|
||||
{xmlelement, "message", Attrs, Els} = Packet},
|
||||
StateData) ->
|
||||
case xml:get_attr_s("type", Attrs) of
|
||||
Type = xml:get_attr_s("type", Attrs),
|
||||
case Type of
|
||||
"error" ->
|
||||
case is_user_online(From, StateData) of
|
||||
true ->
|
||||
@ -412,35 +396,46 @@ normal_state({route, From, ToNick,
|
||||
case (StateData#state.config)#config.allow_private_messages
|
||||
andalso is_user_online(From, StateData) of
|
||||
true ->
|
||||
case find_jid_by_nick(ToNick, StateData) of
|
||||
false ->
|
||||
case Type of
|
||||
"groupchat" ->
|
||||
Err = jlib:make_error_reply(
|
||||
Packet, ?ERR_ITEM_NOT_FOUND),
|
||||
Packet, ?ERR_BAD_REQUEST),
|
||||
ejabberd_router:route(
|
||||
jlib:jid_replace_resource(
|
||||
StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err);
|
||||
ToJID ->
|
||||
{ok, #user{nick = FromNick}} =
|
||||
?DICT:find(jlib:jid_tolower(From),
|
||||
StateData#state.users),
|
||||
ejabberd_router:route(
|
||||
jlib:jid_replace_resource(
|
||||
StateData#state.jid,
|
||||
FromNick),
|
||||
ToJID, Packet)
|
||||
end,
|
||||
{next_state, normal_state, StateData};
|
||||
jlib:jid_replace_resource(
|
||||
StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err);
|
||||
_ ->
|
||||
case find_jid_by_nick(ToNick, StateData) of
|
||||
false ->
|
||||
Err = jlib:make_error_reply(
|
||||
Packet, ?ERR_ITEM_NOT_FOUND),
|
||||
ejabberd_router:route(
|
||||
jlib:jid_replace_resource(
|
||||
StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err);
|
||||
ToJID ->
|
||||
{ok, #user{nick = FromNick}} =
|
||||
?DICT:find(jlib:jid_tolower(From),
|
||||
StateData#state.users),
|
||||
ejabberd_router:route(
|
||||
jlib:jid_replace_resource(
|
||||
StateData#state.jid,
|
||||
FromNick),
|
||||
ToJID, Packet)
|
||||
end
|
||||
end;
|
||||
_ ->
|
||||
Err = jlib:make_error_reply(
|
||||
Packet, ?ERR_NOT_ALLOWED),
|
||||
ejabberd_router:route(
|
||||
jlib:jid_replace_resource(
|
||||
StateData#state.jid,
|
||||
ToNick), From, Err),
|
||||
{next_state, normal_state, StateData}
|
||||
end
|
||||
jlib:jid_replace_resource(
|
||||
StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err)
|
||||
end,
|
||||
{next_state, normal_state, StateData}
|
||||
end;
|
||||
|
||||
normal_state({route, From, ToNick,
|
||||
@ -806,7 +801,7 @@ add_new_user(From, Nick, {xmlelement, _, Attrs, Els} = Packet, StateData) ->
|
||||
case is_nick_exists(Nick, StateData) or
|
||||
not mod_muc:can_use_nick(From, Nick) of
|
||||
true ->
|
||||
Err = jlib:make_error_reply(Packet, ?ERR_MUC_NICK_CONFLICT),
|
||||
Err = jlib:make_error_reply(Packet, ?ERR_CONFLICT),
|
||||
ejabberd_router:route(
|
||||
% TODO: s/Nick/""/
|
||||
jlib:jid_replace_resource(StateData#state.jid, Nick),
|
||||
@ -820,8 +815,8 @@ add_new_user(From, Nick, {xmlelement, _, Attrs, Els} = Packet, StateData) ->
|
||||
Err = jlib:make_error_reply(
|
||||
Packet,
|
||||
case Affiliation of
|
||||
outcast -> ?ERR_MUC_BANNED;
|
||||
_ -> ?ERR_MUC_NOT_MEMBER
|
||||
outcast -> ?ERR_FORBIDDEN;
|
||||
_ -> ?ERR_REGISTRATION_REQUIRED
|
||||
end),
|
||||
ejabberd_router:route( % TODO: s/Nick/""/
|
||||
jlib:jid_replace_resource(StateData#state.jid, Nick),
|
||||
@ -846,7 +841,7 @@ add_new_user(From, Nick, {xmlelement, _, Attrs, Els} = Packet, StateData) ->
|
||||
NewState;
|
||||
_ ->
|
||||
Err = jlib:make_error_reply(
|
||||
Packet, ?ERR_MUC_BAD_PASSWORD),
|
||||
Packet, ?ERR_NOT_AUTHORIZED),
|
||||
ejabberd_router:route( % TODO: s/Nick/""/
|
||||
jlib:jid_replace_resource(
|
||||
StateData#state.jid, Nick),
|
||||
@ -1412,10 +1407,6 @@ find_changed_items(UJID, UAffiliation, URole, Items, StateData, Res) ->
|
||||
{error, ?ERR_BAD_REQUEST}.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
can_change_ra(FAffiliation, FRole,
|
||||
TAffiliation, TRole,
|
||||
affiliation, Value)
|
||||
@ -1510,9 +1501,20 @@ can_change_ra(FAffiliation, FRole,
|
||||
when (FAffiliation == owner) or (FAffiliation == admin) ->
|
||||
true;
|
||||
can_change_ra(FAffiliation, FRole,
|
||||
owner, moderator,
|
||||
role, participant) ->
|
||||
false;
|
||||
can_change_ra(owner, FRole,
|
||||
TAffiliation, moderator,
|
||||
role, participant)
|
||||
when (FAffiliation == owner) or (FAffiliation == admin) ->
|
||||
role, participant) ->
|
||||
true;
|
||||
can_change_ra(FAffiliation, FRole,
|
||||
admin, moderator,
|
||||
role, participant) ->
|
||||
false;
|
||||
can_change_ra(admin, FRole,
|
||||
TAffiliation, moderator,
|
||||
role, participant) ->
|
||||
true;
|
||||
can_change_ra(FAffiliation, FRole,
|
||||
TAffiliation, TRole,
|
||||
@ -1736,7 +1738,6 @@ set_config(XEl, StateData) ->
|
||||
set_xoption(Opts, Config#config{Opt = Val})).
|
||||
|
||||
|
||||
|
||||
set_xoption([], Config) ->
|
||||
Config;
|
||||
set_xoption([{"title", [Val]} | Opts], Config) ->
|
||||
@ -1871,16 +1872,40 @@ destroy_room(DEls, StateData) ->
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Disco
|
||||
|
||||
-define(FEATURE(Var), {xmlelement, "feature", [{"var", Var}], []}).
|
||||
|
||||
-define(CONFIG_OPT_TO_FEATURE(Opt, Fiftrue, Fiffalse),
|
||||
case Opt of
|
||||
true ->
|
||||
?FEATURE(Fiftrue);
|
||||
false ->
|
||||
?FEATURE(Fiffalse)
|
||||
end).
|
||||
|
||||
process_iq_disco_info(From, set, StateData) ->
|
||||
{error, ?ERR_NOT_ALLOWED};
|
||||
|
||||
process_iq_disco_info(From, get, StateData) ->
|
||||
Config = StateData#state.config,
|
||||
{result, [{xmlelement, "identity",
|
||||
[{"category", "conference"},
|
||||
{"type", "text"},
|
||||
{"name", get_title(StateData)}], []},
|
||||
{xmlelement, "feature",
|
||||
[{"var", ?NS_MUC}], []}], StateData}.
|
||||
[{"var", ?NS_MUC}], []},
|
||||
?CONFIG_OPT_TO_FEATURE(Config#config.public,
|
||||
"muc_public", "muc_hidden"),
|
||||
?CONFIG_OPT_TO_FEATURE(Config#config.persistent,
|
||||
"muc_persistent", "muc_temporary"),
|
||||
?CONFIG_OPT_TO_FEATURE(Config#config.members_only,
|
||||
"muc_membersonly", "muc_open"),
|
||||
?CONFIG_OPT_TO_FEATURE(Config#config.anonymous,
|
||||
"muc_semianonymous", "muc_nonanonymous"),
|
||||
?CONFIG_OPT_TO_FEATURE(Config#config.moderated,
|
||||
"muc_moderated", "muc_unmoderated"),
|
||||
?CONFIG_OPT_TO_FEATURE(Config#config.password_protected,
|
||||
"muc_passwordprotected", "muc_unsecured")
|
||||
], StateData}.
|
||||
|
||||
|
||||
process_iq_disco_items(From, set, StateData) ->
|
||||
@ -1985,6 +2010,3 @@ check_invitation(From, Els, StateData) ->
|
||||
error
|
||||
end.
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user