diff options
author | rinpatch <rinpatch@sdf.org> | 2019-02-11 15:02:14 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-02-11 15:02:14 +0000 |
commit | 39383a6b79f5fe8e449d8e1acbc60f265065ad07 (patch) | |
tree | 0d8eeb5dc60d675dccbb9549c511d194ed31f761 /lib/pleroma/web/common_api | |
parent | 044616292b6d441c2259d423d98b38f71019aae9 (diff) | |
parent | ac72b578da673282b927b945bfe03cd3012444b6 (diff) | |
download | pleroma-39383a6b79f5fe8e449d8e1acbc60f265065ad07.tar.gz |
Merge branch 'feature/thread-muting' into 'develop'
Feature/thread muting
See merge request pleroma/pleroma!796
Diffstat (limited to 'lib/pleroma/web/common_api')
-rw-r--r-- | lib/pleroma/web/common_api/common_api.ex | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index c0d6fb5c4..86f249c54 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -7,6 +7,7 @@ defmodule Pleroma.Web.CommonAPI do alias Pleroma.Repo alias Pleroma.Activity alias Pleroma.Object + alias Pleroma.ThreadMute alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.Utils alias Pleroma.Formatter @@ -219,4 +220,27 @@ defmodule Pleroma.Web.CommonAPI do {:error, "Could not unpin"} end end + + def add_mute(user, activity) do + with {:ok, _} <- ThreadMute.add_mute(user.id, activity.data["context"]) do + {:ok, activity} + else + {:error, _} -> {:error, "conversation is already muted"} + end + end + + def remove_mute(user, activity) do + ThreadMute.remove_mute(user.id, activity.data["context"]) + {:ok, activity} + end + + def thread_muted?(%{id: nil} = _user, _activity), do: false + + def thread_muted?(user, activity) do + with [] <- ThreadMute.check_muted(user.id, activity.data["context"]) do + false + else + _ -> true + end + end end |