mod_post_log Warning: undefined callback function mod_options/1 #283
This commit is contained in:
parent
75129ec0bc
commit
0ab2007a3a
|
@ -16,6 +16,7 @@
|
||||||
stop/1,
|
stop/1,
|
||||||
depends/2,
|
depends/2,
|
||||||
mod_opt_type/1,
|
mod_opt_type/1,
|
||||||
|
mod_options/1,
|
||||||
log_user_send/1,
|
log_user_send/1,
|
||||||
log_user_send/4,
|
log_user_send/4,
|
||||||
post_result/1]).
|
post_result/1]).
|
||||||
|
@ -50,10 +51,18 @@ mod_opt_type(from_header) -> fun iolist_to_binary/1;
|
||||||
mod_opt_type(to_header) -> fun iolist_to_binary/1;
|
mod_opt_type(to_header) -> fun iolist_to_binary/1;
|
||||||
mod_opt_type(headers) -> fun(L) when is_list(L) -> L end;
|
mod_opt_type(headers) -> fun(L) when is_list(L) -> L end;
|
||||||
mod_opt_type(content_type) -> fun iolist_to_binary/1;
|
mod_opt_type(content_type) -> fun iolist_to_binary/1;
|
||||||
mod_opt_type(req_options) -> fun(L) when is_list(L) -> L end;
|
mod_opt_type(http_options) -> fun(L) when is_list(L) -> L end;
|
||||||
mod_opt_type(_) ->
|
mod_opt_type(req_options) -> fun(L) when is_list(L) -> L end.
|
||||||
[url, ts_header, from_header, to_header, headers,
|
|
||||||
content_type, req_options].
|
mod_options(_Host) ->
|
||||||
|
[{url, undefined},
|
||||||
|
{ts_header, "X-Message-Timestamp"},
|
||||||
|
{from_header, "X-Message-From"},
|
||||||
|
{to_header, "X-Message-To"},
|
||||||
|
{headers, []},
|
||||||
|
{content_type, "text/xml"},
|
||||||
|
{http_options, []},
|
||||||
|
{req_options, []}].
|
||||||
|
|
||||||
%% TODO: remove log_user_send/4 after 17.02 is released
|
%% TODO: remove log_user_send/4 after 17.02 is released
|
||||||
log_user_send(Packet, C2SState, From, To) ->
|
log_user_send(Packet, C2SState, From, To) ->
|
||||||
|
@ -82,16 +91,16 @@ post_xml(#jid{lserver = LServer} = From, To, Xml) ->
|
||||||
Body = Xml,
|
Body = Xml,
|
||||||
|
|
||||||
Url = get_opt(LServer, url),
|
Url = get_opt(LServer, url),
|
||||||
TsHeader = get_opt(LServer, ts_header, "X-Message-Timestamp"),
|
TsHeader = get_opt(LServer, ts_header),
|
||||||
FromHeader = get_opt(LServer, from_header, "X-Message-From"),
|
FromHeader = get_opt(LServer, from_header),
|
||||||
ToHeader = get_opt(LServer, to_header, "X-Message-To"),
|
ToHeader = get_opt(LServer, to_header),
|
||||||
Headers = [ {TsHeader, Ts},
|
Headers = [ {TsHeader, Ts},
|
||||||
{FromHeader, format_jid(From)},
|
{FromHeader, format_jid(From)},
|
||||||
{ToHeader, format_jid(To)}
|
{ToHeader, format_jid(To)}
|
||||||
| get_opt(LServer, headers, []) ],
|
| get_opt(LServer, headers) ],
|
||||||
ContentType = get_opt(LServer, content_type, "text/xml"),
|
ContentType = get_opt(LServer, content_type),
|
||||||
HttpOptions = get_opt(LServer, http_options, []),
|
HttpOptions = get_opt(LServer, http_options),
|
||||||
ReqOptions = get_opt(LServer, req_options, []),
|
ReqOptions = get_opt(LServer, req_options),
|
||||||
|
|
||||||
{ok, _ReqId} = httpc:request(post,
|
{ok, _ReqId} = httpc:request(post,
|
||||||
{Url, Headers, ContentType, Body},
|
{Url, Headers, ContentType, Body},
|
||||||
|
@ -118,10 +127,7 @@ post_result({_ReqId, Result}) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_opt(LServer, Opt) ->
|
get_opt(LServer, Opt) ->
|
||||||
get_opt(LServer, Opt, undefined).
|
gen_mod:get_module_opt(LServer, ?MODULE, Opt).
|
||||||
|
|
||||||
get_opt(LServer, Opt, Default) ->
|
|
||||||
gen_mod:get_module_opt(LServer, ?MODULE, Opt, Default).
|
|
||||||
|
|
||||||
report_error(ReportArgs) ->
|
report_error(ReportArgs) ->
|
||||||
ok = error_logger:error_report([ mod_post_log_cannot_post | ReportArgs ]).
|
ok = error_logger:error_report([ mod_post_log_cannot_post | ReportArgs ]).
|
||||||
|
|
Loading…
Reference in New Issue