From 0ec7e9b8e98f6310f19d0b0a6ad82fc9c70a9d47 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 1 Jan 2021 11:58:42 -0600 Subject: [PATCH] AdminAPI: return id for moderation log entries --- docs/API/admin_api.md | 1 + lib/pleroma/web/admin_api/views/moderation_log_view.ex | 1 + .../pleroma/web/admin_api/views/moderation_log_view_test.exs | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md index 266f8cef8..5253dc668 100644 --- a/docs/API/admin_api.md +++ b/docs/API/admin_api.md @@ -1123,6 +1123,7 @@ Loads json generated from `config/descriptions.exs`. ```json [ { + "id": 1234, "data": { "actor": { "id": 1, diff --git a/lib/pleroma/web/admin_api/views/moderation_log_view.ex b/lib/pleroma/web/admin_api/views/moderation_log_view.ex index 112f9e0e1..3fa778b0a 100644 --- a/lib/pleroma/web/admin_api/views/moderation_log_view.ex +++ b/lib/pleroma/web/admin_api/views/moderation_log_view.ex @@ -21,6 +21,7 @@ def render("show.json", %{log_entry: log_entry}) do |> DateTime.to_unix() %{ + id: log_entry.id, data: log_entry.data, time: time, message: ModerationLog.get_log_entry_message(log_entry) diff --git a/test/pleroma/web/admin_api/views/moderation_log_view_test.exs b/test/pleroma/web/admin_api/views/moderation_log_view_test.exs index 390d7bbeb..a4748990e 100644 --- a/test/pleroma/web/admin_api/views/moderation_log_view_test.exs +++ b/test/pleroma/web/admin_api/views/moderation_log_view_test.exs @@ -9,6 +9,7 @@ defmodule Pleroma.Web.AdminAPI.ModerationLogViewTest do describe "renders `report_note_delete` log messages" do setup do log1 = %Pleroma.ModerationLog{ + id: 1, data: %{ "action" => "report_note_delete", "actor" => %{"id" => "A1I7G8", "nickname" => "admin", "type" => "user"}, @@ -21,6 +22,7 @@ defmodule Pleroma.Web.AdminAPI.ModerationLogViewTest do } log2 = %Pleroma.ModerationLog{ + id: 2, data: %{ "action" => "report_note_delete", "actor" => %{"id" => "A1I7G8", "nickname" => "admin", "type" => "user"}, @@ -42,6 +44,7 @@ test "renders `report_note_delete` log messages", %{log1: log1, log2: log2} do ) == %{ items: [ %{ + id: 1, data: %{ "action" => "report_note_delete", "actor" => %{"id" => "A1I7G8", "nickname" => "admin", "type" => "user"}, @@ -59,6 +62,7 @@ test "renders `report_note_delete` log messages", %{log1: log1, log2: log2} do time: 1_605_622_400 }, %{ + id: 2, data: %{ "action" => "report_note_delete", "actor" => %{"id" => "A1I7G8", "nickname" => "admin", "type" => "user"}, @@ -82,6 +86,7 @@ test "renders `report_note_delete` log messages", %{log1: log1, log2: log2} do test "renders `report_note_delete` log message", %{log1: log} do assert ModerationLogView.render("show.json", %{log_entry: log}) == %{ + id: 1, data: %{ "action" => "report_note_delete", "actor" => %{"id" => "A1I7G8", "nickname" => "admin", "type" => "user"},