diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-02-17 14:07:04 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-02-17 14:07:04 +0300 |
commit | bc4f77b10bb4360ac00d1999b1d08fa55e1fa547 (patch) | |
tree | 8c87c2cefd1e325a64a19c04d7d7d70ffd8cc485 /lib/pleroma/web/common_api/common_api.ex | |
parent | dcf24a3233bb50689d26f9d7833f98158730ce35 (diff) | |
parent | 3b141194715e362d65482672d00b10991d102fa2 (diff) | |
download | pleroma-bc4f77b10bb4360ac00d1999b1d08fa55e1fa547.tar.gz |
[#468] Merged `upstream/develop`, resolved conflicts.
Diffstat (limited to 'lib/pleroma/web/common_api/common_api.ex')
-rw-r--r-- | lib/pleroma/web/common_api/common_api.ex | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 7084da6de..86f249c54 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -3,7 +3,11 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.CommonAPI do - alias Pleroma.{User, Repo, Activity, Object} + alias Pleroma.User + 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 @@ -216,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 |