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:
parent
100f2e9a13
commit
0c484369c9
@ -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) ->
|
||||||
|
@ -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) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user