Fix mod_muc_log_http to compile and run with recent ejabberd (#221)
This commit is contained in:
parent
2a95a53285
commit
18d1a5d60d
|
@ -13,19 +13,16 @@
|
||||||
-export([
|
-export([
|
||||||
start/2,
|
start/2,
|
||||||
stop/1,
|
stop/1,
|
||||||
loop/1,
|
|
||||||
process/2
|
process/2
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("jlib.hrl").
|
-include("xmpp.hrl").
|
||||||
-include("ejabberd_http.hrl").
|
-include("ejabberd_http.hrl").
|
||||||
-include("mod_muc_room.hrl").
|
-include("mod_muc_room.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
-include_lib("kernel/include/file.hrl").
|
-include_lib("kernel/include/file.hrl").
|
||||||
|
|
||||||
-define(PROCNAME, mod_muc_log_http).
|
|
||||||
|
|
||||||
% TODO:
|
% TODO:
|
||||||
% - If chatroom is password protected, ask password
|
% - If chatroom is password protected, ask password
|
||||||
% - If chatroom is only for members, ask for username and password
|
% - If chatroom is only for members, ask for username and password
|
||||||
|
@ -42,9 +39,7 @@ process(LocalPath, Request) ->
|
||||||
serve(LocalPath, Request).
|
serve(LocalPath, Request).
|
||||||
|
|
||||||
serve(LocalPathBin, #request{host = Host} = Request) ->
|
serve(LocalPathBin, #request{host = Host} = Request) ->
|
||||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
DocRoot = binary_to_list(gen_mod:get_module_opt(Host, mod_muc_log, outdir, <<"www/muc">>)),
|
||||||
Proc ! {get_docroot, self()},
|
|
||||||
receive DocRoot -> ok end,
|
|
||||||
LocalPath = [binary_to_list(LPB) || LPB <- LocalPathBin],
|
LocalPath = [binary_to_list(LPB) || LPB <- LocalPathBin],
|
||||||
FileName = filename:join(filename:split(DocRoot) ++ LocalPath),
|
FileName = filename:join(filename:split(DocRoot) ++ LocalPath),
|
||||||
case file:read_file(FileName) of
|
case file:read_file(FileName) of
|
||||||
|
@ -227,27 +222,12 @@ last_modified(FileName) ->
|
||||||
Then = FileInfo#file_info.mtime,
|
Then = FileInfo#file_info.mtime,
|
||||||
httpd_util:rfc1123_date(Then).
|
httpd_util:rfc1123_date(Then).
|
||||||
|
|
||||||
loop(DocRoot) ->
|
|
||||||
receive
|
|
||||||
{get_docroot, Pid} ->
|
|
||||||
Pid ! DocRoot,
|
|
||||||
loop(DocRoot);
|
|
||||||
stop ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% BEHAVIOUR CALLBACKS
|
%%% BEHAVIOUR CALLBACKS
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
DocRootBin = gen_mod:get_module_opt(Host, mod_muc_log, outdir, fun(A) -> A end, <<"www/muc">>),
|
ok.
|
||||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
|
||||||
DocRoot = binary_to_list(DocRootBin),
|
|
||||||
catch register(Proc, spawn(?MODULE, loop, [DocRoot])),
|
|
||||||
ok.
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
ok.
|
||||||
exit(whereis(Proc), stop),
|
|
||||||
{wait, Proc}.
|
|
||||||
|
|
Loading…
Reference in New Issue