alias Pleroma.{Activity, Notification, User}
schema "thread_mutes" do
- field(:user_id, :string)
+ belongs_to(:user, User, type: Pleroma.FlakeId)
field(:context, :string)
end
def add_mute(user, id) do
- %{id: user_id} = user
+ user_id = user.id
%{data: %{"context" => context}} = Activity.get_by_id(id)
- Pleroma.Repo.insert(%Pleroma.Web.ThreadMute{user_id: user_id, context: context})
+ Pleroma.Repo.insert(%Pleroma.Web.ThreadMute{user: user_id, context: context})
end
def remove_mute(user, id) do
def change do
create table(:thread_mutes) do
- add :user_id, references(:users, type: :uuid, on_delete: :delete_all)
+ add :user, references(:users, type: :uuid, on_delete: :delete_all)
add :context, :string
end
- create index(:thread_mutes, [:user_id])
+ create index(:thread_mutes, [:user])
end
end