25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

In mod_last*:get_last_iq/4, check for user resources first to return 0 seconds if there is one

Fixes problem 2 of EJAB-1158.
This commit is contained in:
Andreas Köhler 2010-11-05 18:38:42 +01:00 committed by Badlop
parent 100f2e9a13
commit 0c484369c9
2 changed files with 38 additions and 20 deletions

View File

@ -153,6 +153,8 @@ get_last(LUser, LServer) ->
end. end.
get_last_iq(IQ, SubEl, LUser, LServer) -> get_last_iq(IQ, SubEl, LUser, LServer) ->
case ejabberd_sm:get_user_resources(LUser, LServer) of
[] ->
case get_last(LUser, LServer) of case get_last(LUser, LServer) of
{error, _Reason} -> {error, _Reason} ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]}; IQ#iq{type = error, sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]};
@ -166,6 +168,13 @@ get_last_iq(IQ, SubEl, LUser, LServer) ->
[{"xmlns", ?NS_LAST}, [{"xmlns", ?NS_LAST},
{"seconds", integer_to_list(Sec)}], {"seconds", integer_to_list(Sec)}],
[{xmlcdata, Status}]}]} [{xmlcdata, Status}]}]}
end;
_ ->
IQ#iq{type = result,
sub_el = [{xmlelement, "query",
[{"xmlns", ?NS_LAST},
{"seconds", "0"}],
[]}]}
end. end.
on_presence_update(User, Server, _Resource, Status) -> on_presence_update(User, Server, _Resource, Status) ->

View File

@ -151,6 +151,8 @@ get_last(LUser, LServer) ->
end. end.
get_last_iq(IQ, SubEl, LUser, LServer) -> get_last_iq(IQ, SubEl, LUser, LServer) ->
case ejabberd_sm:get_user_resources(LUser, LServer) of
[] ->
case get_last(LUser, LServer) of case get_last(LUser, LServer) of
{error, _Reason} -> {error, _Reason} ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]}; IQ#iq{type = error, sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]};
@ -164,6 +166,13 @@ get_last_iq(IQ, SubEl, LUser, LServer) ->
[{"xmlns", ?NS_LAST}, [{"xmlns", ?NS_LAST},
{"seconds", integer_to_list(Sec)}], {"seconds", integer_to_list(Sec)}],
[{xmlcdata, Status}]}]} [{xmlcdata, Status}]}]}
end;
_ ->
IQ#iq{type = result,
sub_el = [{xmlelement, "query",
[{"xmlns", ?NS_LAST},
{"seconds", "0"}],
[]}]}
end. end.
on_presence_update(User, Server, _Resource, Status) -> on_presence_update(User, Server, _Resource, Status) ->