Update the mute implementation to the current codebase
Make it part of the info thing (and do a migration to ensure it's there)
This commit is contained in:
parent
465b547c90
commit
5a46d37af9
6 changed files with 64 additions and 20 deletions
|
|
@ -19,6 +19,7 @@ defmodule Pleroma.User.Info do
|
|||
field(:default_scope, :string, default: "public")
|
||||
field(:blocks, {:array, :string}, default: [])
|
||||
field(:domain_blocks, {:array, :string}, default: [])
|
||||
field(:mutes, {:array, :string}, default: [])
|
||||
field(:deactivated, :boolean, default: false)
|
||||
field(:no_rich_text, :boolean, default: false)
|
||||
field(:ap_enabled, :boolean, default: false)
|
||||
|
|
@ -74,6 +75,14 @@ defmodule Pleroma.User.Info do
|
|||
|> validate_required([:follower_count])
|
||||
end
|
||||
|
||||
def set_mutes(info, mutes) do
|
||||
params = %{mutes: mutes}
|
||||
|
||||
info
|
||||
|> cast(params, [:mutes])
|
||||
|> validate_required([:mutes])
|
||||
end
|
||||
|
||||
def set_blocks(info, blocks) do
|
||||
params = %{blocks: blocks}
|
||||
|
||||
|
|
@ -82,6 +91,14 @@ defmodule Pleroma.User.Info do
|
|||
|> validate_required([:blocks])
|
||||
end
|
||||
|
||||
def add_to_mutes(info, muted) do
|
||||
set_mutes(info, Enum.uniq([muted | info.mutes]))
|
||||
end
|
||||
|
||||
def remove_from_mutes(info, muted) do
|
||||
set_mutes(info, List.delete(info.mutes, muted))
|
||||
end
|
||||
|
||||
def add_to_block(info, blocked) do
|
||||
set_blocks(info, Enum.uniq([blocked | info.blocks]))
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue