mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
* src/mod_last.erl: Supprot for storing status from latest
unavailable presence (thanks to Sergei Golovan) * src/ejabberd_sm.erl: Likewise * src/ejabberd_c2s.erl: Likewise * src/mod_vcard.erl: Minor update (thanks to Sergei Golovan) * src/mod_register.erl: Added "access" option (thanks to Sergei Golovan) * src/mod_irc/mod_irc.erl: Likewise * src/ejabberd.cfg.example: Updated * src/win32/ejabberd.cfg: Likewise * src/mod_privacy.erl: Fixed module stopping (thanks to Sergei Golovan) * src/mod_private.erl: Likewise * src/gen_mod.erl: Added function get_module_opt/3 (thanks to Sergei Golovan) * src/ejabberd_local.erl: Minor fix (thanks to Sergei Golovan) * doc/guide.tex: Updated (thanks to Sergei Golovan) SVN Revision: 244
This commit is contained in:
parent
b64cc8f662
commit
a846fe815c
26
ChangeLog
26
ChangeLog
@ -1,3 +1,29 @@
|
|||||||
|
2004-07-11 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* src/mod_last.erl: Supprot for storing status from latest
|
||||||
|
unavailable presence (thanks to Sergei Golovan)
|
||||||
|
* src/ejabberd_sm.erl: Likewise
|
||||||
|
* src/ejabberd_c2s.erl: Likewise
|
||||||
|
|
||||||
|
* src/mod_vcard.erl: Minor update (thanks to Sergei Golovan)
|
||||||
|
|
||||||
|
* src/mod_register.erl: Added "access" option (thanks to Sergei
|
||||||
|
Golovan)
|
||||||
|
* src/mod_irc/mod_irc.erl: Likewise
|
||||||
|
* src/ejabberd.cfg.example: Updated
|
||||||
|
* src/win32/ejabberd.cfg: Likewise
|
||||||
|
|
||||||
|
* src/mod_privacy.erl: Fixed module stopping (thanks to Sergei
|
||||||
|
Golovan)
|
||||||
|
* src/mod_private.erl: Likewise
|
||||||
|
|
||||||
|
* src/gen_mod.erl: Added function get_module_opt/3 (thanks to
|
||||||
|
Sergei Golovan)
|
||||||
|
|
||||||
|
* src/ejabberd_local.erl: Minor fix (thanks to Sergei Golovan)
|
||||||
|
|
||||||
|
* doc/guide.tex: Updated (thanks to Sergei Golovan)
|
||||||
|
|
||||||
2004-07-10 Alexey Shchepin <alexey@sevcom.net>
|
2004-07-10 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
* src/mod_roster.erl: Removed superfluous include_lib line
|
* src/mod_roster.erl: Removed superfluous include_lib line
|
||||||
|
@ -871,7 +871,17 @@ Options:
|
|||||||
<B><TT>host</TT></B><DD> Defines hostname of service
|
<B><TT>host</TT></B><DD> Defines hostname of service
|
||||||
(see <A HREF="#sec:modhostoption">A.1.2</A>). If not present
|
(see <A HREF="#sec:modhostoption">A.1.2</A>). If not present
|
||||||
then prefix <TT>irc.</TT> is added to main <TT>ejabberd</TT> hostname.
|
then prefix <TT>irc.</TT> is added to main <TT>ejabberd</TT> hostname.
|
||||||
|
<DT><B><TT>access</TT></B><DD> Specifies who is allowed to use IRC transport (default value is <TT>all</TT>).
|
||||||
</DL>
|
</DL>
|
||||||
|
Example:
|
||||||
|
<PRE>
|
||||||
|
{modules,
|
||||||
|
[
|
||||||
|
...
|
||||||
|
{mod_irc, [{access, all}]},
|
||||||
|
...
|
||||||
|
]}.
|
||||||
|
</PRE>
|
||||||
<!--TOC subsection <TT>mod_last</TT>-->
|
<!--TOC subsection <TT>mod_last</TT>-->
|
||||||
|
|
||||||
<H3><A NAME="htoc36">A.6</A> <TT>mod_last</TT></H3><!--SEC END -->
|
<H3><A NAME="htoc36">A.6</A> <TT>mod_last</TT></H3><!--SEC END -->
|
||||||
@ -981,14 +991,15 @@ Example:
|
|||||||
<H3><A NAME="htoc42">A.12</A> <TT>mod_register</TT></H3><!--SEC END -->
|
<H3><A NAME="htoc42">A.12</A> <TT>mod_register</TT></H3><!--SEC END -->
|
||||||
|
|
||||||
<A NAME="sec:modregister"></A>
|
<A NAME="sec:modregister"></A>
|
||||||
This module adds support for <A HREF="http://www.jabber.org/jeps/jep-0077.html">JEP-0077</A> (In-Band Registration).
|
This module adds support for <A HREF="http://www.jabber.org/jeps/jep-0077.html">JEP-0077</A> (In-Band Registration).<BR>
|
||||||
It is possible to restrict registration via ``register''
|
|
||||||
access rule. If this rule returns ``deny'' on requested user name, then
|
|
||||||
registration is not allowed for it.<BR>
|
|
||||||
<BR>
|
<BR>
|
||||||
Options:
|
Options:
|
||||||
<DL COMPACT=compact><DT>
|
<DL COMPACT=compact><DT>
|
||||||
<B><TT>iqdisc</TT></B><DD> <TT>jabber:iq:register</TT> IQ queries processing
|
<B><TT>access</TT></B><DD> Specifies rule to restrict registration.
|
||||||
|
If this rule returns ``deny'' on requested user name, then
|
||||||
|
registration is not allowed for it. (default value is <TT>all</TT>, which means
|
||||||
|
no restrictions).
|
||||||
|
<DT><B><TT>iqdisc</TT></B><DD> <TT>jabber:iq:register</TT> IQ queries processing
|
||||||
discipline (see <A HREF="#sec:modiqdiscoption">A.1.1</A>).
|
discipline (see <A HREF="#sec:modiqdiscoption">A.1.1</A>).
|
||||||
</DL>
|
</DL>
|
||||||
Example:
|
Example:
|
||||||
@ -1004,7 +1015,7 @@ Example:
|
|||||||
{modules,
|
{modules,
|
||||||
[
|
[
|
||||||
...
|
...
|
||||||
{mod_register, []},
|
{mod_register, [{access, register}]},
|
||||||
...
|
...
|
||||||
]}.
|
]}.
|
||||||
</PRE>
|
</PRE>
|
||||||
|
@ -860,8 +860,19 @@ This module implements IRC transport.
|
|||||||
Options:
|
Options:
|
||||||
\begin{description}
|
\begin{description}
|
||||||
\hostitem{irc}
|
\hostitem{irc}
|
||||||
|
\titem{access} Specifies who is allowed to use IRC transport (default value is \term{all}).
|
||||||
\end{description}
|
\end{description}
|
||||||
|
|
||||||
|
Example:
|
||||||
|
\begin{verbatim}
|
||||||
|
{modules,
|
||||||
|
[
|
||||||
|
...
|
||||||
|
{mod_irc, [{access, all}]},
|
||||||
|
...
|
||||||
|
]}.
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
|
|
||||||
\subsection{\modlast{}}
|
\subsection{\modlast{}}
|
||||||
\label{sec:modlast}
|
\label{sec:modlast}
|
||||||
@ -965,12 +976,13 @@ Example:
|
|||||||
\label{sec:modregister}
|
\label{sec:modregister}
|
||||||
|
|
||||||
This module adds support for \jepref{0077} (In-Band Registration).
|
This module adds support for \jepref{0077} (In-Band Registration).
|
||||||
It is possible to restrict registration via ``register''
|
|
||||||
access rule. If this rule returns ``deny'' on requested user name, then
|
|
||||||
registration is not allowed for it.
|
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
\begin{description}
|
\begin{description}
|
||||||
|
\titem{access} Specifies rule to restrict registration.
|
||||||
|
If this rule returns ``deny'' on requested user name, then
|
||||||
|
registration is not allowed for it. (default value is \term{all}, which means
|
||||||
|
no restrictions).
|
||||||
\iqdiscitem{\ns{jabber:iq:register}}
|
\iqdiscitem{\ns{jabber:iq:register}}
|
||||||
\end{description}
|
\end{description}
|
||||||
|
|
||||||
@ -987,7 +999,7 @@ Example:
|
|||||||
{modules,
|
{modules,
|
||||||
[
|
[
|
||||||
...
|
...
|
||||||
{mod_register, []},
|
{mod_register, [{access, register}]},
|
||||||
...
|
...
|
||||||
]}.
|
]}.
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
@ -107,7 +107,7 @@
|
|||||||
% Used modules:
|
% Used modules:
|
||||||
{modules,
|
{modules,
|
||||||
[
|
[
|
||||||
{mod_register, []},
|
{mod_register, [{access, register}]},
|
||||||
{mod_roster, []},
|
{mod_roster, []},
|
||||||
{mod_privacy, []},
|
{mod_privacy, []},
|
||||||
{mod_configure, []},
|
{mod_configure, []},
|
||||||
|
@ -856,7 +856,8 @@ terminate(_Reason, StateName, StateData) ->
|
|||||||
[{xmlelement, "status", [],
|
[{xmlelement, "status", [],
|
||||||
[{xmlcdata, "Replaced by new connection"}]}]},
|
[{xmlcdata, "Replaced by new connection"}]}]},
|
||||||
ejabberd_sm:unset_presence(StateData#state.user,
|
ejabberd_sm:unset_presence(StateData#state.user,
|
||||||
StateData#state.resource),
|
StateData#state.resource,
|
||||||
|
"Replaced by new connection"),
|
||||||
presence_broadcast(
|
presence_broadcast(
|
||||||
StateData, From, StateData#state.pres_a, Packet),
|
StateData, From, StateData#state.pres_a, Packet),
|
||||||
presence_broadcast(
|
presence_broadcast(
|
||||||
@ -867,15 +868,26 @@ terminate(_Reason, StateName, StateData) ->
|
|||||||
jlib:jid_to_string(StateData#state.jid)]),
|
jlib:jid_to_string(StateData#state.jid)]),
|
||||||
ejabberd_sm:close_session(StateData#state.user,
|
ejabberd_sm:close_session(StateData#state.user,
|
||||||
StateData#state.resource),
|
StateData#state.resource),
|
||||||
From = StateData#state.jid,
|
|
||||||
Packet = {xmlelement, "presence",
|
Tmp = ?SETS:new(),
|
||||||
[{"type", "unavailable"}], []},
|
case StateData of
|
||||||
ejabberd_sm:unset_presence(StateData#state.user,
|
#state{pres_last = undefined,
|
||||||
StateData#state.resource),
|
pres_a = Tmp,
|
||||||
presence_broadcast(
|
pres_i = Tmp,
|
||||||
StateData, From, StateData#state.pres_a, Packet),
|
pres_invis = false} ->
|
||||||
presence_broadcast(
|
ok;
|
||||||
StateData, From, StateData#state.pres_i, Packet)
|
_ ->
|
||||||
|
From = StateData#state.jid,
|
||||||
|
Packet = {xmlelement, "presence",
|
||||||
|
[{"type", "unavailable"}], []},
|
||||||
|
ejabberd_sm:unset_presence(StateData#state.user,
|
||||||
|
StateData#state.resource,
|
||||||
|
""),
|
||||||
|
presence_broadcast(
|
||||||
|
StateData, From, StateData#state.pres_a, Packet),
|
||||||
|
presence_broadcast(
|
||||||
|
StateData, From, StateData#state.pres_i, Packet)
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
@ -984,8 +996,15 @@ presence_update(From, Packet, StateData) ->
|
|||||||
{xmlelement, _Name, Attrs, _Els} = Packet,
|
{xmlelement, _Name, Attrs, _Els} = Packet,
|
||||||
case xml:get_attr_s("type", Attrs) of
|
case xml:get_attr_s("type", Attrs) of
|
||||||
"unavailable" ->
|
"unavailable" ->
|
||||||
|
Status = case xml:get_subtag(Packet, "status") of
|
||||||
|
false ->
|
||||||
|
"";
|
||||||
|
StatusTag ->
|
||||||
|
xml:get_tag_cdata(StatusTag)
|
||||||
|
end,
|
||||||
ejabberd_sm:unset_presence(StateData#state.user,
|
ejabberd_sm:unset_presence(StateData#state.user,
|
||||||
StateData#state.resource),
|
StateData#state.resource,
|
||||||
|
Status),
|
||||||
presence_broadcast(StateData, From, StateData#state.pres_a, Packet),
|
presence_broadcast(StateData, From, StateData#state.pres_a, Packet),
|
||||||
presence_broadcast(StateData, From, StateData#state.pres_i, Packet),
|
presence_broadcast(StateData, From, StateData#state.pres_i, Packet),
|
||||||
StateData#state{pres_last = undefined,
|
StateData#state{pres_last = undefined,
|
||||||
|
@ -65,16 +65,16 @@ loop(State) ->
|
|||||||
catch mod_disco:unregister_feature(XMLNS),
|
catch mod_disco:unregister_feature(XMLNS),
|
||||||
loop(State);
|
loop(State);
|
||||||
refresh_iq_handlers ->
|
refresh_iq_handlers ->
|
||||||
lists:map(
|
lists:foreach(
|
||||||
fun(T) ->
|
fun(T) ->
|
||||||
case T of
|
case T of
|
||||||
{XMLNS, _Module, _Function, _Opts} ->
|
{XMLNS, _Module, _Function, _Opts} ->
|
||||||
catch mod_disco:register_feature(XMLNS);
|
catch mod_disco:register_feature(XMLNS);
|
||||||
{XMLNS, _Module, _Function} ->
|
{XMLNS, _Module, _Function} ->
|
||||||
catch mod_disco:register_feature(XMLNS);
|
catch mod_disco:register_feature(XMLNS);
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end
|
end
|
||||||
end, ets:tab2list(State#state.iqtable)),
|
end, ets:tab2list(State#state.iqtable)),
|
||||||
loop(State);
|
loop(State);
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
-export([start_link/0, init/0, open_session/2, close_session/2,
|
-export([start_link/0, init/0, open_session/2, close_session/2,
|
||||||
get_user_resources/1,
|
get_user_resources/1,
|
||||||
set_presence/3,
|
set_presence/3,
|
||||||
unset_presence/2,
|
unset_presence/3,
|
||||||
dirty_get_sessions_list/0,
|
dirty_get_sessions_list/0,
|
||||||
dirty_get_my_sessions_list/0,
|
dirty_get_my_sessions_list/0,
|
||||||
register_iq_handler/3,
|
register_iq_handler/3,
|
||||||
@ -317,14 +317,14 @@ set_presence(User, Resource, Priority) ->
|
|||||||
end,
|
end,
|
||||||
mnesia:transaction(F).
|
mnesia:transaction(F).
|
||||||
|
|
||||||
unset_presence(User, Resource) ->
|
unset_presence(User, Resource, Status) ->
|
||||||
LUser = jlib:nodeprep(User),
|
LUser = jlib:nodeprep(User),
|
||||||
F = fun() ->
|
F = fun() ->
|
||||||
UR = {User, Resource},
|
UR = {User, Resource},
|
||||||
mnesia:delete({presence, UR})
|
mnesia:delete({presence, UR})
|
||||||
end,
|
end,
|
||||||
mnesia:transaction(F),
|
mnesia:transaction(F),
|
||||||
catch mod_last:on_presence_update(LUser).
|
catch mod_last:on_presence_update(LUser, Status).
|
||||||
|
|
||||||
get_user_present_resources(LUser) ->
|
get_user_present_resources(LUser) ->
|
||||||
case catch mnesia:dirty_index_read(presence, LUser, #presence.user) of
|
case catch mnesia:dirty_index_read(presence, LUser, #presence.user) of
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
stop_module/1,
|
stop_module/1,
|
||||||
get_opt/2,
|
get_opt/2,
|
||||||
get_opt/3,
|
get_opt/3,
|
||||||
|
get_module_opt/3,
|
||||||
loaded_modules/0]).
|
loaded_modules/0]).
|
||||||
|
|
||||||
-export([behaviour_info/1]).
|
-export([behaviour_info/1]).
|
||||||
@ -73,6 +74,16 @@ get_opt(Opt, Opts, Default) ->
|
|||||||
Val
|
Val
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
get_module_opt(Module, Opt, Default) ->
|
||||||
|
OptsList = ets:lookup(ejabberd_modules, Module),
|
||||||
|
case OptsList of
|
||||||
|
[] ->
|
||||||
|
Default;
|
||||||
|
[#ejabberd_module{opts = Opts} | _] ->
|
||||||
|
get_opt(Opt, Opts, Default)
|
||||||
|
end.
|
||||||
|
|
||||||
loaded_modules() ->
|
loaded_modules() ->
|
||||||
ets:select(ejabberd_modules,
|
ets:select(ejabberd_modules,
|
||||||
[{#ejabberd_module{_ = '_', module = '$1'}, [],['$1']}]).
|
[{#ejabberd_module{_ = '_', module = '$1'}, [],['$1']}]).
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
-export([start/1, init/1, stop/0, closed_conection/2,
|
-export([start/1, init/2, stop/0, closed_conection/2,
|
||||||
get_user_and_encoding/2]).
|
get_user_and_encoding/2]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
@ -29,34 +29,48 @@ start(Opts) ->
|
|||||||
[{disc_copies, [node()]},
|
[{disc_copies, [node()]},
|
||||||
{attributes, record_info(fields, irc_custom)}]),
|
{attributes, record_info(fields, irc_custom)}]),
|
||||||
Host = gen_mod:get_opt(host, Opts, "irc." ++ ?MYNAME),
|
Host = gen_mod:get_opt(host, Opts, "irc." ++ ?MYNAME),
|
||||||
register(ejabberd_mod_irc, spawn(?MODULE, init, [Host])).
|
Access = gen_mod:get_opt(access, Opts, all),
|
||||||
|
register(ejabberd_mod_irc, spawn(?MODULE, init, [Host, Access])).
|
||||||
|
|
||||||
init(Host) ->
|
init(Host, Access) ->
|
||||||
catch ets:new(irc_connection, [named_table,
|
catch ets:new(irc_connection, [named_table,
|
||||||
public,
|
public,
|
||||||
{keypos, #irc_connection.userserver}]),
|
{keypos, #irc_connection.userserver}]),
|
||||||
ejabberd_router:register_route(Host),
|
ejabberd_router:register_route(Host),
|
||||||
loop(Host).
|
loop(Host, Access).
|
||||||
|
|
||||||
loop(Host) ->
|
loop(Host, Access) ->
|
||||||
receive
|
receive
|
||||||
{route, From, To, Packet} ->
|
{route, From, To, Packet} ->
|
||||||
case catch do_route(Host, From, To, Packet) of
|
case catch do_route(Host, Access, From, To, Packet) of
|
||||||
{'EXIT', Reason} ->
|
{'EXIT', Reason} ->
|
||||||
?ERROR_MSG("~p", [Reason]);
|
?ERROR_MSG("~p", [Reason]);
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
loop(Host);
|
loop(Host, Access);
|
||||||
stop ->
|
stop ->
|
||||||
ejabberd_router:unregister_global_route(Host),
|
ejabberd_router:unregister_global_route(Host),
|
||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
loop(Host)
|
loop(Host, Access)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
do_route(Host, From, To, Packet) ->
|
do_route(Host, Access, From, To, Packet) ->
|
||||||
|
case acl:match_rule(Access, From) of
|
||||||
|
allow ->
|
||||||
|
do_route1(Host, From, To, Packet);
|
||||||
|
_ ->
|
||||||
|
{xmlelement, _Name, Attrs, _Els} = Packet,
|
||||||
|
Lang = xml:get_attr_s("xml:lang", Attrs),
|
||||||
|
ErrText = "Access denied by service policy",
|
||||||
|
Err = jlib:make_error_reply(Packet,
|
||||||
|
?ERRT_FORBIDDEN(Lang, ErrText)),
|
||||||
|
ejabberd_router:route(To, From, Err)
|
||||||
|
end.
|
||||||
|
|
||||||
|
do_route1(Host, From, To, Packet) ->
|
||||||
#jid{user = ChanServ, resource = Resource} = To,
|
#jid{user = ChanServ, resource = Resource} = To,
|
||||||
{xmlelement, _Name, Attrs, _Els} = Packet,
|
{xmlelement, _Name, Attrs, _Els} = Packet,
|
||||||
case ChanServ of
|
case ChanServ of
|
||||||
|
@ -16,13 +16,13 @@
|
|||||||
stop/0,
|
stop/0,
|
||||||
process_local_iq/3,
|
process_local_iq/3,
|
||||||
process_sm_iq/3,
|
process_sm_iq/3,
|
||||||
on_presence_update/1,
|
on_presence_update/2,
|
||||||
remove_user/1]).
|
remove_user/1]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("jlib.hrl").
|
-include("jlib.hrl").
|
||||||
|
|
||||||
-record(last_activity, {user, timestamp}).
|
-record(last_activity, {user, timestamp, status}).
|
||||||
|
|
||||||
|
|
||||||
start(Opts) ->
|
start(Opts) ->
|
||||||
@ -30,6 +30,7 @@ start(Opts) ->
|
|||||||
mnesia:create_table(last_activity,
|
mnesia:create_table(last_activity,
|
||||||
[{disc_copies, [node()]},
|
[{disc_copies, [node()]},
|
||||||
{attributes, record_info(fields, last_activity)}]),
|
{attributes, record_info(fields, last_activity)}]),
|
||||||
|
update_table(),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_LAST,
|
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_LAST,
|
||||||
?MODULE, process_local_iq, IQDisc),
|
?MODULE, process_local_iq, IQDisc),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, ?NS_LAST,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, ?NS_LAST,
|
||||||
@ -93,7 +94,7 @@ get_last(IQ, SubEl, LUser) ->
|
|||||||
IQ#iq{type = error, sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]};
|
IQ#iq{type = error, sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]};
|
||||||
[] ->
|
[] ->
|
||||||
IQ#iq{type = error, sub_el = [SubEl, ?ERR_SERVICE_UNAVAILABLE]};
|
IQ#iq{type = error, sub_el = [SubEl, ?ERR_SERVICE_UNAVAILABLE]};
|
||||||
[#last_activity{timestamp = TimeStamp}] ->
|
[#last_activity{timestamp = TimeStamp, status = Status}] ->
|
||||||
{MegaSecs, Secs, _MicroSecs} = now(),
|
{MegaSecs, Secs, _MicroSecs} = now(),
|
||||||
TimeStamp2 = MegaSecs * 1000000 + Secs,
|
TimeStamp2 = MegaSecs * 1000000 + Secs,
|
||||||
Sec = TimeStamp2 - TimeStamp,
|
Sec = TimeStamp2 - TimeStamp,
|
||||||
@ -101,17 +102,18 @@ get_last(IQ, SubEl, LUser) ->
|
|||||||
sub_el = [{xmlelement, "query",
|
sub_el = [{xmlelement, "query",
|
||||||
[{"xmlns", ?NS_LAST},
|
[{"xmlns", ?NS_LAST},
|
||||||
{"seconds", integer_to_list(Sec)}],
|
{"seconds", integer_to_list(Sec)}],
|
||||||
[]}]}
|
[{xmlcdata, Status}]}]}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
on_presence_update(LUser) ->
|
on_presence_update(LUser, Status) ->
|
||||||
{MegaSecs, Secs, _MicroSecs} = now(),
|
{MegaSecs, Secs, _MicroSecs} = now(),
|
||||||
TimeStamp = MegaSecs * 1000000 + Secs,
|
TimeStamp = MegaSecs * 1000000 + Secs,
|
||||||
F = fun() ->
|
F = fun() ->
|
||||||
mnesia:write(#last_activity{user = LUser,
|
mnesia:write(#last_activity{user = LUser,
|
||||||
timestamp = TimeStamp})
|
timestamp = TimeStamp,
|
||||||
|
status = Status})
|
||||||
end,
|
end,
|
||||||
mnesia:transaction(F).
|
mnesia:transaction(F).
|
||||||
|
|
||||||
@ -122,3 +124,22 @@ remove_user(User) ->
|
|||||||
mnesia:delete({last_activity, LUser})
|
mnesia:delete({last_activity, LUser})
|
||||||
end,
|
end,
|
||||||
mnesia:transaction(F).
|
mnesia:transaction(F).
|
||||||
|
|
||||||
|
|
||||||
|
update_table() ->
|
||||||
|
Fields = record_info(fields, last_activity),
|
||||||
|
case mnesia:table_info(last_activity, attributes) of
|
||||||
|
Fields ->
|
||||||
|
ok;
|
||||||
|
[user, timestamp] ->
|
||||||
|
?INFO_MSG("Converting last_activity table from {user, timestamp} format", []),
|
||||||
|
mnesia:transform_table(
|
||||||
|
last_activity,
|
||||||
|
fun({_, U, T}) ->
|
||||||
|
#last_activity{user = U, timestamp = T, status = ""}
|
||||||
|
end, Fields);
|
||||||
|
_ ->
|
||||||
|
?INFO_MSG("Recreating last_activity table", []),
|
||||||
|
mnesia:transform_table(last_activity, ignore, Fields)
|
||||||
|
end.
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ start(Opts) ->
|
|||||||
?MODULE, process_iq, IQDisc).
|
?MODULE, process_iq, IQDisc).
|
||||||
|
|
||||||
stop() ->
|
stop() ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_PRIVACY).
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, ?NS_PRIVACY).
|
||||||
|
|
||||||
process_iq(From, _To, IQ) ->
|
process_iq(From, _To, IQ) ->
|
||||||
#iq{type = Type, sub_el = SubEl} = IQ,
|
#iq{type = Type, sub_el = SubEl} = IQ,
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
-export([start/1,
|
-export([start/1,
|
||||||
stop/0,
|
stop/0,
|
||||||
process_local_iq/3,
|
process_sm_iq/3,
|
||||||
remove_user/1]).
|
remove_user/1]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
@ -28,13 +28,13 @@ start(Opts) ->
|
|||||||
[{disc_only_copies, [node()]},
|
[{disc_only_copies, [node()]},
|
||||||
{attributes, record_info(fields, private_storage)}]),
|
{attributes, record_info(fields, private_storage)}]),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, ?NS_PRIVATE,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, ?NS_PRIVATE,
|
||||||
?MODULE, process_local_iq, IQDisc).
|
?MODULE, process_sm_iq, IQDisc).
|
||||||
|
|
||||||
stop() ->
|
stop() ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_PRIVATE).
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, ?NS_PRIVATE).
|
||||||
|
|
||||||
|
|
||||||
process_local_iq(From, _To, #iq{type = Type, sub_el = SubEl} = IQ) ->
|
process_sm_iq(From, _To, #iq{type = Type, sub_el = SubEl} = IQ) ->
|
||||||
#jid{luser = LUser, lserver = LServer} = From,
|
#jid{luser = LUser, lserver = LServer} = From,
|
||||||
case ?MYNAME of
|
case ?MYNAME of
|
||||||
LServer ->
|
LServer ->
|
||||||
|
@ -122,7 +122,8 @@ try_register(User, Password) ->
|
|||||||
{error, ?ERR_BAD_REQUEST};
|
{error, ?ERR_BAD_REQUEST};
|
||||||
_ ->
|
_ ->
|
||||||
JID = jlib:make_jid(User, ?MYNAME, ""),
|
JID = jlib:make_jid(User, ?MYNAME, ""),
|
||||||
case acl:match_rule(register, JID) of
|
Access = gen_mod:get_module_opt(?MODULE, access, all),
|
||||||
|
case acl:match_rule(Access, JID) of
|
||||||
deny ->
|
deny ->
|
||||||
{error, ?ERR_CONFLICT};
|
{error, ?ERR_CONFLICT};
|
||||||
allow ->
|
allow ->
|
||||||
|
@ -70,10 +70,10 @@ start(Opts) ->
|
|||||||
|
|
||||||
init(Host, Search) ->
|
init(Host, Search) ->
|
||||||
case Search of
|
case Search of
|
||||||
true ->
|
false ->
|
||||||
ejabberd_router:register_route(Host),
|
|
||||||
loop(Host);
|
loop(Host);
|
||||||
_ ->
|
_ ->
|
||||||
|
ejabberd_router:register_route(Host),
|
||||||
loop(Host)
|
loop(Host)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@
|
|||||||
% Used modules:
|
% Used modules:
|
||||||
{modules,
|
{modules,
|
||||||
[
|
[
|
||||||
{mod_register, []},
|
{mod_register, [{access, register}]},
|
||||||
{mod_roster, []},
|
{mod_roster, []},
|
||||||
{mod_privacy, []},
|
{mod_privacy, []},
|
||||||
{mod_configure, []},
|
{mod_configure, []},
|
||||||
|
Loading…
Reference in New Issue
Block a user