account.go (9502B)
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 import ( 21 "mime/multipart" 22 "net" 23 ) 24 25 // Account models a fediverse account. 26 // 27 // The modelled account can be either a remote account, or one on this instance. 28 // 29 // swagger:model account 30 type Account struct { 31 // The account id. 32 // example: 01FBVD42CQ3ZEEVMW180SBX03B 33 ID string `json:"id"` 34 // The username of the account, not including domain. 35 // example: some_user 36 Username string `json:"username"` 37 // The account URI as discovered via webfinger. 38 // Equal to username for local users, or username@domain for remote users. 39 // example: some_user@example.org 40 Acct string `json:"acct"` 41 // The account's display name. 42 // example: big jeff (he/him) 43 DisplayName string `json:"display_name"` 44 // Account manually approves follow requests. 45 Locked bool `json:"locked"` 46 // Account has opted into discovery features. 47 Discoverable bool `json:"discoverable"` 48 // Account identifies as a bot. 49 Bot bool `json:"bot"` 50 // When the account was created (ISO 8601 Datetime). 51 // example: 2021-07-30T09:20:25+00:00 52 CreatedAt string `json:"created_at"` 53 // Bio/description of this account. 54 Note string `json:"note"` 55 // Web location of the account's profile page. 56 // example: https://example.org/@some_user 57 URL string `json:"url"` 58 // Web location of the account's avatar. 59 // example: https://example.org/media/some_user/avatar/original/avatar.jpeg 60 Avatar string `json:"avatar"` 61 // Web location of a static version of the account's avatar. 62 // Only relevant when the account's main avatar is a video or a gif. 63 // example: https://example.org/media/some_user/avatar/static/avatar.png 64 AvatarStatic string `json:"avatar_static"` 65 // Web location of the account's header image. 66 // example: https://example.org/media/some_user/header/original/header.jpeg 67 Header string `json:"header"` 68 // Web location of a static version of the account's header. 69 // Only relevant when the account's main header is a video or a gif. 70 // example: https://example.org/media/some_user/header/static/header.png 71 HeaderStatic string `json:"header_static"` 72 // Number of accounts following this account, according to our instance. 73 FollowersCount int `json:"followers_count"` 74 // Number of account's followed by this account, according to our instance. 75 FollowingCount int `json:"following_count"` 76 // Number of statuses posted by this account, according to our instance. 77 StatusesCount int `json:"statuses_count"` 78 // When the account's most recent status was posted (ISO 8601 Datetime). 79 // example: 2021-07-30T09:20:25+00:00 80 LastStatusAt *string `json:"last_status_at"` 81 // Array of custom emojis used in this account's note or display name. 82 Emojis []Emoji `json:"emojis"` 83 // Additional metadata attached to this account's profile. 84 Fields []Field `json:"fields"` 85 // Account has been suspended by our instance. 86 Suspended bool `json:"suspended,omitempty"` 87 // If this account has been muted, when will the mute expire (ISO 8601 Datetime). 88 // example: 2021-07-30T09:20:25+00:00 89 MuteExpiresAt string `json:"mute_expires_at,omitempty"` 90 // Extra profile information. Shown only if the requester owns the account being requested. 91 Source *Source `json:"source,omitempty"` 92 // CustomCSS to include when rendering this account's profile or statuses. 93 CustomCSS string `json:"custom_css,omitempty"` 94 // Account has enabled RSS feed. 95 EnableRSS bool `json:"enable_rss,omitempty"` 96 // Role of the account on this instance. 97 // Omitted for remote accounts. 98 Role *AccountRole `json:"role,omitempty"` 99 } 100 101 // AccountCreateRequest models account creation parameters. 102 // 103 // swagger:parameters accountCreate 104 type AccountCreateRequest struct { 105 // Text that will be reviewed by moderators if registrations require manual approval. 106 Reason string `form:"reason" json:"reason" xml:"reason"` 107 // The desired username for the account. 108 // swagger:parameters 109 // pattern: [a-z0-9_]{2,64} 110 // example: a_valid_username 111 // required: true 112 Username string `form:"username" json:"username" xml:"username" binding:"required"` 113 // The email address to be used for login. 114 // swagger:parameters 115 // example: someone@wherever.com 116 // required: true 117 Email string `form:"email" json:"email" xml:"email" binding:"required"` 118 // The password to be used for login. This will be hashed before storage. 119 // swagger:parameters 120 // example: some_really_really_really_strong_password 121 // required: true 122 Password string `form:"password" json:"password" xml:"password" binding:"required"` 123 // The user agrees to the terms, conditions, and policies of the instance. 124 // swagger:parameters 125 // required: true 126 Agreement bool `form:"agreement" json:"agreement" xml:"agreement" binding:"required"` 127 // The language of the confirmation email that will be sent. 128 // swagger:parameters 129 // example: en 130 // Required: true 131 Locale string `form:"locale" json:"locale" xml:"locale" binding:"required"` 132 // The IP of the sign up request, will not be parsed from the form. 133 // swagger:parameters 134 // swagger:ignore 135 IP net.IP `form:"-"` 136 } 137 138 // UpdateCredentialsRequest models an update to an account, by the account owner. 139 // 140 // swagger:ignore 141 type UpdateCredentialsRequest struct { 142 // Account should be made discoverable and shown in the profile directory (if enabled). 143 Discoverable *bool `form:"discoverable" json:"discoverable"` 144 // Account is flagged as a bot. 145 Bot *bool `form:"bot" json:"bot"` 146 // The display name to use for the account. 147 DisplayName *string `form:"display_name" json:"display_name"` 148 // Bio/description of this account. 149 Note *string `form:"note" json:"note"` 150 // Avatar image encoded using multipart/form-data. 151 Avatar *multipart.FileHeader `form:"avatar" json:"-"` 152 // Header image encoded using multipart/form-data 153 Header *multipart.FileHeader `form:"header" json:"-"` 154 // Require manual approval of follow requests. 155 Locked *bool `form:"locked" json:"locked"` 156 // New Source values for this account. 157 Source *UpdateSource `form:"source" json:"source"` 158 // Profile metadata names and values. 159 FieldsAttributes *[]UpdateField `form:"fields_attributes" json:"-"` 160 // Profile metadata names and values, parsed from JSON. 161 JSONFieldsAttributes *map[string]UpdateField `form:"-" json:"fields_attributes"` 162 // Custom CSS to be included when rendering this account's profile or statuses. 163 CustomCSS *string `form:"custom_css" json:"custom_css"` 164 // Enable RSS feed of public toots for this account at /@[username]/feed.rss 165 EnableRSS *bool `form:"enable_rss" json:"enable_rss"` 166 } 167 168 // UpdateSource is to be used specifically in an UpdateCredentialsRequest. 169 // 170 // swagger:model updateSource 171 type UpdateSource struct { 172 // Default post privacy for authored statuses. 173 Privacy *string `form:"privacy" json:"privacy"` 174 // Mark authored statuses as sensitive by default. 175 Sensitive *bool `form:"sensitive" json:"sensitive"` 176 // Default language to use for authored statuses. (ISO 6391) 177 Language *string `form:"language" json:"language"` 178 // Default format for authored statuses (text/plain or text/markdown). 179 StatusContentType *string `form:"status_content_type" json:"status_content_type"` 180 } 181 182 // UpdateField is to be used specifically in an UpdateCredentialsRequest. 183 // By default, max 6 fields and 255 characters per property/value. 184 // 185 // swagger:model updateField 186 type UpdateField struct { 187 // Key this form field was submitted with; 188 // only set if it was submitted as JSON. 189 Key int `form:"-" json:"-"` 190 // Name of the field 191 Name *string `form:"name" json:"name"` 192 // Value of the field 193 Value *string `form:"value" json:"value"` 194 } 195 196 // AccountFollowRequest models a request to follow an account. 197 // 198 // swagger:ignore 199 type AccountFollowRequest struct { 200 // The id of the account to follow. 201 ID string `form:"-" json:"-" xml:"-"` 202 // Show reblogs from this account. 203 Reblogs *bool `form:"reblogs" json:"reblogs" xml:"reblogs"` 204 // Notify when this account posts. 205 Notify *bool `form:"notify" json:"notify" xml:"notify"` 206 } 207 208 // AccountDeleteRequest models a request to delete an account. 209 // 210 // swagger:ignore 211 type AccountDeleteRequest struct { 212 // Password of the account's user, for confirmation. 213 Password string `form:"password" json:"password" xml:"password"` 214 } 215 216 // AccountRole models the role of an account. 217 // 218 // swagger:model accountRole 219 type AccountRole struct { 220 Name AccountRoleName `json:"name"` 221 } 222 223 // AccountRoleName represent the name of the role of an account. 224 // 225 // swagger:type string 226 type AccountRoleName string 227 228 const ( 229 AccountRoleUser AccountRoleName = "user" // Standard user 230 AccountRoleModerator AccountRoleName = "moderator" // Moderator privileges 231 AccountRoleAdmin AccountRoleName = "admin" // Instance admin 232 AccountRoleUnknown AccountRoleName = "" // We don't know / remote account 233 )