- Mastodon API: Add `/api/v1/markers` for managing timeline read markers
- Mastodon API: Add the `recipients` parameter to `GET /api/v1/conversations`
- Configuration: `feed` option for user atom feed.
+- Admin API: Add `/api/pleroma/admin/instances/:instance/statuses` - lists all statuses from a given instance
</details>
### Fixed
|> Enum.reverse()
end
+ def fetch_instance_activities(params) do
+ params =
+ params
+ |> Map.put("type", ["Create", "Announce"])
+ |> Map.put("instance", params["instance"])
+ |> Map.put("whole_db", true)
+
+ fetch_activities([Pleroma.Constants.as_public()], params, :offset)
+ |> Enum.reverse()
+ end
+
defp user_activities_recipients(%{"godmode" => true}) do
[]
end
defp restrict_muted_reblogs(query, _), do: query
+ defp restrict_instance(query, %{"instance" => instance}) do
+ users =
+ from(
+ u in User,
+ select: u.ap_id,
+ where: fragment("? LIKE ?", u.nickname, ^"%@#{instance}")
+ )
+ |> Repo.all()
+
+ from(activity in query, where: activity.actor in ^users)
+ end
+
+ defp restrict_instance(query, _), do: query
+
defp exclude_poll_votes(query, %{"include_poll_votes" => true}), do: query
defp exclude_poll_votes(query, _) do
|> restrict_reblogs(opts)
|> restrict_pinned(opts)
|> restrict_muted_reblogs(opts)
+ |> restrict_instance(opts)
|> Activity.restrict_deactivated_users()
|> exclude_poll_votes(opts)
|> exclude_visibility(opts)
end
end
+ def list_instance_statuses(conn, %{"instance" => instance} = params) do
+ {page, page_size} = page_params(params)
+
+ activities =
+ ActivityPub.fetch_instance_activities(%{
+ "instance" => instance,
+ "limit" => page_size,
+ "offset" => (page - 1) * page_size
+ })
+
+ conn
+ |> put_view(StatusView)
+ |> render("index.json", %{activities: activities, as: :activity})
+ end
+
def list_user_statuses(conn, %{"nickname" => nickname} = params) do
godmode = params["godmode"] == "true" || params["godmode"] == true
get("/users/:nickname", AdminAPIController, :user_show)
get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
+ get("/instances/:instance/statuses", AdminAPIController, :list_instance_statuses)
+
get("/reports", AdminAPIController, :list_reports)
get("/reports/:id", AdminAPIController, :report_show)
put("/reports/:id", AdminAPIController, :report_update_state)
"@#{admin.nickname} unfollowed relay: http://mastodon.example.org/users/admin"
end
end
+
+ describe "instances" do
+ test "GET /instances/:instance/statuses" do
+ admin = insert(:user, is_admin: true)
+ user = insert(:user, local: false, nickname: "archaeme@archae.me")
+ user2 = insert(:user, local: false, nickname: "test@test.com")
+ insert_pair(:note_activity, user: user)
+ insert(:note_activity, user: user2)
+
+ conn =
+ build_conn()
+ |> assign(:user, admin)
+ |> get("/api/pleroma/admin/instances/archae.me/statuses")
+
+ response = json_response(conn, 200)
+
+ assert length(response) == 2
+
+ conn =
+ build_conn()
+ |> assign(:user, admin)
+ |> get("/api/pleroma/admin/instances/test.com/statuses")
+
+ response = json_response(conn, 200)
+
+ assert length(response) == 1
+
+ conn =
+ build_conn()
+ |> assign(:user, admin)
+ |> get("/api/pleroma/admin/instances/nonexistent.com/statuses")
+
+ response = json_response(conn, 200)
+
+ assert length(response) == 0
+ end
+ end
end
# Needed for testing