Expose history and source apis to anon users
This commit is contained in:
parent
c3593639ad
commit
27f3d802f2
@ -195,8 +195,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
@doc "GET /api/v1/statuses/:id/history"
|
@doc "GET /api/v1/statuses/:id/history"
|
||||||
def show_history(%{assigns: %{user: user}} = conn, %{id: id} = params) do
|
def show_history(%{assigns: assigns} = conn, %{id: id} = params) do
|
||||||
with %Activity{} = activity <- Activity.get_by_id_with_object(id),
|
with user = assigns[:user],
|
||||||
|
%Activity{} = activity <- Activity.get_by_id_with_object(id),
|
||||||
true <- Visibility.visible_for_user?(activity, user) do
|
true <- Visibility.visible_for_user?(activity, user) do
|
||||||
try_render(conn, "history.json",
|
try_render(conn, "history.json",
|
||||||
activity: activity,
|
activity: activity,
|
||||||
@ -210,8 +211,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
@doc "GET /api/v1/statuses/:id/source"
|
@doc "GET /api/v1/statuses/:id/source"
|
||||||
def show_source(%{assigns: %{user: user}} = conn, %{id: id} = _params) do
|
def show_source(%{assigns: assigns} = conn, %{id: id} = _params) do
|
||||||
with %Activity{} = activity <- Activity.get_by_id_with_object(id),
|
with user = assigns[:user],
|
||||||
|
%Activity{} = activity <- Activity.get_by_id_with_object(id),
|
||||||
true <- Visibility.visible_for_user?(activity, user) do
|
true <- Visibility.visible_for_user?(activity, user) do
|
||||||
try_render(conn, "source.json",
|
try_render(conn, "source.json",
|
||||||
activity: activity,
|
activity: activity,
|
||||||
|
@ -552,8 +552,6 @@ defmodule Pleroma.Web.Router do
|
|||||||
get("/bookmarks", StatusController, :bookmarks)
|
get("/bookmarks", StatusController, :bookmarks)
|
||||||
|
|
||||||
post("/statuses", StatusController, :create)
|
post("/statuses", StatusController, :create)
|
||||||
get("/statuses/:id/history", StatusController, :show_history)
|
|
||||||
get("/statuses/:id/source", StatusController, :show_source)
|
|
||||||
put("/statuses/:id", StatusController, :update)
|
put("/statuses/:id", StatusController, :update)
|
||||||
delete("/statuses/:id", StatusController, :delete)
|
delete("/statuses/:id", StatusController, :delete)
|
||||||
post("/statuses/:id/reblog", StatusController, :reblog)
|
post("/statuses/:id/reblog", StatusController, :reblog)
|
||||||
@ -611,6 +609,8 @@ defmodule Pleroma.Web.Router do
|
|||||||
get("/statuses/:id/card", StatusController, :card)
|
get("/statuses/:id/card", StatusController, :card)
|
||||||
get("/statuses/:id/favourited_by", StatusController, :favourited_by)
|
get("/statuses/:id/favourited_by", StatusController, :favourited_by)
|
||||||
get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
|
get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
|
||||||
|
get("/statuses/:id/history", StatusController, :show_history)
|
||||||
|
get("/statuses/:id/source", StatusController, :show_source)
|
||||||
|
|
||||||
get("/custom_emojis", CustomEmojiController, :index)
|
get("/custom_emojis", CustomEmojiController, :index)
|
||||||
|
|
||||||
|
@ -1993,7 +1993,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||||||
|
|
||||||
describe "get status history" do
|
describe "get status history" do
|
||||||
setup do
|
setup do
|
||||||
oauth_access(["read:statuses"])
|
%{conn: build_conn()}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "unedited post", %{conn: conn} do
|
test "unedited post", %{conn: conn} do
|
||||||
@ -2039,7 +2039,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||||||
|
|
||||||
describe "get status source" do
|
describe "get status source" do
|
||||||
setup do
|
setup do
|
||||||
oauth_access(["read:statuses"])
|
%{conn: build_conn()}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns the source", %{conn: conn} do
|
test "it returns the source", %{conn: conn} do
|
||||||
|
Loading…
Reference in New Issue
Block a user