aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-04-27 16:08:03 +0200
committerlain <lain@soykaf.club>2020-04-27 16:08:03 +0200
commit49e673dfea0a0cc94bba9691ce171b60f8a2fd75 (patch)
treeabefe9e73963b4bf9447f72f508452020700abee
parent00e956528b392689326d5f5527543a422a874bcc (diff)
downloadpleroma-49e673dfea0a0cc94bba9691ce171b60f8a2fd75.tar.gz
ChatView: Add actor_account_id
-rw-r--r--lib/pleroma/web/api_spec/schemas/chat_message_response.ex2
-rw-r--r--lib/pleroma/web/pleroma_api/views/chat_message_view.ex2
-rw-r--r--test/web/pleroma_api/views/chat_message_view_test.exs2
3 files changed, 6 insertions, 0 deletions
diff --git a/lib/pleroma/web/api_spec/schemas/chat_message_response.ex b/lib/pleroma/web/api_spec/schemas/chat_message_response.ex
index e94c00369..9459d210b 100644
--- a/lib/pleroma/web/api_spec/schemas/chat_message_response.ex
+++ b/lib/pleroma/web/api_spec/schemas/chat_message_response.ex
@@ -14,6 +14,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.ChatMessageResponse do
properties: %{
id: %Schema{type: :string},
actor: %Schema{type: :string, description: "The ActivityPub id of the actor"},
+ actor_account_id: %Schema{type: :string, description: "The Mastodon API id of the actor"},
chat_id: %Schema{type: :string},
content: %Schema{type: :string},
created_at: %Schema{type: :string, format: :datetime},
@@ -21,6 +22,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.ChatMessageResponse do
},
example: %{
"actor" => "https://dontbulling.me/users/lain",
+ "actor_account_id" => "someflakeid",
"chat_id" => "1",
"content" => "hey you again",
"created_at" => "2020-04-21T15:06:45.000Z",
diff --git a/lib/pleroma/web/pleroma_api/views/chat_message_view.ex b/lib/pleroma/web/pleroma_api/views/chat_message_view.ex
index b40ab92a0..5b740cc44 100644
--- a/lib/pleroma/web/pleroma_api/views/chat_message_view.ex
+++ b/lib/pleroma/web/pleroma_api/views/chat_message_view.ex
@@ -8,6 +8,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageView do
alias Pleroma.Chat
alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.MastodonAPI.StatusView
+ alias Pleroma.User
def render(
"show.json",
@@ -21,6 +22,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageView do
content: chat_message["content"],
chat_id: chat_id |> to_string(),
actor: chat_message["actor"],
+ actor_account_id: User.get_cached_by_ap_id(chat_message["actor"]).id,
created_at: Utils.to_masto_date(chat_message["published"]),
emojis: StatusView.build_emojis(chat_message["emoji"])
}
diff --git a/test/web/pleroma_api/views/chat_message_view_test.exs b/test/web/pleroma_api/views/chat_message_view_test.exs
index 115335f10..7e3aeefab 100644
--- a/test/web/pleroma_api/views/chat_message_view_test.exs
+++ b/test/web/pleroma_api/views/chat_message_view_test.exs
@@ -26,6 +26,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageViewTest do
assert chat_message[:id] == object.id |> to_string()
assert chat_message[:content] == "kippis :firefox:"
assert chat_message[:actor] == user.ap_id
+ assert chat_message[:actor_account_id] == user.id
assert chat_message[:chat_id]
assert chat_message[:created_at]
assert match?([%{shortcode: "firefox"}], chat_message[:emojis])
@@ -39,6 +40,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageViewTest do
assert chat_message_two[:id] == object.id |> to_string()
assert chat_message_two[:content] == "gkgkgk"
assert chat_message_two[:actor] == recipient.ap_id
+ assert chat_message_two[:actor_account_id] == recipient.id
assert chat_message_two[:chat_id] == chat_message[:chat_id]
end
end