mod_mam_sql: Improve check for empty archive

Avoid counting the messages of an archive to check whether it's empty.
This commit is contained in:
Holger Weiss 2019-02-21 23:50:16 +01:00
parent 9a3a7369cb
commit f63dcdb790
1 changed files with 7 additions and 9 deletions

View File

@ -268,15 +268,13 @@ export(_Server) ->
is_empty_for_user(LUser, LServer) ->
case ejabberd_sql:sql_query(
LServer,
?SQL("select @(count(*))d from archive"
" where username=%(LUser)s and %(LServer)H")) of
{selected, [{Res}]} ->
case Res of
0 -> true;
_ -> false
end;
_ -> false
end.
?SQL("select @(1)d from archive"
" where username=%(LUser)s and %(LServer)H limit 1")) of
{selected, [{1}]} ->
false;
_ ->
true
end.
is_empty_for_room(LServer, LName, LHost) ->
LUser = jid:encode({LName, LHost, <<>>}),