mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
* src/mod_muc/mod_muc.erl: Now body of message from admin to MUC
service is broadcasted to all conferences * src/mod_muc/mod_muc_room.erl: Likewise SVN Revision: 110
This commit is contained in:
parent
ee15945cd7
commit
d719a93fa1
@ -1,3 +1,9 @@
|
|||||||
|
2003-05-18 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* src/mod_muc/mod_muc.erl: Now body of message from admin to MUC
|
||||||
|
service is broadcasted to all conferences
|
||||||
|
* src/mod_muc/mod_muc_room.erl: Likewise
|
||||||
|
|
||||||
2003-05-15 Alexey Shchepin <alexey@sevcom.net>
|
2003-05-15 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
* src/ejabberd_s2s.erl: Added error catching for do_route/3
|
* src/ejabberd_s2s.erl: Added error catching for do_route/3
|
||||||
|
4
TODO
4
TODO
@ -20,7 +20,3 @@ add traffic shapers to c2s connection before authentification
|
|||||||
add traffic shapers to s2s connections
|
add traffic shapers to s2s connections
|
||||||
more traffic shapers
|
more traffic shapers
|
||||||
SNMP
|
SNMP
|
||||||
|
|
||||||
mod_muc:
|
|
||||||
|
|
||||||
* broadcast messages from admin
|
|
||||||
|
@ -75,10 +75,13 @@ loop(Host) ->
|
|||||||
|
|
||||||
do_route(Host, From, To, Packet) ->
|
do_route(Host, From, To, Packet) ->
|
||||||
{Room, _, Nick} = To,
|
{Room, _, Nick} = To,
|
||||||
|
{xmlelement, Name, Attrs, Els} = Packet,
|
||||||
case Room of
|
case Room of
|
||||||
"" ->
|
"" ->
|
||||||
case Nick of
|
case Nick of
|
||||||
"" ->
|
"" ->
|
||||||
|
case Name of
|
||||||
|
"iq" ->
|
||||||
case jlib:iq_query_info(Packet) of
|
case jlib:iq_query_info(Packet) of
|
||||||
{iq, ID, get, ?NS_DISCO_INFO = XMLNS, SubEl} ->
|
{iq, ID, get, ?NS_DISCO_INFO = XMLNS, SubEl} ->
|
||||||
Res = {iq, ID, result, XMLNS,
|
Res = {iq, ID, result, XMLNS,
|
||||||
@ -93,11 +96,13 @@ do_route(Host, From, To, Packet) ->
|
|||||||
process_iq_disco_items,
|
process_iq_disco_items,
|
||||||
[Host, From, To, ID, SubEl]);
|
[Host, From, To, ID, SubEl]);
|
||||||
{iq, ID, get, ?NS_REGISTER = XMLNS, SubEl} ->
|
{iq, ID, get, ?NS_REGISTER = XMLNS, SubEl} ->
|
||||||
Lang = xml:get_tag_attr_s("xml:lang", SubEl),
|
Lang = xml:get_tag_attr_s(
|
||||||
|
"xml:lang", SubEl),
|
||||||
Res = {iq, ID, result, XMLNS,
|
Res = {iq, ID, result, XMLNS,
|
||||||
[{xmlelement, "query",
|
[{xmlelement, "query",
|
||||||
[{"xmlns", XMLNS}],
|
[{"xmlns", XMLNS}],
|
||||||
iq_get_register_info(From, Lang)}]},
|
iq_get_register_info(
|
||||||
|
From, Lang)}]},
|
||||||
ejabberd_router:route(To,
|
ejabberd_router:route(To,
|
||||||
From,
|
From,
|
||||||
jlib:iq_to_xml(Res));
|
jlib:iq_to_xml(Res));
|
||||||
@ -113,10 +118,12 @@ do_route(Host, From, To, Packet) ->
|
|||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
Err = jlib:make_error_reply(
|
Err = jlib:make_error_reply(
|
||||||
Packet, Error),
|
Packet, Error),
|
||||||
ejabberd_router:route(To, From, Err)
|
ejabberd_router:route(
|
||||||
|
To, From, Err)
|
||||||
end;
|
end;
|
||||||
{iq, ID, get, ?NS_VCARD = XMLNS, SubEl} ->
|
{iq, ID, get, ?NS_VCARD = XMLNS, SubEl} ->
|
||||||
Lang = xml:get_tag_attr_s("xml:lang", SubEl),
|
Lang = xml:get_tag_attr_s(
|
||||||
|
"xml:lang", SubEl),
|
||||||
Res = {iq, ID, result, XMLNS,
|
Res = {iq, ID, result, XMLNS,
|
||||||
[{xmlelement, "query",
|
[{xmlelement, "query",
|
||||||
[{"xmlns", XMLNS}],
|
[{"xmlns", XMLNS}],
|
||||||
@ -124,19 +131,51 @@ do_route(Host, From, To, Packet) ->
|
|||||||
ejabberd_router:route(To,
|
ejabberd_router:route(To,
|
||||||
From,
|
From,
|
||||||
jlib:iq_to_xml(Res));
|
jlib:iq_to_xml(Res));
|
||||||
|
reply ->
|
||||||
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
Err = jlib:make_error_reply(
|
Err = jlib:make_error_reply(
|
||||||
Packet, ?ERR_FEATURE_NOT_IMPLEMENTED),
|
Packet,
|
||||||
|
?ERR_FEATURE_NOT_IMPLEMENTED),
|
||||||
ejabberd_router:route(To, From, Err)
|
ejabberd_router:route(To, From, Err)
|
||||||
end;
|
end;
|
||||||
|
"message" ->
|
||||||
|
case xml:get_attr_s("type", Attrs) of
|
||||||
|
"error" ->
|
||||||
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
Err = jlib:make_error_reply(Packet, ?ERR_JID_NOT_FOUND),
|
case acl:match_rule(muc_admin, From) of
|
||||||
|
allow ->
|
||||||
|
Msg = xml:get_path_s(
|
||||||
|
Packet,
|
||||||
|
[{elem, "body"}, cdata]),
|
||||||
|
broadcast_service_message(Msg);
|
||||||
|
_ ->
|
||||||
|
Err = jlib:make_error_reply(
|
||||||
|
Packet,
|
||||||
|
?ERR_NOT_ALLOWED),
|
||||||
|
ejabberd_router:route(
|
||||||
|
To, From, Err)
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
"presence" ->
|
||||||
|
ok
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
case xml:get_attr_s("type", Attrs) of
|
||||||
|
"error" ->
|
||||||
|
ok;
|
||||||
|
"result" ->
|
||||||
|
ok;
|
||||||
|
_ ->
|
||||||
|
Err = jlib:make_error_reply(
|
||||||
|
Packet, ?ERR_JID_NOT_FOUND),
|
||||||
ejabberd_router:route(To, From, Err)
|
ejabberd_router:route(To, From, Err)
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
case ets:lookup(muc_online_room, Room) of
|
case ets:lookup(muc_online_room, Room) of
|
||||||
[] ->
|
[] ->
|
||||||
{xmlelement, Name, Attrs, Els} = Packet,
|
|
||||||
Type = xml:get_attr_s("type", Attrs),
|
Type = xml:get_attr_s("type", Attrs),
|
||||||
case {Name, Type} of
|
case {Name, Type} of
|
||||||
{"presence", ""} ->
|
{"presence", ""} ->
|
||||||
@ -358,6 +397,14 @@ iq_get_vcard(Lang) ->
|
|||||||
"Copyright (c) 2003 Alexey Shchepin"}]}].
|
"Copyright (c) 2003 Alexey Shchepin"}]}].
|
||||||
|
|
||||||
|
|
||||||
|
broadcast_service_message(Msg) ->
|
||||||
|
lists:foreach(
|
||||||
|
fun(#muc_online_room{name = Name, pid = Pid}) ->
|
||||||
|
gen_fsm:send_all_state_event(
|
||||||
|
Pid, {service_message, Msg})
|
||||||
|
end, ets:tab2list(muc_online_room)).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
can_use_nick(JID, "") ->
|
can_use_nick(JID, "") ->
|
||||||
false;
|
false;
|
||||||
|
@ -521,6 +521,25 @@ normal_state(Event, StateData) ->
|
|||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
%% {next_state, NextStateName, NextStateData, Timeout} |
|
||||||
%% {stop, Reason, NewStateData}
|
%% {stop, Reason, NewStateData}
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
|
handle_event({service_message, Msg}, StateName, StateData) ->
|
||||||
|
MessagePkt = {xmlelement, "message",
|
||||||
|
[{"type", "groupchat"}],
|
||||||
|
[{xmlelement, "body", [], [{xmlcdata, Msg}]}]},
|
||||||
|
lists:foreach(
|
||||||
|
fun({LJID, Info}) ->
|
||||||
|
ejabberd_router:route(
|
||||||
|
{StateData#state.room,
|
||||||
|
StateData#state.host,
|
||||||
|
""},
|
||||||
|
Info#user.jid,
|
||||||
|
MessagePkt)
|
||||||
|
end,
|
||||||
|
?DICT:to_list(StateData#state.users)),
|
||||||
|
NSD = add_message_to_history("",
|
||||||
|
MessagePkt,
|
||||||
|
StateData),
|
||||||
|
{next_state, normal_state, NSD};
|
||||||
|
|
||||||
handle_event(Event, StateName, StateData) ->
|
handle_event(Event, StateName, StateData) ->
|
||||||
{next_state, StateName, StateData}.
|
{next_state, StateName, StateData}.
|
||||||
|
|
||||||
|
@ -109,6 +109,7 @@ try_register(User, Password) ->
|
|||||||
{atomic, ok} ->
|
{atomic, ok} ->
|
||||||
ok;
|
ok;
|
||||||
{atomic, exists} ->
|
{atomic, exists} ->
|
||||||
|
% TODO: replace to "username unavailable"
|
||||||
{error, ?ERR_BAD_REQUEST};
|
{error, ?ERR_BAD_REQUEST};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
||||||
|
25
src/xml.erl
25
src/xml.erl
@ -40,6 +40,31 @@ attrs_to_string(Attrs) ->
|
|||||||
attr_to_string({Name, Value}) ->
|
attr_to_string({Name, Value}) ->
|
||||||
" " ++ crypt(Name) ++ "='" ++ crypt(Value) ++ "'".
|
" " ++ crypt(Name) ++ "='" ++ crypt(Value) ++ "'".
|
||||||
|
|
||||||
|
|
||||||
|
%element_to_string2(El) ->
|
||||||
|
% lists:flatten(element_to_string21(El)).
|
||||||
|
%
|
||||||
|
%element_to_string21(El) ->
|
||||||
|
% case El of
|
||||||
|
% {xmlelement, Name, Attrs, Els} ->
|
||||||
|
% if length(Els) > 0 ->
|
||||||
|
% [[$< | Name], attrs_to_list(Attrs), ">",
|
||||||
|
% lists:map(fun(E) -> element_to_string21(E) end, Els),
|
||||||
|
% "</", Name, ">"];
|
||||||
|
% true ->
|
||||||
|
% ["<", Name, attrs_to_list(Attrs), "/>"]
|
||||||
|
% end;
|
||||||
|
% {xmlcdata, CData} -> crypt(CData)
|
||||||
|
% end.
|
||||||
|
%
|
||||||
|
%attrs_to_list(Attrs) ->
|
||||||
|
% lists:map(fun(A) -> attr_to_list(A) end, Attrs).
|
||||||
|
%
|
||||||
|
%attr_to_list({Name, Value}) ->
|
||||||
|
% [" ", crypt(Name), "='", crypt(Value), "'"].
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%crypt(S) ->
|
%crypt(S) ->
|
||||||
% lists:reverse(crypt(S, "")).
|
% lists:reverse(crypt(S, "")).
|
||||||
%
|
%
|
||||||
|
Loading…
Reference in New Issue
Block a user