2020-04-08 18:33:25 +00:00
# Pleroma: A lightweight social networking server
2023-01-02 20:38:50 +00:00
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
2020-04-08 18:33:25 +00:00
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ApiSpec.Schemas.Status do
alias OpenApiSpex.Schema
alias Pleroma.Web.ApiSpec.Schemas.Account
2020-05-05 19:19:16 +00:00
alias Pleroma.Web.ApiSpec.Schemas.Attachment
2020-04-27 18:55:05 +00:00
alias Pleroma.Web.ApiSpec.Schemas.Emoji
2020-04-21 19:54:45 +00:00
alias Pleroma.Web.ApiSpec.Schemas.FlakeID
2020-04-08 18:33:25 +00:00
alias Pleroma.Web.ApiSpec.Schemas.Poll
2020-05-06 15:20:26 +00:00
alias Pleroma.Web.ApiSpec.Schemas.Tag
2020-04-08 18:33:25 +00:00
alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope
require OpenApiSpex
OpenApiSpex . schema ( %{
title : " Status " ,
description : " Response schema for a status " ,
type : :object ,
properties : %{
2020-05-12 19:59:26 +00:00
account : % Schema { allOf : [ Account ] , description : " The account that authored this status " } ,
2020-04-08 18:33:25 +00:00
application : % Schema {
2020-05-12 19:59:26 +00:00
description : " The application used to post this status " ,
2020-04-08 18:33:25 +00:00
type : :object ,
2021-02-18 22:35:03 +00:00
nullable : true ,
2020-04-08 18:33:25 +00:00
properties : %{
name : % Schema { type : :string } ,
2021-02-18 22:35:03 +00:00
website : % Schema { type : :string , format : :uri }
2020-04-08 18:33:25 +00:00
}
} ,
2020-05-12 19:59:26 +00:00
bookmarked : % Schema { type : :boolean , description : " Have you bookmarked this status? " } ,
2020-04-08 18:33:25 +00:00
card : % Schema {
type : :object ,
nullable : true ,
2020-05-12 19:59:26 +00:00
description : " Preview card for links included within status content " ,
required : [ :url , :title , :description , :type ] ,
2020-04-08 18:33:25 +00:00
properties : %{
2020-05-12 19:59:26 +00:00
type : % Schema {
type : :string ,
enum : [ " link " , " photo " , " video " , " rich " ] ,
description : " The type of the preview card "
} ,
provider_name : % Schema {
type : :string ,
nullable : true ,
description : " The provider of the original resource "
} ,
provider_url : % Schema {
type : :string ,
format : :uri ,
description : " A link to the provider of the original resource "
} ,
url : % Schema { type : :string , format : :uri , description : " Location of linked resource " } ,
image : % Schema {
type : :string ,
nullable : true ,
format : :uri ,
description : " Preview thumbnail "
} ,
title : % Schema { type : :string , description : " Title of linked resource " } ,
description : % Schema { type : :string , description : " Description of preview " }
2020-04-08 18:33:25 +00:00
}
} ,
2020-05-12 19:59:26 +00:00
content : % Schema { type : :string , format : :html , description : " HTML-encoded status content " } ,
2020-06-26 05:16:24 +00:00
text : % Schema {
type : :string ,
description : " Original unformatted content in plain text " ,
nullable : true
} ,
2020-05-12 19:59:26 +00:00
created_at : % Schema {
type : :string ,
format : " date-time " ,
description : " The date when this status was created "
} ,
2022-06-04 01:47:40 +00:00
edited_at : % Schema {
type : :string ,
format : " date-time " ,
nullable : true ,
description : " The date when this status was last edited "
} ,
2020-05-12 19:59:26 +00:00
emojis : % Schema {
type : :array ,
items : Emoji ,
description : " Custom emoji to be used when rendering status content "
} ,
favourited : % Schema { type : :boolean , description : " Have you favourited this status? " } ,
favourites_count : % Schema {
type : :integer ,
description : " How many favourites this status has received "
} ,
2020-04-21 19:54:45 +00:00
id : FlakeID ,
2020-05-12 19:59:26 +00:00
in_reply_to_account_id : % Schema {
allOf : [ FlakeID ] ,
nullable : true ,
description : " ID of the account being replied to "
} ,
in_reply_to_id : % Schema {
allOf : [ FlakeID ] ,
nullable : true ,
description : " ID of the status being replied "
} ,
language : % Schema {
type : :string ,
nullable : true ,
description : " Primary language of this status "
} ,
2020-04-08 18:33:25 +00:00
media_attachments : % Schema {
type : :array ,
2020-05-12 19:59:26 +00:00
items : Attachment ,
description : " Media that is attached to this status "
2020-04-08 18:33:25 +00:00
} ,
mentions : % Schema {
type : :array ,
2020-05-12 19:59:26 +00:00
description : " Mentions of users within the status content " ,
2020-04-08 18:33:25 +00:00
items : % Schema {
type : :object ,
properties : %{
2020-05-12 19:59:26 +00:00
id : % Schema { allOf : [ FlakeID ] , description : " The account id of the mentioned user " } ,
acct : % Schema {
type : :string ,
description :
" The webfinger acct: URI of the mentioned user. Equivalent to `username` for local users, or `username@domain` for remote users. "
} ,
username : % Schema { type : :string , description : " The username of the mentioned user " } ,
url : % Schema {
type : :string ,
format : :uri ,
description : " The location of the mentioned user's profile "
}
2020-04-08 18:33:25 +00:00
}
}
} ,
2020-05-12 19:59:26 +00:00
muted : % Schema {
type : :boolean ,
description : " Have you muted notifications for this status's conversation? "
} ,
pinned : % Schema {
type : :boolean ,
description : " Have you pinned this status? Only appears if the status is pinnable. "
} ,
2020-04-08 18:33:25 +00:00
pleroma : % Schema {
type : :object ,
properties : %{
2020-05-12 19:59:26 +00:00
content : % Schema {
type : :object ,
2023-01-15 22:28:32 +00:00
additionalProperties : % Schema {
type : :string ,
description : " Alternate representation in the MIME type specified " ,
extensions : %{ " x-additionalPropertiesName " : " MIME type " }
} ,
2020-05-12 19:59:26 +00:00
description :
" A map consisting of alternate representations of the `content` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain` "
} ,
2022-08-07 18:39:35 +00:00
context : % Schema {
type : :string ,
description : " The thread identifier the status is associated with "
} ,
2020-05-12 19:59:26 +00:00
conversation_id : % Schema {
type : :integer ,
2022-08-07 18:39:35 +00:00
deprecated : true ,
description :
" The ID of the AP context the status is associated with (if any); deprecated, please use `context` instead "
2020-05-12 19:59:26 +00:00
} ,
2020-05-05 13:44:46 +00:00
direct_conversation_id : % Schema {
type : :integer ,
nullable : true ,
description :
" The ID of the Mastodon direct message conversation the status is associated with (if any) "
} ,
2020-04-08 18:33:25 +00:00
emoji_reactions : % Schema {
type : :array ,
2020-05-12 19:59:26 +00:00
description :
" A list with emoji / reaction maps. Contains no information about the reacting users, for that use the /statuses/:id/reactions endpoint. " ,
2020-04-08 18:33:25 +00:00
items : % Schema {
type : :object ,
properties : %{
name : % Schema { type : :string } ,
count : % Schema { type : :integer } ,
me : % Schema { type : :boolean }
}
}
} ,
2020-05-12 19:59:26 +00:00
expires_at : % Schema {
type : :string ,
format : " date-time " ,
nullable : true ,
description :
" A datetime (ISO 8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire "
} ,
in_reply_to_account_acct : % Schema {
type : :string ,
nullable : true ,
description : " The `acct` property of User entity for replied user (if any) "
} ,
2022-01-23 02:05:58 +00:00
quote : % Schema {
allOf : [ % OpenApiSpex.Reference { " $ref " : " # /components/schemas/Status " } ] ,
nullable : true ,
description : " Quoted status (if any) "
} ,
2022-01-23 19:55:25 +00:00
quote_url : % Schema {
type : :string ,
format : :uri ,
nullable : true ,
description : " URL of the quoted status "
} ,
2022-01-26 17:52:50 +00:00
quote_visible : % Schema {
type : :boolean ,
description : " `true` if the quoted post is visible to the user "
} ,
2020-05-12 19:59:26 +00:00
local : % Schema {
type : :boolean ,
description : " `true` if the post was made on the local instance "
} ,
spoiler_text : % Schema {
type : :object ,
2023-01-15 22:28:32 +00:00
additionalProperties : % Schema {
type : :string ,
description : " Alternate representation in the MIME type specified " ,
extensions : %{ " x-additionalPropertiesName " : " MIME type " }
} ,
2020-05-12 19:59:26 +00:00
description :
" A map consisting of alternate representations of the `spoiler_text` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`. "
} ,
thread_muted : % Schema {
type : :boolean ,
description : " `true` if the thread the post belongs to is muted "
2020-06-24 12:33:00 +00:00
} ,
parent_visible : % Schema {
type : :boolean ,
description : " `true` if the parent post is visible to the user "
2021-02-03 13:09:28 +00:00
} ,
pinned_at : % Schema {
type : :string ,
format : " date-time " ,
nullable : true ,
description :
" A datetime (ISO 8601) that states when the post was pinned or `null` if the post is not pinned "
2020-05-12 19:59:26 +00:00
}
2020-04-08 18:33:25 +00:00
}
} ,
2020-05-12 19:59:26 +00:00
poll : % Schema { allOf : [ Poll ] , nullable : true , description : " The poll attached to the status " } ,
2020-04-08 18:33:25 +00:00
reblog : % Schema {
allOf : [ % OpenApiSpex.Reference { " $ref " : " # /components/schemas/Status " } ] ,
2020-05-12 19:59:26 +00:00
nullable : true ,
description : " The status being reblogged "
} ,
reblogged : % Schema { type : :boolean , description : " Have you boosted this status? " } ,
reblogs_count : % Schema {
type : :integer ,
description : " How many boosts this status has received "
} ,
replies_count : % Schema {
type : :integer ,
description : " How many replies this status has received "
} ,
sensitive : % Schema {
type : :boolean ,
description : " Is this status marked as sensitive content? "
} ,
spoiler_text : % Schema {
type : :string ,
description :
" Subject or summary line, below which status content is collapsed until expanded "
2020-04-08 18:33:25 +00:00
} ,
2020-05-06 15:20:26 +00:00
tags : % Schema { type : :array , items : Tag } ,
2020-05-12 19:59:26 +00:00
uri : % Schema {
type : :string ,
format : :uri ,
description : " URI of the status used for federation "
} ,
url : % Schema {
type : :string ,
nullable : true ,
format : :uri ,
description : " A link to the status's HTML representation "
} ,
visibility : % Schema {
allOf : [ VisibilityScope ] ,
description : " Visibility of this status "
}
2020-04-08 18:33:25 +00:00
} ,
example : %{
2020-04-21 19:30:24 +00:00
" account " = > %{
" acct " = > " nick6 " ,
" avatar " = > " http://localhost:4001/images/avi.png " ,
" avatar_static " = > " http://localhost:4001/images/avi.png " ,
" bot " = > false ,
2020-04-08 18:33:25 +00:00
" created_at " = > " 2020-04-07T19:48:51.000Z " ,
2020-04-21 19:30:24 +00:00
" display_name " = > " Test テスト User 6 " ,
2020-04-08 18:33:25 +00:00
" emojis " = > [ ] ,
2020-04-21 19:30:24 +00:00
" fields " = > [ ] ,
" followers_count " = > 1 ,
" following_count " = > 0 ,
" header " = > " http://localhost:4001/images/banner.png " ,
" header_static " = > " http://localhost:4001/images/banner.png " ,
" id " = > " 9toJCsKN7SmSf3aj5c " ,
2020-10-13 14:31:13 +00:00
" is_locked " = > false ,
2020-04-21 19:30:24 +00:00
" note " = > " Tester Number 6 " ,
2020-04-08 18:33:25 +00:00
" pleroma " = > %{
2020-04-21 19:30:24 +00:00
" background_image " = > nil ,
2020-10-13 19:29:34 +00:00
" is_confirmed " = > true ,
2020-04-21 19:30:24 +00:00
" hide_favorites " = > true ,
" hide_followers " = > false ,
" hide_followers_count " = > false ,
" hide_follows " = > false ,
" hide_follows_count " = > false ,
" is_admin " = > false ,
" is_moderator " = > false ,
" relationship " = > %{
" blocked_by " = > false ,
" blocking " = > false ,
" domain_blocking " = > false ,
" endorsed " = > false ,
" followed_by " = > false ,
" following " = > true ,
" id " = > " 9toJCsKN7SmSf3aj5c " ,
" muting " = > false ,
" muting_notifications " = > false ,
2021-11-21 15:53:30 +00:00
" note " = > " " ,
2020-04-21 19:30:24 +00:00
" requested " = > false ,
" showing_reblogs " = > true ,
2021-12-06 20:23:34 +00:00
" subscribing " = > false ,
" notifying " = > false
2020-04-21 19:30:24 +00:00
} ,
" skip_thread_containment " = > false ,
" tags " = > [ ]
2020-04-08 18:33:25 +00:00
} ,
2020-04-21 19:30:24 +00:00
" source " = > %{
" fields " = > [ ] ,
" note " = > " Tester Number 6 " ,
" pleroma " = > %{ " actor_type " = > " Person " , " discoverable " = > false } ,
" sensitive " = > false
} ,
" statuses_count " = > 1 ,
" url " = > " http://localhost:4001/users/nick6 " ,
" username " = > " nick6 "
} ,
2021-02-18 22:35:03 +00:00
" application " = > nil ,
2020-04-21 19:30:24 +00:00
" bookmarked " = > false ,
" card " = > nil ,
" content " = > " foobar " ,
" created_at " = > " 2020-04-07T19:48:51.000Z " ,
" emojis " = > [ ] ,
" favourited " = > false ,
" favourites_count " = > 0 ,
" id " = > " 9toJCu5YZW7O7gfvH6 " ,
" in_reply_to_account_id " = > nil ,
" in_reply_to_id " = > nil ,
" language " = > nil ,
" media_attachments " = > [ ] ,
" mentions " = > [ ] ,
" muted " = > false ,
" pinned " = > false ,
" pleroma " = > %{
" content " = > %{ " text/plain " = > " foobar " } ,
2022-08-07 18:39:35 +00:00
" context " = > " http://localhost:4001/objects/8b4c0c80-6a37-4d2a-b1b9-05a19e3875aa " ,
2020-04-21 19:30:24 +00:00
" conversation_id " = > 345_972 ,
" direct_conversation_id " = > nil ,
" emoji_reactions " = > [ ] ,
" expires_at " = > nil ,
" in_reply_to_account_acct " = > nil ,
" local " = > true ,
" spoiler_text " = > %{ " text/plain " = > " " } ,
" thread_muted " = > false
} ,
" poll " = > nil ,
" reblog " = > nil ,
" reblogged " = > false ,
" reblogs_count " = > 0 ,
" replies_count " = > 0 ,
" sensitive " = > false ,
" spoiler_text " = > " " ,
" tags " = > [ ] ,
" uri " = > " http://localhost:4001/objects/0f5dad44-0e9e-4610-b377-a2631e499190 " ,
" url " = > " http://localhost:4001/notice/9toJCu5YZW7O7gfvH6 " ,
" visibility " = > " private "
2020-04-08 18:33:25 +00:00
}
} )
end