[#502] Fixed User.active_local_user_query to return users with nil or missing `info.deactivated`. Adjusted test.
This commit is contained in:
parent
d17a4b1891
commit
34d59e4008
|
@ -901,7 +901,7 @@ def local_user_query do
|
||||||
def active_local_user_query do
|
def active_local_user_query do
|
||||||
from(
|
from(
|
||||||
u in local_user_query(),
|
u in local_user_query(),
|
||||||
where: fragment("?->'deactivated' @> 'false'", u.info)
|
where: fragment("not (?->'deactivated' @> 'true')", u.info)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
||||||
alias Pleroma.Web.{OStatus, CommonAPI}
|
alias Pleroma.Web.{OStatus, CommonAPI}
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.MastodonAPI.FilterView
|
alias Pleroma.Web.MastodonAPI.FilterView
|
||||||
|
alias Ecto.Changeset
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
import ExUnit.CaptureLog
|
import ExUnit.CaptureLog
|
||||||
import Tesla.Mock
|
import Tesla.Mock
|
||||||
|
@ -1483,6 +1484,16 @@ test "get instance information", %{conn: conn} do
|
||||||
|
|
||||||
{:ok, _} = TwitterAPI.create_status(user, %{"status" => "cofe"})
|
{:ok, _} = TwitterAPI.create_status(user, %{"status" => "cofe"})
|
||||||
|
|
||||||
|
# Stats should count users with missing or nil `info.deactivated` value
|
||||||
|
user = Repo.get(User, user.id)
|
||||||
|
info_change = Changeset.change(user.info, %{deactivated: nil})
|
||||||
|
|
||||||
|
{:ok, _user} =
|
||||||
|
user
|
||||||
|
|> Changeset.change()
|
||||||
|
|> Changeset.put_embed(:info, info_change)
|
||||||
|
|> User.update_and_set_cache()
|
||||||
|
|
||||||
Pleroma.Stats.update_stats()
|
Pleroma.Stats.update_stats()
|
||||||
|
|
||||||
conn = get(conn, "/api/v1/instance")
|
conn = get(conn, "/api/v1/instance")
|
||||||
|
|
Loading…
Reference in New Issue