Chat: Add last_message to schema.
[akkoma] / lib / pleroma / web / api_spec / schemas / chat.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.Schemas.Chat do
6 alias OpenApiSpex.Schema
7 alias Pleroma.Web.ApiSpec.Schemas.ChatMessage
8
9 require OpenApiSpex
10
11 OpenApiSpex.schema(%{
12 title: "Chat",
13 description: "Response schema for a Chat",
14 type: :object,
15 properties: %{
16 id: %Schema{type: :string},
17 account: %Schema{type: :object},
18 unread: %Schema{type: :integer},
19 last_message: %Schema{type: ChatMessage, nullable: true}
20 },
21 example: %{
22 "account" => %{
23 "pleroma" => %{
24 "is_admin" => false,
25 "confirmation_pending" => false,
26 "hide_followers_count" => false,
27 "is_moderator" => false,
28 "hide_favorites" => true,
29 "ap_id" => "https://dontbulling.me/users/lain",
30 "hide_follows_count" => false,
31 "hide_follows" => false,
32 "background_image" => nil,
33 "skip_thread_containment" => false,
34 "hide_followers" => false,
35 "relationship" => %{},
36 "tags" => []
37 },
38 "avatar" =>
39 "https://dontbulling.me/media/065a4dd3c6740dab13ff9c71ec7d240bb9f8be9205c9e7467fb2202117da1e32.jpg",
40 "following_count" => 0,
41 "header_static" => "https://originalpatchou.li/images/banner.png",
42 "source" => %{
43 "sensitive" => false,
44 "note" => "lain",
45 "pleroma" => %{
46 "discoverable" => false,
47 "actor_type" => "Person"
48 },
49 "fields" => []
50 },
51 "statuses_count" => 1,
52 "locked" => false,
53 "created_at" => "2020-04-16T13:40:15.000Z",
54 "display_name" => "lain",
55 "fields" => [],
56 "acct" => "lain@dontbulling.me",
57 "id" => "9u6Qw6TAZANpqokMkK",
58 "emojis" => [],
59 "avatar_static" =>
60 "https://dontbulling.me/media/065a4dd3c6740dab13ff9c71ec7d240bb9f8be9205c9e7467fb2202117da1e32.jpg",
61 "username" => "lain",
62 "followers_count" => 0,
63 "header" => "https://originalpatchou.li/images/banner.png",
64 "bot" => false,
65 "note" => "lain",
66 "url" => "https://dontbulling.me/users/lain"
67 },
68 "id" => "1",
69 "unread" => 2,
70 "last_message" => ChatMessage.schema().example()
71 }
72 })
73 end