diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 219bbd0b6d..07822a257b 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -895,7 +895,6 @@ defmodule Pleroma.Web.Router do post("/tags/:id/follow", TagController, :follow) post("/tags/:id/unfollow", TagController, :unfollow) get("/followed_tags", TagController, :show_followed) - end post("/bite", BiteController, :bite) end diff --git a/priv/repo/migrations/20221203232118_add_user_follows_hashtag.exs b/priv/repo/migrations/20221203232118_add_user_follows_hashtag.exs index 27fff25862..2b5ae91be2 100644 --- a/priv/repo/migrations/20221203232118_add_user_follows_hashtag.exs +++ b/priv/repo/migrations/20221203232118_add_user_follows_hashtag.exs @@ -8,5 +8,7 @@ def change do end create(unique_index(:user_follows_hashtag, [:user_id, :hashtag_id])) + + create_if_not_exists(index(:user_follows_hashtag, [:hashtag_id])) end end diff --git a/test/mix/tasks/pleroma/database_test.exs b/test/mix/tasks/pleroma/database_test.exs index d401063abd..14b9ebc2c2 100644 --- a/test/mix/tasks/pleroma/database_test.exs +++ b/test/mix/tasks/pleroma/database_test.exs @@ -412,7 +412,7 @@ test "We don't have unexpected tables which may contain objects that are referen ["scheduled_activities"], ["schema_migrations"], ["thread_mutes"], - # ["user_follows_hashtag"], # not in pleroma + ["user_follows_hashtag"], # ["user_frontend_setting_profiles"], # not in pleroma ["user_invite_tokens"], ["user_notes"], diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs index a7a6b30303..1334aeb210 100644 --- a/test/pleroma/web/activity_pub/activity_pub_test.exs +++ b/test/pleroma/web/activity_pub/activity_pub_test.exs @@ -864,13 +864,19 @@ test "it should return public activities that reference a given hashtag" do user = insert(:user) other_user = insert(:user) - {:ok, normally_visible} = CommonAPI.post(other_user, %{status: "hello :)", visibility: "public"}) + {:ok, normally_visible} = + CommonAPI.post(other_user, %{status: "hello :)", visibility: "public"}) + {:ok, public} = CommonAPI.post(user, %{status: "maji #tenshi", visibility: "public"}) {:ok, _unrelated} = CommonAPI.post(user, %{status: "dai #tensh", visibility: "public"}) {:ok, unlisted} = CommonAPI.post(user, %{status: "maji #tenshi", visibility: "unlisted"}) {:ok, _private} = CommonAPI.post(user, %{status: "maji #tenshi", visibility: "private"}) - activities = ActivityPub.fetch_activities([other_user.follower_address], %{followed_hashtags: [hashtag.id]}) + activities = + ActivityPub.fetch_activities([other_user.follower_address], %{ + followed_hashtags: [hashtag.id] + }) + assert length(activities) == 3 normal_id = normally_visible.id public_id = public.id diff --git a/test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs index 0a392e0b85..e90a8ab6a1 100644 --- a/test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs @@ -459,10 +459,9 @@ test "should return 404 if disabled" do test "should not return 404 if local is specified" do clear_config([:instance, :federated_timeline_available], false) - result = - build_conn() - |> get("/api/v1/timelines/public?local=true") - |> json_response_and_validate_schema(200) + build_conn() + |> get("/api/v1/timelines/public?local=true") + |> json_response_and_validate_schema(200) end end @@ -1093,18 +1092,10 @@ test "with `%{local: true, federated: false}`, forbids unauthenticated access to describe "bubble" do setup do: oauth_access(["read:statuses"]) - test "it returns nothing if no bubble is configured", %{user: user, conn: conn} do - clear_config([:instance, :local_bubble], []) - {:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "public"}) - - conn = get(conn, "/api/v1/timelines/bubble") - - assert [] = json_response_and_validate_schema(conn, :ok) - end - test "filtering", %{conn: conn, user: user} do clear_config([:instance, :local_bubble], []) - local_user = insert(:user) + # our endpoint host has a port in it so let's set the AP ID + local_user = insert(:user, %{ap_id: "https://localhost/users/user"}) remote_user = insert(:user, %{ap_id: "https://example.com/users/remote_user"}) {:ok, user, local_user} = User.follow(user, local_user) {:ok, _user, remote_user} = User.follow(user, remote_user) @@ -1112,15 +1103,8 @@ test "filtering", %{conn: conn, user: user} do {:ok, local_activity} = CommonAPI.post(local_user, %{status: "Status"}) remote_activity = create_remote_activity(remote_user) - resp = - conn - |> get("/api/v1/timelines/bubble") - |> json_response_and_validate_schema(200) - |> Enum.map(& &1["id"]) - - assert Enum.empty?(resp) - - clear_config([:instance, :local_bubble], ["localhost:4001"]) + # If nothing, only include ours + clear_config([:instance, :local_bubble], []) one_instance = conn