mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
Catch 404s.
This commit is contained in:
parent
df2f59be91
commit
828259fb65
1 changed files with 34 additions and 21 deletions
|
@ -61,35 +61,48 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
|
||||||
end
|
end
|
||||||
|
|
||||||
def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do
|
def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do
|
||||||
activity = Activity.get_by_id_with_object(notice_id)
|
case Activity.get_by_id_with_object(notice_id) do
|
||||||
timeline =
|
%Activity{} = activity ->
|
||||||
activity.object.data["context"]
|
timeline =
|
||||||
|> ActivityPub.fetch_activities_for_context(%{})
|
activity.object.data["context"]
|
||||||
|> Enum.reverse()
|
|> ActivityPub.fetch_activities_for_context(%{})
|
||||||
|> Enum.map(&represent(&1, &1.object.id == activity.object.id))
|
|> Enum.reverse()
|
||||||
|
|> Enum.map(&represent(&1, &1.object.id == activity.object.id))
|
||||||
|
|
||||||
render(conn, "conversation.html", %{activities: timeline})
|
render(conn, "conversation.html", %{activities: timeline})
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
conn
|
||||||
|
|> put_status(404)
|
||||||
|
|> render_error(:not_found, "Notice not found")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do
|
def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do
|
||||||
%User{} = user = User.get_cached_by_nickname_or_id(username_or_id)
|
case User.get_cached_by_nickname_or_id(username_or_id) do
|
||||||
|
%User{} = user ->
|
||||||
|
timeline =
|
||||||
|
ActivityPub.fetch_user_activities(user, nil, Map.take(params, @page_keys))
|
||||||
|
|> Enum.map(&represent/1)
|
||||||
|
|
||||||
timeline =
|
prev_page_id =
|
||||||
ActivityPub.fetch_user_activities(user, nil, Map.take(params, @page_keys))
|
(params["min_id"] || params["max_id"]) &&
|
||||||
|> Enum.map(&represent/1)
|
List.first(timeline) && List.first(timeline).id
|
||||||
|
|
||||||
prev_page_id =
|
next_page_id = List.last(timeline) && List.last(timeline).id
|
||||||
(params["min_id"] || params["max_id"]) &&
|
|
||||||
List.first(timeline) && List.first(timeline).id
|
|
||||||
|
|
||||||
next_page_id = List.last(timeline) && List.last(timeline).id
|
render(conn, "profile.html", %{
|
||||||
|
user: user,
|
||||||
|
timeline: timeline,
|
||||||
|
prev_page_id: prev_page_id,
|
||||||
|
next_page_id: next_page_id
|
||||||
|
})
|
||||||
|
|
||||||
render(conn, "profile.html", %{
|
_ ->
|
||||||
user: user,
|
conn
|
||||||
timeline: timeline,
|
|> put_status(404)
|
||||||
prev_page_id: prev_page_id,
|
|> render_error(:not_found, "User not found")
|
||||||
next_page_id: next_page_id
|
end
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts),
|
def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts),
|
||||||
|
|
Loading…
Reference in a new issue