From: Ivan Tashkinov Date: Tue, 22 Jan 2019 14:12:53 +0000 (+0300) Subject: [#502] Fixed User.active_local_user_query to return users with nil or missing `info... X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=34d59e40086ad8adc020bac6d23ab2aa835f267b;p=akkoma [#502] Fixed User.active_local_user_query to return users with nil or missing `info.deactivated`. Adjusted test. --- diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 06084b117..18137106e 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -901,7 +901,7 @@ defmodule Pleroma.User do def active_local_user_query do from( u in local_user_query(), - where: fragment("?->'deactivated' @> 'false'", u.info) + where: fragment("not (?->'deactivated' @> 'true')", u.info) ) end diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index dd84052a3..8443dc856 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -10,6 +10,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do alias Pleroma.Web.{OStatus, CommonAPI} alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.MastodonAPI.FilterView + alias Ecto.Changeset import Pleroma.Factory import ExUnit.CaptureLog import Tesla.Mock @@ -1483,6 +1484,16 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do {: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() conn = get(conn, "/api/v1/instance")