diff options
author | Karen Konou <konoukaren@gmail.com> | 2019-03-09 14:08:41 +0100 |
---|---|---|
committer | Karen Konou <konoukaren@gmail.com> | 2019-03-15 14:18:21 +0100 |
commit | c8f31e0bc2764c924a4045e007e828052c837ac2 (patch) | |
tree | c788aa39e450bf9849628f70ddc6762a6e078bc2 /lib/pleroma/web/common_api/common_api.ex | |
parent | 41fc67aa4993c119dae82578df7309d3999ac47a (diff) | |
download | pleroma-c8f31e0bc2764c924a4045e007e828052c837ac2.tar.gz |
Implement mastodon's reblog hiding feature
Diffstat (limited to 'lib/pleroma/web/common_api/common_api.ex')
-rw-r--r-- | lib/pleroma/web/common_api/common_api.ex | 16 |
1 files changed, 16 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..035c59387 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -299,4 +299,20 @@ defmodule Pleroma.Web.CommonAPI do {:account, nil} -> {:error, "Account not found"} end end + + def hide_reblogs(user, id) do + if id not in user.info.muted_reblogs do + info_changeset = User.Info.add_reblog_mute(user.info, 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, id) do + if id in user.info.muted_reblogs do + info_changeset = User.Info.remove_reblog_mute(user.info, id) + changeset = Ecto.Changeset.change(user) |> Ecto.Changeset.put_embed(:info, info_changeset) + User.update_and_set_cache(changeset) + end + end end |