diff options
author | lain <lain@soykaf.club> | 2020-04-17 14:23:59 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-04-17 15:37:54 +0200 |
commit | 372614cfd3119b589c9c47619445714e8ae6c07e (patch) | |
tree | 5235e88411e86659dd51ed0beb6cfbae0f913ecf /lib | |
parent | d45ae6485811189e98f774ecdb46f0ccdfa8b2b3 (diff) | |
download | pleroma-372614cfd3119b589c9c47619445714e8ae6c07e.tar.gz pleroma-372614cfd3119b589c9c47619445714e8ae6c07e.zip |
ChatView: Add a mastodon api representation of the recipient.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/transmogrifier/chat_message_handling.ex | 1 | ||||
-rw-r--r-- | lib/pleroma/web/pleroma_api/views/chat_view.ex | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/pleroma/web/activity_pub/transmogrifier/chat_message_handling.ex b/lib/pleroma/web/activity_pub/transmogrifier/chat_message_handling.ex index 11bd10456..cfe3b767b 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier/chat_message_handling.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier/chat_message_handling.ex @@ -22,6 +22,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageHandling do # For now, just strip HTML stripped_content = Pleroma.HTML.strip_tags(object_cast_data["content"]), object_cast_data = object_cast_data |> Map.put("content", stripped_content), + {_, true} <- {:to_fields_match, cast_data["to"] == object_cast_data["to"]}, {_, {:ok, validated_object, _meta}} <- {:validate_object, ObjectValidator.validate(object_cast_data, %{})}, {_, {:ok, _created_object}} <- {:persist_object, Object.create(validated_object)}, diff --git a/lib/pleroma/web/pleroma_api/views/chat_view.ex b/lib/pleroma/web/pleroma_api/views/chat_view.ex index 7b8c6450a..1e9ef4356 100644 --- a/lib/pleroma/web/pleroma_api/views/chat_view.ex +++ b/lib/pleroma/web/pleroma_api/views/chat_view.ex @@ -6,11 +6,16 @@ defmodule Pleroma.Web.PleromaAPI.ChatView do use Pleroma.Web, :view alias Pleroma.Chat + alias Pleroma.User + alias Pleroma.Web.MastodonAPI.AccountView + + def render("show.json", %{chat: %Chat{} = chat} = opts) do + recipient = User.get_cached_by_ap_id(chat.recipient) - def render("show.json", %{chat: %Chat{} = chat}) do %{ id: chat.id |> to_string(), recipient: chat.recipient, + recipient_account: AccountView.render("show.json", Map.put(opts, :user, recipient)), unread: chat.unread } end |