Implement GET /api/v1/announcements/:id
This commit is contained in:
parent
5169ad8f14
commit
aa1fff279e
2 changed files with 67 additions and 2 deletions
|
|
@ -55,7 +55,20 @@ defmodule Pleroma.Web.MastodonAPI.AnnouncementController do
|
|||
end
|
||||
|
||||
@doc "POST /api/v1/announcements/:id"
|
||||
def show(_conn, _params) do
|
||||
{:error, :not_found}
|
||||
def show(%{assigns: %{user: user}} = conn, %{id: id} = _params) do
|
||||
render_announcement_by_id(conn, id, user)
|
||||
end
|
||||
|
||||
def show(conn, %{id: id} = _params) do
|
||||
render_announcement_by_id(conn, id)
|
||||
end
|
||||
|
||||
def render_announcement_by_id(conn, id, user \\ nil) do
|
||||
with announcement when not is_nil(announcement) <- Announcement.get_by_id(id) do
|
||||
render(conn, "show.json", announcement: announcement, user: user)
|
||||
else
|
||||
_ ->
|
||||
{:error, :not_found}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue