diff options
author | lain <lain@soykaf.club> | 2019-04-02 16:04:18 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-04-02 16:08:55 +0200 |
commit | fd07745d1b18e2a1eeb88a99eaa9d5e728d1aa71 (patch) | |
tree | 734e37960d5af945240217420c9073f8327da48a /test/web/activity_pub/utils_test.exs | |
parent | 749d53e2b2ffb108964c569f04e5989c63643338 (diff) | |
download | pleroma-fd07745d1b18e2a1eeb88a99eaa9d5e728d1aa71.tar.gz pleroma-fd07745d1b18e2a1eeb88a99eaa9d5e728d1aa71.zip |
ActivityPub Utils: Greatly speed up the follow / block activity fetching.
Diffstat (limited to 'test/web/activity_pub/utils_test.exs')
-rw-r--r-- | test/web/activity_pub/utils_test.exs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/web/activity_pub/utils_test.exs b/test/web/activity_pub/utils_test.exs index 2bd3ddf93..6b9961d82 100644 --- a/test/web/activity_pub/utils_test.exs +++ b/test/web/activity_pub/utils_test.exs @@ -1,10 +1,34 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do use Pleroma.DataCase + alias Pleroma.Activity + alias Pleroma.Repo + alias Pleroma.User + alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.Utils alias Pleroma.Web.CommonAPI import Pleroma.Factory + describe "fetch the latest Follow" do + test "fetches the latest Follow activity" do + %Activity{data: %{"type" => "Follow"}} = activity = insert(:follow_activity) + follower = Repo.get_by(User, ap_id: activity.data["actor"]) + followed = Repo.get_by(User, ap_id: activity.data["object"]) + + assert activity == Utils.fetch_latest_follow(follower, followed) + end + end + + describe "fetch the latest Block" do + test "fetches the latest Block activity" do + blocker = insert(:user) + blocked = insert(:user) + {:ok, activity} = ActivityPub.block(blocker, blocked) + + assert activity == Utils.fetch_latest_block(blocker, blocked) + end + end + describe "determine_explicit_mentions()" do test "works with an object that has mentions" do object = %{ |