From a51d903e0c8c87247df6b3cdecc476269edf58ce Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Thu, 28 Jan 2021 22:23:10 +0400 Subject: [PATCH] Make sure active_user_count/1 counts only local users --- lib/pleroma/user.ex | 3 ++- test/pleroma/user_test.exs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 1dde65335..06cdb42af 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -2446,7 +2446,7 @@ defmodule Pleroma.User do URI.parse(ap_id).host end - def update_last_active_at(user) do + def update_last_active_at(%__MODULE__{local: true} = user) do user |> cast(%{last_active_at: NaiveDateTime.utc_now()}, [:last_active_at]) |> update_and_set_cache() @@ -2457,6 +2457,7 @@ defmodule Pleroma.User do __MODULE__ |> where([u], u.last_active_at >= ^active_after) + |> where([u], u.local == true) |> Repo.aggregate(:count) end end diff --git a/test/pleroma/user_test.exs b/test/pleroma/user_test.exs index 1fab519f0..ae6fc4c0d 100644 --- a/test/pleroma/user_test.exs +++ b/test/pleroma/user_test.exs @@ -2278,6 +2278,7 @@ defmodule Pleroma.UserTest do test "active_user_count/1" do insert(:user) + insert(:user, %{local: false}) insert(:user, %{last_active_at: Timex.shift(NaiveDateTime.utc_now(), weeks: -5)}) insert(:user, %{last_active_at: Timex.shift(NaiveDateTime.utc_now(), weeks: -3)}) insert(:user, %{last_active_at: NaiveDateTime.utc_now()}) -- 2.45.2