First
[anni] / lib / pleroma / web / api_spec / schemas / chat_message.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.Schemas.ChatMessage do
6   alias OpenApiSpex.Schema
7   alias Pleroma.Web.ApiSpec.Schemas.Emoji
8
9   require OpenApiSpex
10
11   OpenApiSpex.schema(%{
12     title: "ChatMessage",
13     description: "Response schema for a ChatMessage",
14     nullable: true,
15     type: :object,
16     properties: %{
17       id: %Schema{type: :string},
18       account_id: %Schema{type: :string, description: "The Mastodon API id of the actor"},
19       chat_id: %Schema{type: :string},
20       content: %Schema{type: :string, nullable: true},
21       created_at: %Schema{type: :string, format: :"date-time"},
22       emojis: %Schema{type: :array, items: Emoji},
23       attachment: %Schema{type: :object, nullable: true},
24       card: %Schema{
25         type: :object,
26         nullable: true,
27         description: "Preview card for links included within status content",
28         required: [:url, :title, :description, :type],
29         properties: %{
30           type: %Schema{
31             type: :string,
32             enum: ["link", "photo", "video", "rich"],
33             description: "The type of the preview card"
34           },
35           provider_name: %Schema{
36             type: :string,
37             nullable: true,
38             description: "The provider of the original resource"
39           },
40           provider_url: %Schema{
41             type: :string,
42             format: :uri,
43             description: "A link to the provider of the original resource"
44           },
45           url: %Schema{type: :string, format: :uri, description: "Location of linked resource"},
46           image: %Schema{
47             type: :string,
48             nullable: true,
49             format: :uri,
50             description: "Preview thumbnail"
51           },
52           title: %Schema{type: :string, description: "Title of linked resource"},
53           description: %Schema{type: :string, description: "Description of preview"}
54         }
55       },
56       unread: %Schema{type: :boolean, description: "Whether a message has been marked as read."}
57     },
58     example: %{
59       "account_id" => "someflakeid",
60       "chat_id" => "1",
61       "content" => "hey you again",
62       "created_at" => "2020-04-21T15:06:45.000Z",
63       "card" => nil,
64       "emojis" => [
65         %{
66           "static_url" => "https://dontbulling.me/emoji/Firefox.gif",
67           "visible_in_picker" => false,
68           "shortcode" => "firefox",
69           "url" => "https://dontbulling.me/emoji/Firefox.gif"
70         }
71       ],
72       "id" => "14",
73       "attachment" => nil,
74       "unread" => false
75     }
76   })
77 end