From dbb248247b5dbc0113ea9e272ea2b9495ed34041 Mon Sep 17 00:00:00 2001 From: Alexey Shchepin Date: Mon, 23 May 2005 19:47:57 +0000 Subject: * src/mod_last_odbc.erl: Added store_last_info/4 function (thanks to Sergei Golovan) * src/mod_last.erl: Likewise * src/jd2ejd.erl: Support for exporting iq:last information, better error handling (thanks to Sergei Golovan) * src/ejabberd_ctl.erl: Added "import-file" and "import-dir" commands (thanks to Sergei Golovan) SVN Revision: 358 --- src/jd2ejd.erl | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'src/jd2ejd.erl') diff --git a/src/jd2ejd.erl b/src/jd2ejd.erl index 6f2152b97..86e36a038 100644 --- a/src/jd2ejd.erl +++ b/src/jd2ejd.erl @@ -37,19 +37,23 @@ import_file(File) -> {'EXIT', Reason} -> ?ERROR_MSG( "Error while processing file \"~s\": ~p~n", - [File, Reason]); + [File, Reason]), + {error, Reason}; _ -> ok end; {error, Reason} -> ?ERROR_MSG("Can't parse file \"~s\": ~p~n", - [File, Reason]) + [File, Reason]), + {error, Reason} end; {error, Reason} -> - ?ERROR_MSG("Can't read file \"~s\": ~p~n", [File, Reason]) + ?ERROR_MSG("Can't read file \"~s\": ~p~n", [File, Reason]), + {error, Reason} end; false -> - ?ERROR_MSG("Incorrect user/server name in file \"~s\"~n", [File]) + ?ERROR_MSG("Illegal user/server name in file \"~s\"~n", [File]), + {error, "illegal user/server"} end. @@ -65,11 +69,15 @@ import_dir(Dir) -> false end end, Files), - lists:foreach( - fun(FN) -> - import_file(filename:join([Dir, FN])) - end, MsgFiles), - ok. + lists:foldl( + fun(FN, A) -> + Res = import_file(filename:join([Dir, FN])), + case {A, Res} of + {ok, ok} -> ok; + {ok, _} -> {error, "see ejabberd log for details"}; + _ -> A + end + end, ok, MsgFiles). %%%---------------------------------------------------------------------- %%% Internal functions @@ -99,6 +107,14 @@ xdb_data(User, Server, {xmlelement, _Name, Attrs, _Els} = El) -> ?NS_ROSTER -> catch mod_roster:set_items(User, Server, El), ok; + ?NS_LAST -> + TimeStamp = xml:get_attr_s("last", Attrs), + Status = xml:get_tag_cdata(El), + catch mod_last:store_last_info(User, + Server, + list_to_integer(TimeStamp), + Status), + ok; ?NS_VCARD -> catch mod_vcard:process_sm_iq( From, -- cgit v1.2.3