diff options
author | lain <lain@soykaf.club> | 2020-05-06 16:12:36 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-06 16:12:36 +0200 |
commit | 20baa2eaf04425cf0a2eebc84760be6c12ee7f51 (patch) | |
tree | 5034177137693546741945fed7476c2fb77b8dbd /lib/pleroma/web/common_api | |
parent | 205313e54146c00374e3edfa951132a7229fa16d (diff) | |
download | pleroma-20baa2eaf04425cf0a2eebc84760be6c12ee7f51.tar.gz |
ChatMessages: Add attachments.
Diffstat (limited to 'lib/pleroma/web/common_api')
-rw-r--r-- | lib/pleroma/web/common_api/common_api.ex | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index e428cc17d..38b5c6f7c 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -25,14 +25,16 @@ defmodule Pleroma.Web.CommonAPI do require Pleroma.Constants require Logger - def post_chat_message(%User{} = user, %User{} = recipient, content) do + def post_chat_message(%User{} = user, %User{} = recipient, content, opts \\ []) do with :ok <- validate_chat_content_length(content), + maybe_attachment <- opts[:media_id] && Object.get_by_id(opts[:media_id]), {_, {:ok, chat_message_data, _meta}} <- {:build_object, Builder.chat_message( user, recipient.ap_id, - content |> Formatter.html_escape("text/plain") + content |> Formatter.html_escape("text/plain"), + attachment: maybe_attachment )}, {_, {:ok, create_activity_data, _meta}} <- {:build_create_activity, Builder.create(user, chat_message_data, [recipient.ap_id])}, |