Transmogrifier: Update notification after accepting.

This commit is contained in:
lain 2020-06-04 19:22:49 +02:00
parent 00748e9650
commit 56dfa0e0fb
2 changed files with 9 additions and 1 deletions

View file

@ -538,6 +538,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
{_, false} <- {:user_blocked, User.blocks?(followed, follower) && deny_follow_blocked}, {_, false} <- {:user_blocked, User.blocks?(followed, follower) && deny_follow_blocked},
{_, false} <- {:user_locked, User.locked?(followed)}, {_, false} <- {:user_locked, User.locked?(followed)},
{_, {:ok, follower}} <- {:follow, User.follow(follower, followed)}, {_, {:ok, follower}} <- {:follow, User.follow(follower, followed)},
_ <- Notification.update_notification_type(followed, activity),
{_, {:ok, _}} <- {_, {:ok, _}} <-
{:follow_state_update, Utils.update_follow_state_for_all(activity, "accept")}, {:follow_state_update, Utils.update_follow_state_for_all(activity, "accept")},
{:ok, _relationship} <- {:ok, _relationship} <-

View file

@ -5,6 +5,7 @@
defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
use Pleroma.DataCase use Pleroma.DataCase
alias Pleroma.Activity alias Pleroma.Activity
alias Pleroma.Notification
alias Pleroma.Repo alias Pleroma.Repo
alias Pleroma.User alias Pleroma.User
alias Pleroma.Web.ActivityPub.Transmogrifier alias Pleroma.Web.ActivityPub.Transmogrifier
@ -57,9 +58,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
activity = Repo.get(Activity, activity.id) activity = Repo.get(Activity, activity.id)
assert activity.data["state"] == "accept" assert activity.data["state"] == "accept"
assert User.following?(User.get_cached_by_ap_id(data["actor"]), user) assert User.following?(User.get_cached_by_ap_id(data["actor"]), user)
[notification] = Notification.for_user(user)
assert notification.type == "follow"
end end
test "with locked accounts, it does not create a follow or an accept" do test "with locked accounts, it does create a Follow, but not an Accept" do
user = insert(:user, locked: true) user = insert(:user, locked: true)
data = data =
@ -81,6 +85,9 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
|> Repo.all() |> Repo.all()
assert Enum.empty?(accepts) assert Enum.empty?(accepts)
[notification] = Notification.for_user(user)
assert notification.type == "follow_request"
end end
test "it works for follow requests when you are already followed, creating a new accept activity" do test "it works for follow requests when you are already followed, creating a new accept activity" do