forked from AkkomaGang/akkoma
Dismiss the follow request notification on rejection
This commit is contained in:
parent
c75840f7b8
commit
441e28f365
2 changed files with 12 additions and 0 deletions
|
@ -271,6 +271,16 @@ def destroy_multiple(%{id: user_id} = _user, ids) do
|
||||||
|> Repo.delete_all()
|
|> Repo.delete_all()
|
||||||
end
|
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
|
def dismiss(%{id: user_id} = _user, id) do
|
||||||
notification = Repo.get(Notification, id)
|
notification = Repo.get(Notification, id)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ defmodule Pleroma.Web.CommonAPI do
|
||||||
alias Pleroma.ActivityExpiration
|
alias Pleroma.ActivityExpiration
|
||||||
alias Pleroma.Conversation.Participation
|
alias Pleroma.Conversation.Participation
|
||||||
alias Pleroma.FollowingRelationship
|
alias Pleroma.FollowingRelationship
|
||||||
|
alias Pleroma.Notification
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.ThreadMute
|
alias Pleroma.ThreadMute
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
@ -58,6 +59,7 @@ def reject_follow_request(follower, followed) do
|
||||||
with %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed),
|
with %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed),
|
||||||
{:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "reject"),
|
{:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "reject"),
|
||||||
{:ok, _relationship} <- FollowingRelationship.update(follower, followed, :follow_reject),
|
{:ok, _relationship} <- FollowingRelationship.update(follower, followed, :follow_reject),
|
||||||
|
{:ok, _notifications} <- Notification.dismiss(follow_activity),
|
||||||
{:ok, _activity} <-
|
{:ok, _activity} <-
|
||||||
ActivityPub.reject(%{
|
ActivityPub.reject(%{
|
||||||
to: [follower.ap_id],
|
to: [follower.ap_id],
|
||||||
|
|
Loading…
Reference in a new issue