projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
activity: when restricting deactivated users, precalculate the user list
[akkoma]
/
lib
/
pleroma
/
filter.ex
diff --git
a/lib/pleroma/filter.ex
b/lib/pleroma/filter.ex
index 25ed38f34927c7bdee2d91176e317a7bf4d7bd74..90457dadf8641f9c100aa067ba8678dc0ef55c60 100644
(file)
--- a/
lib/pleroma/filter.ex
+++ b/
lib/pleroma/filter.ex
@@
-1,10
+1,18
@@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Filter do
use Ecto.Schema
defmodule Pleroma.Filter do
use Ecto.Schema
- import Ecto.{Changeset, Query}
- alias Pleroma.{User, Repo, Activity}
+
+ import Ecto.Changeset
+ import Ecto.Query
+
+ alias Pleroma.Repo
+ alias Pleroma.User
schema "filters" do
schema "filters" do
- belongs_to(:user,
Pleroma.User
)
+ belongs_to(:user,
User, type: Pleroma.FlakeId
)
field(:filter_id, :integer)
field(:hide, :boolean, default: false)
field(:whole_word, :boolean, default: true)
field(:filter_id, :integer)
field(:hide, :boolean, default: false)
field(:whole_word, :boolean, default: true)
@@
-26,11
+34,12
@@
defmodule Pleroma.Filter do
Repo.one(query)
end
Repo.one(query)
end
- def get_filters(%
Pleroma.User{id: user_id} =
user) do
+ def get_filters(%
User{id: user_id} = _
user) do
query =
from(
f in Pleroma.Filter,
query =
from(
f in Pleroma.Filter,
- where: f.user_id == ^user_id
+ where: f.user_id == ^user_id,
+ order_by: [desc: :id]
)
Repo.all(query)
)
Repo.all(query)
@@
-38,9
+47,9
@@
defmodule Pleroma.Filter do
def create(%Pleroma.Filter{user_id: user_id, filter_id: nil} = filter) do
# If filter_id wasn't given, use the max filter_id for this user plus 1.
def create(%Pleroma.Filter{user_id: user_id, filter_id: nil} = filter) do
# If filter_id wasn't given, use the max filter_id for this user plus 1.
- # XXX This could result in a race condition if a user tries to add two
- # different filters for their account from two different clients at the
- # same time, but that should be unlikely.
+ # XXX This could result in a race condition if a user tries to add two
+ # different filters for their account from two different clients at the
+ # same time, but that should be unlikely.
max_id_query =
from(
max_id_query =
from(