aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api/common_api.ex
diff options
context:
space:
mode:
authorkaniini <nenolod@gmail.com>2019-03-16 04:31:31 +0000
committerkaniini <nenolod@gmail.com>2019-03-16 04:31:31 +0000
commitc69dc2acf1e4cb1afe61bda3566aec44d48a240f (patch)
tree919ef67a2b39f7c80c253fa8b940f1f37da17305 /lib/pleroma/web/common_api/common_api.ex
parentf58d47d6f752fa04bfd0a5d809b6d4e28248654d (diff)
parentd8244c2a1bfc54b9dfa70be3ce49db961205f883 (diff)
downloadpleroma-c69dc2acf1e4cb1afe61bda3566aec44d48a240f.tar.gz
Merge branch 'feature/reblog-muting' into 'develop'
Implement mastodon's reblog hiding feature See merge request pleroma/pleroma!916
Diffstat (limited to 'lib/pleroma/web/common_api/common_api.ex')
-rw-r--r--lib/pleroma/web/common_api/common_api.ex20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index de0759fb0..84d66efc9 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -299,4 +299,24 @@ defmodule Pleroma.Web.CommonAPI do
{:account, nil} -> {:error, "Account not found"}
end
end
+
+ def hide_reblogs(user, muted) do
+ ap_id = muted.ap_id
+
+ if ap_id not in user.info.muted_reblogs do
+ info_changeset = User.Info.add_reblog_mute(user.info, ap_id)
+ changeset = Ecto.Changeset.change(user) |> Ecto.Changeset.put_embed(:info, info_changeset)
+ User.update_and_set_cache(changeset)
+ end
+ end
+
+ def show_reblogs(user, muted) do
+ ap_id = muted.ap_id
+
+ if ap_id in user.info.muted_reblogs do
+ info_changeset = User.Info.remove_reblog_mute(user.info, ap_id)
+ changeset = Ecto.Changeset.change(user) |> Ecto.Changeset.put_embed(:info, info_changeset)
+ User.update_and_set_cache(changeset)
+ end
+ end
end