Show edited_at in MastodonAPI/show
This commit is contained in:
parent
920a5c7107
commit
d236c091ad
3 changed files with 33 additions and 0 deletions
|
@ -73,6 +73,12 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
|
|||
format: "date-time",
|
||||
description: "The date when this status was created"
|
||||
},
|
||||
edited_at: %Schema{
|
||||
type: :string,
|
||||
format: "date-time",
|
||||
nullable: true,
|
||||
description: "The date when this status was last edited"
|
||||
},
|
||||
emojis: %Schema{
|
||||
type: :array,
|
||||
items: Emoji,
|
||||
|
|
|
@ -257,6 +257,16 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
|
|||
|
||||
created_at = Utils.to_masto_date(object.data["published"])
|
||||
|
||||
edited_at =
|
||||
with %{"updated" => updated} <- object.data,
|
||||
date <- Utils.to_masto_date(updated),
|
||||
true <- date != "" do
|
||||
date
|
||||
else
|
||||
_ ->
|
||||
nil
|
||||
end
|
||||
|
||||
reply_to = get_reply_to(activity, opts)
|
||||
|
||||
reply_to_user = reply_to && CommonAPI.get_user(reply_to.data["actor"])
|
||||
|
@ -347,6 +357,7 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
|
|||
content: content_html,
|
||||
text: opts[:with_source] && object.data["source"],
|
||||
created_at: created_at,
|
||||
edited_at: edited_at,
|
||||
reblogs_count: announcement_count,
|
||||
replies_count: object.data["repliesCount"] || 0,
|
||||
favourites_count: like_count,
|
||||
|
|
|
@ -260,6 +260,7 @@ test "a note activity" do
|
|||
content: HTML.filter_tags(object_data["content"]),
|
||||
text: nil,
|
||||
created_at: created_at,
|
||||
edited_at: nil,
|
||||
reblogs_count: 0,
|
||||
replies_count: 0,
|
||||
favourites_count: 0,
|
||||
|
@ -751,4 +752,19 @@ test "has a field for parent visibility" do
|
|||
status = StatusView.render("show.json", activity: visible, for: poster)
|
||||
assert status.pleroma.parent_visible
|
||||
end
|
||||
|
||||
test "it shows edited_at" do
|
||||
poster = insert(:user)
|
||||
|
||||
{:ok, post} = CommonAPI.post(poster, %{status: "hey"})
|
||||
|
||||
status = StatusView.render("show.json", activity: post)
|
||||
refute status.edited_at
|
||||
|
||||
{:ok, _} = CommonAPI.update(poster, post, %{status: "mew mew"})
|
||||
edited = Pleroma.Activity.normalize(post)
|
||||
|
||||
status = StatusView.render("show.json", activity: edited)
|
||||
assert status.edited_at
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue