diff options
author | eugenijm <eugenijm@protonmail.com> | 2020-04-30 15:02:35 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-05-02 19:16:27 +0300 |
commit | 441e28f36562492ad076443c4d061b33fc0f9813 (patch) | |
tree | fc7c98667fe9557838f1087fd1a93a7052c2b007 | |
parent | c75840f7b8a117e973713c8cb47523f09deaab79 (diff) | |
download | pleroma-441e28f36562492ad076443c4d061b33fc0f9813.tar.gz |
Dismiss the follow request notification on rejection
-rw-r--r-- | lib/pleroma/notification.ex | 10 | ||||
-rw-r--r-- | lib/pleroma/web/common_api/common_api.ex | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 815356a5e..556075fba 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -271,6 +271,16 @@ defmodule Pleroma.Notification do |> Repo.delete_all() end + def dismiss(%Pleroma.Activity{} = activity) do + Notification + |> where([n], n.activity_id == ^activity.id) + |> Repo.delete_all() + |> case do + {_, notifications} -> {:ok, notifications} + _ -> {:error, "Cannot dismiss notification"} + end + end + def dismiss(%{id: user_id} = _user, id) do notification = Repo.get(Notification, id) diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index c84782008..74e9e8cfa 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.ActivityExpiration alias Pleroma.Conversation.Participation alias Pleroma.FollowingRelationship + alias Pleroma.Notification alias Pleroma.Object alias Pleroma.ThreadMute alias Pleroma.User @@ -58,6 +59,7 @@ defmodule Pleroma.Web.CommonAPI do with %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed), {:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "reject"), {:ok, _relationship} <- FollowingRelationship.update(follower, followed, :follow_reject), + {:ok, _notifications} <- Notification.dismiss(follow_activity), {:ok, _activity} <- ActivityPub.reject(%{ to: [follower.ap_id], |