WIP: post editing #103
2 changed files with 6 additions and 7 deletions
|
@ -424,13 +424,12 @@ def render("history.json", %{activity: %{data: %{"object" => _object}} = activit
|
||||||
|> Enum.map(&Map.put(&1, "id", object.data["id"]))
|
|> Enum.map(&Map.put(&1, "id", object.data["id"]))
|
||||||
|> Enum.map(&%Object{data: &1, id: object.id})
|
|> Enum.map(&%Object{data: &1, id: object.id})
|
||||||
|
|
||||||
history = [object | past_history]
|
|
||||||
|
|
||||||
history_len = length(history)
|
|
||||||
|
|
||||||
history =
|
history =
|
||||||
Enum.zip(history_len..0, history)
|
[object | past_history]
|
||||||
|> Enum.map(fn {chrono_order, object} ->
|
# Mastodon expects the original to be at the first
|
||||||
|
|> Enum.reverse()
|
||||||
|
|> Enum.with_index()
|
||||||
|
|> Enum.map(fn {object, chrono_order} ->
|
||||||
%{
|
%{
|
||||||
# The history is prepended every time there is a new edit.
|
# The history is prepended every time there is a new edit.
|
||||||
# In chrono_order, the oldest item is always at 0, and so on.
|
# In chrono_order, the oldest item is always at 0, and so on.
|
||||||
|
|
|
@ -2084,7 +2084,7 @@ test "edited post", %{conn: conn} do
|
||||||
|
|
||||||
conn = get(conn, "/api/v1/statuses/#{activity.id}/history")
|
conn = get(conn, "/api/v1/statuses/#{activity.id}/history")
|
||||||
|
|
||||||
assert [_, %{"spoiler_text" => "title 2"}, %{"spoiler_text" => "title 1"}] =
|
assert [%{"spoiler_text" => "title 1"}, %{"spoiler_text" => "title 2"}, _] =
|
||||||
json_response_and_validate_schema(conn, 200)
|
json_response_and_validate_schema(conn, 200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue