Compare commits

...

17 Commits

Author SHA1 Message Date
badlop a3c7a5d086 Merge pull request #74 from mojolingo/feature/mod_post_log
mod_post_log [2.1.x]
2015-04-03 11:06:55 +02:00
Mickaël Rémond b6a4ba0e6c Merge pull request #88 from blackbass1988/mod_archive_ns_actualized
ns actualized with XEP-0136
2015-03-17 10:42:59 +01:00
Oleg Salionov 374eabfee3 Update mod_archive.erl 2015-03-17 08:49:03 +09:00
Oleg Salionov 50f3a42de8 ns actualized with XEP-0136 2015-03-17 09:45:20 +10:00
Tim Stewart 0df57edeef Include to/from info in POSTed headers 2014-10-21 12:45:21 -04:00
Tim Stewart d265730f31 Repair error reporting in {error, Reason} case 2014-10-21 12:44:30 -04:00
Tim Stewart d744d77288 Remove unnecessary `Host' parameter 2014-10-21 12:42:39 -04:00
Ben Langfeld c28cb3b4c2 Emakefile is required to build mods 2014-08-13 13:35:32 -03:00
Ben Langfeld d974cb618d Correct permissions 2014-08-13 13:14:41 -03:00
Ben Langfeld 04df0724f3 Proper build setup 2014-08-13 12:54:37 -03:00
Ben Langfeld a0e27ffe65 Add mod_post_log 2014-08-13 12:21:04 -03:00
Badlop 93bba1d1fd Fix for command rooms_unused_destroy in ejabberd 2.1.11+ 2013-10-14 17:09:12 +02:00
Badlop 93e0695c88 Remove reference to old git repository 2013-09-10 18:46:13 +02:00
Badlop c84d51a992 Update ejabberd-dev to ejabberd 2.1.13 2013-09-10 18:34:53 +02:00
Badlop a03088d033 Use the regexp frontend module (EJAB-921) 2013-09-10 18:34:38 +02:00
Badlop 360ed6a2e6 Add get_last to ejabberdctl for last user activity (thanks to lehrblogger)
The logic for determining the response is borrowed from here:
6d811f5178/src/web/ejabberd_web_admin.erl (L1583-L1601)
2013-08-07 13:47:59 +02:00
Badlop 2e5bc8d269 Add ebin/ dirs with .keepme file to ensure Git tracks them 2013-04-25 12:55:59 +02:00
49 changed files with 263 additions and 66 deletions

0
bfile/ebin/.keepme Normal file
View File

View File

View File

@ -1,6 +1,6 @@
%%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as

View File

@ -1,6 +1,6 @@
%%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as

View File

@ -1,6 +1,6 @@
%%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as

View File

@ -1,6 +1,6 @@
%%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as

View File

@ -1,6 +1,6 @@
%%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as

View File

@ -1,6 +1,6 @@
%%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as

View File

@ -1,6 +1,6 @@
%%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as

View File

@ -11,12 +11,12 @@
%%% under the License.
%%%
%%% The Initial Developer of the Original Code is ProcessOne.
%%% Portions created by ProcessOne are Copyright 2006-2011, ProcessOne
%%% Portions created by ProcessOne are Copyright 2006-2013, ProcessOne
%%% All Rights Reserved.''
%%% This software is copyright 2006-2011, ProcessOne.
%%% This software is copyright 2006-2013, ProcessOne.
%%%
%%%
%%% copyright 2006-2011 ProcessOne
%%% copyright 2006-2013 ProcessOne
%%%
%%% This file contains pubsub types definition.
%%% ====================================================================
@ -136,8 +136,9 @@
options = []
}).
%% @type pubsubState() = {pubsub_state, StateId, Items, Affiliation, Subscriptions}
%% @type pubsubState() = {pubsub_state, StateId, NodeIdx, Items, Affiliation, Subscriptions}
%% StateId = {ljid(), nodeIdx()}
%% NodeIdx = nodeIdx(),
%% Items = [itemId()]
%% Affiliation = affiliation()
%% Subscriptions = [{subscription(), subId()}].
@ -146,6 +147,7 @@
-record(pubsub_state,
{
stateid,
nodeidx,
items = [],
affiliation = 'none',
subscriptions = []
@ -161,6 +163,7 @@
-record(pubsub_item,
{
itemid,
nodeidx,
creation = {'unknown','unknown'},
modification = {'unknown','unknown'},
payload = []

View File

@ -1,6 +1,6 @@
%%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as

View File

@ -1,6 +1,6 @@
%%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as

View File

@ -1,6 +1,6 @@
%%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as

View File

@ -5,7 +5,7 @@
%%% Created : 24 Jan 2003 by Alexey Shchepin <alexey@process-one.net>
%%%
%%%
%%% ejabberd, Copyright (C) 2002-2008 ProcessOne
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
@ -16,7 +16,7 @@
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
@ -34,6 +34,8 @@
get_opt/2,
get_opt/3,
get_opt_host/3,
db_type/1,
db_type/2,
get_module_opt/4,
get_module_opt_host/3,
loaded_modules/1,
@ -66,15 +68,28 @@ start_module(Host, Module, Opts) ->
ets:insert(ejabberd_modules,
#ejabberd_module{module_host = {Module, Host},
opts = Opts}),
case catch Module:start(Host, Opts) of
{'EXIT', Reason} ->
try Module:start(Host, Opts)
catch Class:Reason ->
del_module_mnesia(Host, Module),
ets:delete(ejabberd_modules, {Module, Host}),
?ERROR_MSG("~p", [Reason]);
_ ->
ok
ErrorText = io_lib:format("Problem starting the module ~p for host ~p ~n options: ~p~n ~p: ~p",
[Module, Host, Opts, Class, Reason]),
?CRITICAL_MSG(ErrorText, []),
case is_app_running(ejabberd) of
true ->
erlang:raise(Class, Reason, erlang:get_stacktrace());
false ->
?CRITICAL_MSG("ejabberd initialization was aborted because a module start failed.", []),
timer:sleep(3000),
erlang:halt(string:substr(lists:flatten(ErrorText), 1, 199))
end
end.
is_app_running(AppName) ->
%% Use a high timeout to prevent a false positive in a high load system
Timeout = 15000,
lists:keymember(AppName, 1, application:which_applications(Timeout)).
%% @doc Stop the module in a host, and forget its configuration.
stop_module(Host, Module) ->
case stop_module_keep_config(Host, Module) of
@ -173,11 +188,23 @@ get_module_opt(Host, Module, Opt, Default) ->
get_module_opt_host(Host, Module, Default) ->
Val = get_module_opt(Host, Module, host, Default),
element(2, regexp:gsub(Val, "@HOST@", Host)).
ejabberd_regexp:greplace(Val, "@HOST@", Host).
get_opt_host(Host, Opts, Default) ->
Val = get_opt(host, Opts, Default),
element(2, regexp:gsub(Val, "@HOST@", Host)).
ejabberd_regexp:greplace(Val, "@HOST@", Host).
db_type(Opts) ->
case get_opt(db_type, Opts, mnesia) of
odbc -> odbc;
_ -> mnesia
end.
db_type(Host, Module) ->
case get_module_opt(Host, Module, db_type, mnesia) of
odbc -> odbc;
_ -> mnesia
end.
loaded_modules(Host) ->
ets:select(ejabberd_modules,

View File

0
ircd/ebin/.keepme Normal file
View File

View File

View File

@ -69,6 +69,7 @@
push_roster_all/1,
push_alltoall/2,
%% mod_last
get_last/2,
set_last/4,
%% mod_private
private_get/4,
@ -436,6 +437,13 @@ commands() ->
args = [{host, string}, {group, string}],
result = {res, rescode}},
#ejabberd_commands{name = get_last, tags = [last],
desc = "Get last activity information",
longdesc = "Timestamp is the seconds since"
"1970-01-01 00:00:00 UTC, for example: date +%s",
module = ?MODULE, function = get_last,
args = [{user, string}, {host, string}],
result = {last_activity, string}},
#ejabberd_commands{name = set_last, tags = [last],
desc = "Set last activity information",
longdesc = "Timestamp is the seconds since"
@ -1233,6 +1241,28 @@ build_broadcast(U, S, SubsAtom) when is_atom(SubsAtom) ->
%%% Last Activity
%%%
get_last(User, Server) ->
Mod = get_lastactivity_module(Server),
case ejabberd_sm:get_user_resources(User, Server) of
[] ->
case Mod:get_last_info(User, Server) of
not_found ->
"Never";
{ok, Shift, _Status} ->
TimeStamp = {Shift div 1000000,
Shift rem 1000000,
0},
{{Year, Month, Day}, {Hour, Minute, Second}} =
calendar:now_to_local_time(TimeStamp),
lists:flatten(
io_lib:format(
"~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
[Year, Month, Day, Hour, Minute, Second]))
end;
_ ->
"Online"
end.
set_last(User, Server, Timestamp, Status) ->
Mod = get_lastactivity_module(Server),
Mod:store_last_info(User, Server, Timestamp, Status).

0
mod_archive/ebin/.keepme Normal file
View File

View File

@ -37,14 +37,10 @@
-record(state, {host, storages, save_default, session_duration}).
-define(PROCNAME, ejabberd_mod_archive).
-define(NS_ARCHIVE,
"http://www.xmpp.org/extensions/xep-0136.html#ns").
-define(NS_ARCHIVE_MANAGE,
"http://www.xmpp.org/extensions/xep-0136.html#ns-manage").
-define(NS_ARCHIVE_PREF,
"http://www.xmpp.org/extensions/xep-0136.html#ns-pref").
-define(NS_ARCHIVE_MANUAL,
"http://www.xmpp.org/extensions/xep-0136.html#ns-manual").
-define(NS_ARCHIVE, "urn:xmpp:archive").
-define(NS_ARCHIVE_MANAGE, "urn:xmpp:archive:manage").
-define(NS_ARCHIVE_PREF, "urn:xmpp:archive:pref").
-define(NS_ARCHIVE_MANUAL, "urn:xmpp:archive:manual").
-define(INFINITY, calendar:datetime_to_gregorian_seconds({{2038,1,19},{0,0,0}})).
-define(MYDEBUG(Format, Args),

View File

@ -90,16 +90,11 @@
session_duration}).
-define(PROCNAME, ejabberd_mod_archive_odbc).
-define(NS_ARCHIVE,
"http://www.xmpp.org/extensions/xep-0136.html#ns").
-define(NS_ARCHIVE_AUTO,
"http://www.xmpp.org/extensions/xep-0136.html#ns-auto").
-define(NS_ARCHIVE_MANAGE,
"http://www.xmpp.org/extensions/xep-0136.html#ns-manage").
-define(NS_ARCHIVE_PREF,
"http://www.xmpp.org/extensions/xep-0136.html#ns-pref").
-define(NS_ARCHIVE_MANUAL,
"http://www.xmpp.org/extensions/xep-0136.html#ns-manual").
-define(NS_ARCHIVE, "urn:xmpp:archive").
-define(NS_ARCHIVE_AUTO, "urn:xmpp:archive:auto").
-define(NS_ARCHIVE_MANAGE, "urn:xmpp:archive:manage").
-define(NS_ARCHIVE_PREF, "urn:xmpp:archive:pref").
-define(NS_ARCHIVE_MANUAL, "urn:xmpp:archive:manual").
-define(INFINITY, calendar:datetime_to_gregorian_seconds({{2038,1,19},{0,0,0}})).
%% Should be OK for most of modern DBs, I hope ...

View File

@ -38,14 +38,10 @@
session_duration}).
-define(PROCNAME, ejabberd_mod_archive_sql).
-define(NS_ARCHIVE,
"http://www.xmpp.org/extensions/xep-0136.html#ns").
-define(NS_ARCHIVE_MANAGE,
"http://www.xmpp.org/extensions/xep-0136.html#ns-manage").
-define(NS_ARCHIVE_PREF,
"http://www.xmpp.org/extensions/xep-0136.html#ns-pref").
-define(NS_ARCHIVE_MANUAL,
"http://www.xmpp.org/extensions/xep-0136.html#ns-manual").
-define(NS_ARCHIVE, "urn:xmpp:archive").
-define(NS_ARCHIVE_MANAGE, "urn:xmpp:archive:manage").
-define(NS_ARCHIVE_PREF, "urn:xmpp:archive:pref").
-define(NS_ARCHIVE_MANUAL, "urn:xmpp:archive:manual").
-define(INFINITY, calendar:datetime_to_gregorian_seconds({{2038,1,19},{0,0,0}})).
-define(DICT, dict).

0
mod_cron/ebin/.keepme Normal file
View File

View File

0
mod_irc/ebin/.keepme Normal file
View File

View File

View File

View File

@ -115,7 +115,7 @@ get_process_name(Host) ->
gen_mod:get_module_proc(Host, ?PROCNAME).
replace_host(Host, Filename) ->
element(2, regexp:gsub(Filename, "@HOST@", Host)).
re:replace(Filename, "@HOST@", Host, [global, {return, list}]).
open_file(Filename) ->
{ok, File} = file:open(Filename, [append]),

0
mod_logxml/ebin/.keepme Normal file
View File

View File

View File

@ -634,7 +634,7 @@ act_on_room(destroy, {N, H, Pid}, SH) ->
gen_fsm:send_all_state_event(
Pid, {destroy, "Room destroyed by rooms_unused_destroy."}),
mod_muc:room_destroyed(H, N, Pid, SH),
mod_muc:forget_room(H, N);
mod_muc:forget_room(SH, H, N);
act_on_room(list, _, _) ->
ok.

View File

View File

@ -4,17 +4,7 @@
Homepage: http://ejabberd.jabber.ru/mod_multicast
Author: Badlop
Module for ejabberd SVN
*****************************************
**
** IMPORTANT!!
**
** This code is now hosted and developed in this Git repository and branch:
** https://git.process-one.net/~badlop/ejabberd/badlop-ejabberd/commits/multicast-2.1.x
**
*****************************************
Module for ejabberd 2.1.x branch
DESCRIPTION

View File

0
mod_openid/ebin/.keepme Normal file
View File

View File

@ -133,7 +133,7 @@ check_authentication2(AssocHandle, Sig, Signed, Query) ->
%% Fields is a list of fields which should be in the query as openid.Field
%% return the list of argument [{Key,Value}] as they appears in the query
retrieve_params(Fields,Query) ->
{ok, FList} = regexp:split(Fields, ","),
FList = re:split(Fields, ",", [{return, list}]),
retrieve_params_recurse(FList,Query).
retrieve_params_recurse([],_) -> [];
retrieve_params_recurse([Key | Tail ], Query) ->

2
mod_post_log/Emakefile Normal file
View File

@ -0,0 +1,2 @@
{'../ejabberd-dev/src/gen_mod', [{outdir, "../ejabberd-dev/ebin"},{i,"../ejabberd-dev/include"}]}.
{'src/mod_post_log', [{outdir, "ebin"},{i,"../ejabberd-dev/include"}]}.

2
mod_post_log/build.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
erl -pa ../ejabberd-dev/ebin -pz ebin -make

View File

View File

@ -0,0 +1,157 @@
%%%----------------------------------------------------------------------
%%% File : mod_post_log.erl
%%% Author : Tim Stewart <tim@stoo.org>
%%% Purpose : POST user messages to server via HTTP
%%% Created : 02 Aug 2014 by Tim Stewart <tim@stoo.org>
%%%
%%% Based on mod_service_log.erl
%%%----------------------------------------------------------------------
-module(mod_post_log).
-author('tim@stoo.org').
-behaviour(gen_mod).
-export([start/2,
stop/1,
log_user_send/3,
post_result/1]).
-include("ejabberd.hrl").
-include("jlib.hrl").
start(Host, _Opts) ->
ok = case inets:start() of
{error, {already_started, inets}} ->
ok;
ok ->
ok
end,
ejabberd_hooks:add(user_send_packet, Host,
?MODULE, log_user_send, 50),
ok.
stop(Host) ->
ejabberd_hooks:delete(user_send_packet, Host,
?MODULE, log_user_send, 50),
ok.
log_user_send(From, To, Packet) ->
ok = log_packet(From, To, Packet).
log_packet(From, To, {xmlelement, "message", _Attrs, _Els} = Packet) ->
ok = log_message(From, To, Packet);
log_packet(_From, _To, {xmlelement, _Name, _Attrs, _Els}) ->
ok.
log_message(From, To, {xmlelement, _Name, Attrs, _Els} = Packet) ->
Type = lists:keyfind("type", 1, Attrs),
log_message_filter(Type, From, To, Packet).
log_message_filter({"type", Type}, From, To, Packet)
when Type =:= "chat";
Type =:= "groupchat" ->
log_chat(From, To, Packet);
log_message_filter(_Other, _From, _To, _Packet) ->
ok.
log_chat(From, To, {xmlelement, _Name, _Attrs, Els} = Packet) ->
case get_body(Els) of
no_body ->
ok;
{ok, _Body} ->
log_chat_with_body(From, To, Packet)
end.
log_chat_with_body(From, To, Packet) ->
post_xml(From, To, xml:element_to_binary(Packet)).
post_xml(From, To, Xml) ->
Ts = to_iso_8601_date(os:timestamp()),
Body = Xml,
Url = get_opt(url),
TsHeader = get_opt(ts_header, "X-Message-Timestamp"),
FromHeader = get_opt(from_header, "X-Message-From"),
ToHeader = get_opt(to_header, "X-Message-To"),
Headers = [ {TsHeader, Ts},
{FromHeader, format_jid(From)},
{ToHeader, format_jid(To)}
| get_opt(headers, []) ],
ContentType = get_opt(content_type, "text/xml"),
HttpOptions = get_opt(http_options, []),
ReqOptions = get_opt(req_options, []),
{ok, _ReqId} = httpc:request(post,
{Url, Headers, ContentType, Body},
HttpOptions,
[ {sync, false},
{receiver, {?MODULE, post_result, []}}
| ReqOptions ]),
ok.
post_result({_ReqId, {error, Reason}}) ->
report_error([ {error, Reason } ]);
post_result({_ReqId, Result}) ->
{StatusLine, Headers, Body} = Result,
{_HttpVersion, StatusCode, ReasonPhrase} = StatusLine,
if StatusCode < 200;
StatusCode > 299 ->
ok = report_error([ {status_code, StatusCode},
{reason_phrase, ReasonPhrase},
{headers, Headers},
{body, Body} ]),
ok;
true ->
ok
end.
get_body(Els) ->
XmlElements = [ El || El <- Els, element(1, El) =:= xmlelement ],
case lists:keyfind("body", 2, XmlElements) of
false ->
no_body;
{xmlelement, "body", _, InnerEls} ->
case lists:keyfind(xmlcdata, 1, InnerEls) of
false ->
no_body;
{xmlcdata, Body} ->
{ok, Body}
end
end.
get_opt(Opt) ->
get_opt(Opt, undefined).
get_opt(Opt, Default) ->
gen_mod:get_module_opt(global, ?MODULE, Opt, Default).
report_error(ReportArgs) ->
ok = error_logger:error_report([ mod_post_log_cannot_post | ReportArgs ]).
format_jid(#jid{luser = User, lserver = Server, lresource = Resource})
when Resource =:= undefined;
Resource =:= "";
Resource =:= <<"">> ->
%% The guard above feels defensive, but I don't yet know the full
%% set of ways that ejabberd will represent an empty resource
io_lib:format("~s@~s", [User, Server]);
format_jid(#jid{luser = User, lserver = Server, lresource = Resource}) ->
io_lib:format("~s@~s/~s", [User, Server, Resource]).
%% Erlang now()-style timestamps are in UTC by definition, and we are
%% assuming ISO 8601 dates should be printed in UTC as well, so no
%% conversion necessary
%%
%% Example:
%% {1385,388790,334905}
%% -becomes-
%% 2013-11-25 14:13:10.334905Z
-spec to_iso_8601_date(erlang:timestamp()) -> string().
to_iso_8601_date(Timestamp) when is_tuple(Timestamp) ->
{{Y, Mo, D}, {H, M, S}} = calendar:now_to_universal_time(Timestamp),
{_, _, US} = Timestamp,
lists:flatten(io_lib:format("~4.10.0B-~2.10.0B-~2.10.0B ~2.10.0B:~2.10.0B:~2.10.0B.~6.10.0BZ",
[Y, Mo, D, H, M, S, US])).

0
mod_profile/ebin/.keepme Normal file
View File

View File

0
mod_rest/ebin/.keepme Normal file
View File

0
mod_s2s_log/ebin/.keepme Normal file
View File

View File

0
mod_statsdx/ebin/.keepme Normal file
View File

View File

View File

@ -667,9 +667,8 @@ intund2string(undefined) -> "undefined";
intund2string(Int) when is_integer(Int) -> integer_to_list(Int).
escape(S1) ->
{ok, S2, _} = regexp:gsub(S1, "\'", "\\'"),
{ok, S3, _} = regexp:gsub(S2, "\n", "\\n"),
S3.
S2 = re:replace(S1, "\'", "\\'", [global, {return, list}]),
re:replace(S2, "\n", "\\n", [global, {return, list}]).
get_baseurl(Host) ->
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),

0
mod_xmlrpc/ebin/.keepme Normal file
View File