status.go (9536B)
1 // GoToSocial 2 // Copyright (C) GoToSocial Authors admin@gotosocial.org 3 // SPDX-License-Identifier: AGPL-3.0-or-later 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Affero General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Affero General Public License for more details. 14 // 15 // You should have received a copy of the GNU Affero General Public License 16 // along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 package model 19 20 // Status models a status or post. 21 // 22 // swagger:model status 23 type Status struct { 24 // ID of the status. 25 // example: 01FBVD42CQ3ZEEVMW180SBX03B 26 ID string `json:"id"` 27 // The date when this status was created (ISO 8601 Datetime). 28 // example: 2021-07-30T09:20:25+00:00 29 CreatedAt string `json:"created_at"` 30 // ID of the status being replied to. 31 // example: 01FBVD42CQ3ZEEVMW180SBX03B 32 // nullable: true 33 InReplyToID *string `json:"in_reply_to_id"` 34 // ID of the account being replied to. 35 // example: 01FBVD42CQ3ZEEVMW180SBX03B 36 // nullable: true 37 InReplyToAccountID *string `json:"in_reply_to_account_id"` 38 // Status contains sensitive content. 39 // example: false 40 Sensitive bool `json:"sensitive"` 41 // Subject, summary, or content warning for the status. 42 // example: warning nsfw 43 SpoilerText string `json:"spoiler_text"` 44 // Visibility of this status. 45 // example: unlisted 46 Visibility Visibility `json:"visibility"` 47 // Primary language of this status (ISO 639 Part 1 two-letter language code). 48 // Will be null if language is not known. 49 // example: en 50 Language *string `json:"language"` 51 // ActivityPub URI of the status. Equivalent to the status's activitypub ID. 52 // example: https://example.org/users/some_user/statuses/01FBVD42CQ3ZEEVMW180SBX03B 53 URI string `json:"uri"` 54 // The status's publicly available web URL. This link will only work if the visibility of the status is 'public'. 55 // example: https://example.org/@some_user/statuses/01FBVD42CQ3ZEEVMW180SBX03B 56 URL string `json:"url"` 57 // Number of replies to this status, according to our instance. 58 RepliesCount int `json:"replies_count"` 59 // Number of times this status has been boosted/reblogged, according to our instance. 60 ReblogsCount int `json:"reblogs_count"` 61 // Number of favourites/likes this status has received, according to our instance. 62 FavouritesCount int `json:"favourites_count"` 63 // This status has been favourited by the account viewing it. 64 Favourited bool `json:"favourited"` 65 // This status has been boosted/reblogged by the account viewing it. 66 Reblogged bool `json:"reblogged"` 67 // Replies to this status have been muted by the account viewing it. 68 Muted bool `json:"muted"` 69 // This status has been bookmarked by the account viewing it. 70 Bookmarked bool `json:"bookmarked"` 71 // This status has been pinned by the account viewing it (only relevant for your own statuses). 72 Pinned bool `json:"pinned"` 73 // The content of this status. Should be HTML, but might also be plaintext in some cases. 74 // example: <p>Hey this is a status!</p> 75 Content string `json:"content"` 76 // The status that this status reblogs/boosts. 77 // nullable: true 78 Reblog *StatusReblogged `json:"reblog"` 79 // The application used to post this status, if visible. 80 Application *Application `json:"application,omitempty"` 81 // The account that authored this status. 82 Account *Account `json:"account"` 83 // Media that is attached to this status. 84 MediaAttachments []Attachment `json:"media_attachments"` 85 // Mentions of users within the status content. 86 Mentions []Mention `json:"mentions"` 87 // Hashtags used within the status content. 88 Tags []Tag `json:"tags"` 89 // Custom emoji to be used when rendering status content. 90 Emojis []Emoji `json:"emojis"` 91 // Preview card for links included within status content. 92 // nullable: true 93 Card *Card `json:"card"` 94 // The poll attached to the status. 95 // nullable: true 96 Poll *Poll `json:"poll"` 97 // Plain-text source of a status. Returned instead of content when status is deleted, 98 // so the user may redraft from the source text without the client having to reverse-engineer 99 // the original text from the HTML content. 100 Text string `json:"text,omitempty"` 101 } 102 103 /* 104 ** The below functions are added onto the API model status so that it satisfies 105 ** the Preparable interface in internal/timeline. 106 */ 107 108 func (s *Status) GetID() string { 109 return s.ID 110 } 111 112 func (s *Status) GetAccountID() string { 113 if s.Account != nil { 114 return s.Account.ID 115 } 116 return "" 117 } 118 119 func (s *Status) GetBoostOfID() string { 120 if s.Reblog != nil { 121 return s.Reblog.ID 122 } 123 return "" 124 } 125 126 func (s *Status) GetBoostOfAccountID() string { 127 if s.Reblog != nil && s.Reblog.Account != nil { 128 return s.Reblog.Account.ID 129 } 130 return "" 131 } 132 133 // StatusReblogged represents a reblogged status. 134 // 135 // swagger:model statusReblogged 136 type StatusReblogged struct { 137 *Status 138 } 139 140 // StatusCreateRequest models status creation parameters. 141 // 142 // swagger:model statusCreateRequest 143 type StatusCreateRequest struct { 144 // Text content of the status. 145 // If media_ids is provided, this becomes optional. 146 // Attaching a poll is optional while status is provided. 147 // in: formData 148 Status string `form:"status" json:"status" xml:"status"` 149 // Array of Attachment ids to be attached as media. 150 // If provided, status becomes optional, and poll cannot be used. 151 // 152 // If the status is being submitted as a form, the key is 'media_ids[]', 153 // but if it's json or xml, the key is 'media_ids'. 154 // 155 // in: formData 156 MediaIDs []string `form:"media_ids[]" json:"media_ids" xml:"media_ids"` 157 // Poll to include with this status. 158 // swagger:ignore 159 Poll *PollRequest `form:"poll" json:"poll" xml:"poll"` 160 // ID of the status being replied to, if status is a reply. 161 // in: formData 162 InReplyToID string `form:"in_reply_to_id" json:"in_reply_to_id" xml:"in_reply_to_id"` 163 // Status and attached media should be marked as sensitive. 164 // in: formData 165 Sensitive bool `form:"sensitive" json:"sensitive" xml:"sensitive"` 166 // Text to be shown as a warning or subject before the actual content. 167 // Statuses are generally collapsed behind this field. 168 // in: formData 169 SpoilerText string `form:"spoiler_text" json:"spoiler_text" xml:"spoiler_text"` 170 // Visibility of the posted status. 171 // in: formData 172 Visibility Visibility `form:"visibility" json:"visibility" xml:"visibility"` 173 // ISO 8601 Datetime at which to schedule a status. 174 // Providing this parameter will cause ScheduledStatus to be returned instead of Status. 175 // Must be at least 5 minutes in the future. 176 // in: formData 177 ScheduledAt string `form:"scheduled_at" json:"scheduled_at" xml:"scheduled_at"` 178 // ISO 639 language code for this status. 179 // in: formData 180 Language string `form:"language" json:"language" xml:"language"` 181 // Content type to use when parsing this status. 182 // in: formData 183 ContentType StatusContentType `form:"content_type" json:"content_type" xml:"content_type"` 184 } 185 186 // Visibility models the visibility of a status. 187 // 188 // swagger:enum statusVisibility 189 // swagger:type string 190 type Visibility string 191 192 const ( 193 // VisibilityPublic is visible to everyone, and will be available via the web even for nonauthenticated users. 194 VisibilityPublic Visibility = "public" 195 // VisibilityUnlisted is visible to everyone, but only on home timelines, lists, etc. 196 VisibilityUnlisted Visibility = "unlisted" 197 // VisibilityPrivate is visible only to followers of the account that posted the status. 198 VisibilityPrivate Visibility = "private" 199 // VisibilityMutualsOnly is visible only to mutual followers of the account that posted the status. 200 VisibilityMutualsOnly Visibility = "mutuals_only" 201 // VisibilityDirect is visible only to accounts tagged in the status. It is equivalent to a direct message. 202 VisibilityDirect Visibility = "direct" 203 ) 204 205 // AdvancedStatusCreateForm wraps the mastodon-compatible status create form along with the GTS advanced 206 // visibility settings. 207 // 208 // swagger:parameters statusCreate 209 type AdvancedStatusCreateForm struct { 210 StatusCreateRequest 211 AdvancedVisibilityFlagsForm 212 } 213 214 // AdvancedVisibilityFlagsForm allows a few more advanced flags to be set on new statuses, in addition 215 // to the standard mastodon-compatible ones. 216 // 217 // swagger:model advancedVisibilityFlagsForm 218 type AdvancedVisibilityFlagsForm struct { 219 // This status will be federated beyond the local timeline(s). 220 Federated *bool `form:"federated" json:"federated" xml:"federated"` 221 // This status can be boosted/reblogged. 222 Boostable *bool `form:"boostable" json:"boostable" xml:"boostable"` 223 // This status can be replied to. 224 Replyable *bool `form:"replyable" json:"replyable" xml:"replyable"` 225 // This status can be liked/faved. 226 Likeable *bool `form:"likeable" json:"likeable" xml:"likeable"` 227 } 228 229 // StatusContentType is the content type with which to parse the submitted status. 230 // Can be either text/plain or text/markdown. Empty will default to text/plain. 231 // 232 // swagger:enum statusContentType 233 // swagger:type string 234 type StatusContentType string 235 236 // Content type to use when parsing submitted status into an html-formatted status 237 const ( 238 StatusContentTypePlain StatusContentType = "text/plain" 239 StatusContentTypeMarkdown StatusContentType = "text/markdown" 240 StatusContentTypeDefault = StatusContentTypePlain 241 )