2023-03-12 16:00:57 +01:00
|
|
|
// GoToSocial
|
|
|
|
// Copyright (C) GoToSocial Authors admin@gotosocial.org
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2021-03-11 21:15:51 +01:00
|
|
|
|
2021-05-08 14:25:55 +02:00
|
|
|
package model
|
2021-03-11 14:30:14 +01:00
|
|
|
|
2021-05-08 14:25:55 +02:00
|
|
|
import (
|
|
|
|
"mime/multipart"
|
|
|
|
"net"
|
|
|
|
)
|
2021-04-01 20:46:45 +02:00
|
|
|
|
2021-08-02 19:06:44 +02:00
|
|
|
// Account models a fediverse account.
|
|
|
|
//
|
|
|
|
// The modelled account can be either a remote account, or one on this instance.
|
2021-07-31 17:49:59 +02:00
|
|
|
//
|
|
|
|
// swagger:model account
|
2021-03-11 14:30:14 +01:00
|
|
|
type Account struct {
|
2021-07-31 17:49:59 +02:00
|
|
|
// The account id.
|
|
|
|
// example: 01FBVD42CQ3ZEEVMW180SBX03B
|
2021-03-11 21:15:51 +01:00
|
|
|
ID string `json:"id"`
|
|
|
|
// The username of the account, not including domain.
|
2021-07-31 17:49:59 +02:00
|
|
|
// example: some_user
|
2021-03-11 21:15:51 +01:00
|
|
|
Username string `json:"username"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// The account URI as discovered via webfinger.
|
|
|
|
// Equal to username for local users, or username@domain for remote users.
|
|
|
|
// example: some_user@example.org
|
2021-03-11 21:15:51 +01:00
|
|
|
Acct string `json:"acct"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// The account's display name.
|
|
|
|
// example: big jeff (he/him)
|
2021-03-11 21:15:51 +01:00
|
|
|
DisplayName string `json:"display_name"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Account manually approves follow requests.
|
2021-03-11 21:15:51 +01:00
|
|
|
Locked bool `json:"locked"`
|
2021-08-02 19:06:44 +02:00
|
|
|
// Account has opted into discovery features.
|
2023-02-16 14:20:23 +01:00
|
|
|
Discoverable bool `json:"discoverable"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Account identifies as a bot.
|
2021-03-11 21:15:51 +01:00
|
|
|
Bot bool `json:"bot"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// When the account was created (ISO 8601 Datetime).
|
|
|
|
// example: 2021-07-30T09:20:25+00:00
|
2021-03-11 21:15:51 +01:00
|
|
|
CreatedAt string `json:"created_at"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Bio/description of this account.
|
2021-03-11 21:15:51 +01:00
|
|
|
Note string `json:"note"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Web location of the account's profile page.
|
|
|
|
// example: https://example.org/@some_user
|
2021-03-11 21:15:51 +01:00
|
|
|
URL string `json:"url"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Web location of the account's avatar.
|
|
|
|
// example: https://example.org/media/some_user/avatar/original/avatar.jpeg
|
2021-03-11 21:15:51 +01:00
|
|
|
Avatar string `json:"avatar"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Web location of a static version of the account's avatar.
|
|
|
|
// Only relevant when the account's main avatar is a video or a gif.
|
|
|
|
// example: https://example.org/media/some_user/avatar/static/avatar.png
|
2021-03-11 21:15:51 +01:00
|
|
|
AvatarStatic string `json:"avatar_static"`
|
2024-07-08 15:47:03 +02:00
|
|
|
// Description of this account's avatar, for alt text.
|
|
|
|
// example: A cute drawing of a smiling sloth.
|
|
|
|
AvatarDescription string `json:"avatar_description,omitempty"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Web location of the account's header image.
|
|
|
|
// example: https://example.org/media/some_user/header/original/header.jpeg
|
2021-03-11 21:15:51 +01:00
|
|
|
Header string `json:"header"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Web location of a static version of the account's header.
|
|
|
|
// Only relevant when the account's main header is a video or a gif.
|
|
|
|
// example: https://example.org/media/some_user/header/static/header.png
|
2021-03-11 21:15:51 +01:00
|
|
|
HeaderStatic string `json:"header_static"`
|
2024-07-08 15:47:03 +02:00
|
|
|
// Description of this account's header, for alt text.
|
|
|
|
// example: A sunlit field with purple flowers.
|
|
|
|
HeaderDescription string `json:"header_description,omitempty"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Number of accounts following this account, according to our instance.
|
2021-03-11 21:15:51 +01:00
|
|
|
FollowersCount int `json:"followers_count"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Number of account's followed by this account, according to our instance.
|
2021-03-11 21:15:51 +01:00
|
|
|
FollowingCount int `json:"following_count"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Number of statuses posted by this account, according to our instance.
|
2021-03-11 21:15:51 +01:00
|
|
|
StatusesCount int `json:"statuses_count"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// When the account's most recent status was posted (ISO 8601 Datetime).
|
|
|
|
// example: 2021-07-30T09:20:25+00:00
|
2022-11-13 21:38:01 +01:00
|
|
|
LastStatusAt *string `json:"last_status_at"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Array of custom emojis used in this account's note or display name.
|
2024-06-06 12:22:16 +02:00
|
|
|
// Empty for blocked accounts.
|
2021-03-11 21:15:51 +01:00
|
|
|
Emojis []Emoji `json:"emojis"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Additional metadata attached to this account's profile.
|
2024-06-06 12:22:16 +02:00
|
|
|
// Empty for blocked accounts.
|
2021-03-11 21:15:51 +01:00
|
|
|
Fields []Field `json:"fields"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Account has been suspended by our instance.
|
2021-04-01 20:46:45 +02:00
|
|
|
Suspended bool `json:"suspended,omitempty"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Extra profile information. Shown only if the requester owns the account being requested.
|
2021-04-19 19:42:19 +02:00
|
|
|
Source *Source `json:"source,omitempty"`
|
2024-03-25 18:32:24 +01:00
|
|
|
// Filename of user-selected CSS theme to include when rendering this account's profile or statuses. Eg., `blurple-light.css`.
|
|
|
|
Theme string `json:"theme,omitempty"`
|
2022-09-12 13:14:29 +02:00
|
|
|
// CustomCSS to include when rendering this account's profile or statuses.
|
|
|
|
CustomCSS string `json:"custom_css,omitempty"`
|
2022-10-08 14:00:39 +02:00
|
|
|
// Account has enabled RSS feed.
|
2024-04-02 11:42:24 +02:00
|
|
|
// Key/value omitted if false.
|
2022-10-08 14:00:39 +02:00
|
|
|
EnableRSS bool `json:"enable_rss,omitempty"`
|
2024-04-02 11:42:24 +02:00
|
|
|
// Account has opted to hide their followers/following collections.
|
|
|
|
// Key/value omitted if false.
|
|
|
|
HideCollections bool `json:"hide_collections,omitempty"`
|
2022-11-15 10:19:32 +01:00
|
|
|
// Role of the account on this instance.
|
2024-04-02 11:42:24 +02:00
|
|
|
// Key/value omitted for remote accounts.
|
2023-02-20 17:00:44 +01:00
|
|
|
Role *AccountRole `json:"role,omitempty"`
|
2024-01-16 17:22:44 +01:00
|
|
|
// If set, indicates that this account is currently inactive, and has migrated to the given account.
|
2024-04-02 11:42:24 +02:00
|
|
|
// Key/value omitted for accounts that haven't moved, and for suspended accounts.
|
2024-01-16 17:22:44 +01:00
|
|
|
Moved *Account `json:"moved,omitempty"`
|
2024-07-21 14:22:08 +02:00
|
|
|
}
|
2024-07-08 15:47:03 +02:00
|
|
|
|
2024-07-21 14:22:08 +02:00
|
|
|
// WebAccount is like Account, but with
|
|
|
|
// additional fields not exposed via JSON;
|
|
|
|
// used only internally for templating etc.
|
|
|
|
//
|
|
|
|
// swagger:ignore
|
|
|
|
type WebAccount struct {
|
|
|
|
*Account
|
2024-07-08 15:47:03 +02:00
|
|
|
|
|
|
|
// Proper attachment model for the avatar.
|
|
|
|
//
|
2024-07-21 14:22:08 +02:00
|
|
|
// Only set if this account had an avatar set
|
|
|
|
// (and not just the default "blank" image.)
|
|
|
|
AvatarAttachment *WebAttachment `json:"-"`
|
|
|
|
|
|
|
|
// Proper attachment model for the header.
|
|
|
|
//
|
|
|
|
// Only set if this account had a header set
|
|
|
|
// (and not just the default "blank" image.)
|
|
|
|
HeaderAttachment *WebAttachment `json:"-"`
|
2021-03-11 14:30:14 +01:00
|
|
|
}
|
2021-04-01 20:46:45 +02:00
|
|
|
|
2024-06-06 18:38:02 +02:00
|
|
|
// MutedAccount extends Account with a field used only by the muted user list.
|
|
|
|
//
|
|
|
|
// swagger:model mutedAccount
|
|
|
|
type MutedAccount struct {
|
|
|
|
Account
|
|
|
|
// If this account has been muted, when will the mute expire (ISO 8601 Datetime).
|
|
|
|
// If the mute is indefinite, this will be null.
|
|
|
|
// example: 2021-07-30T09:20:25+00:00
|
|
|
|
MuteExpiresAt *string `json:"mute_expires_at"`
|
|
|
|
}
|
|
|
|
|
2021-08-02 19:06:44 +02:00
|
|
|
// AccountCreateRequest models account creation parameters.
|
2021-07-31 17:49:59 +02:00
|
|
|
//
|
2021-08-02 19:06:44 +02:00
|
|
|
// swagger:parameters accountCreate
|
2021-04-01 20:46:45 +02:00
|
|
|
type AccountCreateRequest struct {
|
|
|
|
// Text that will be reviewed by moderators if registrations require manual approval.
|
2021-05-21 15:48:26 +02:00
|
|
|
Reason string `form:"reason" json:"reason" xml:"reason"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// The desired username for the account.
|
|
|
|
// swagger:parameters
|
|
|
|
// pattern: [a-z0-9_]{2,64}
|
|
|
|
// example: a_valid_username
|
|
|
|
// required: true
|
2021-05-21 15:48:26 +02:00
|
|
|
Username string `form:"username" json:"username" xml:"username" binding:"required"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// The email address to be used for login.
|
|
|
|
// swagger:parameters
|
|
|
|
// example: someone@wherever.com
|
|
|
|
// required: true
|
2021-05-21 15:48:26 +02:00
|
|
|
Email string `form:"email" json:"email" xml:"email" binding:"required"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// The password to be used for login. This will be hashed before storage.
|
|
|
|
// swagger:parameters
|
|
|
|
// example: some_really_really_really_strong_password
|
|
|
|
// required: true
|
2021-05-21 15:48:26 +02:00
|
|
|
Password string `form:"password" json:"password" xml:"password" binding:"required"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// The user agrees to the terms, conditions, and policies of the instance.
|
|
|
|
// swagger:parameters
|
|
|
|
// required: true
|
2021-05-21 15:48:26 +02:00
|
|
|
Agreement bool `form:"agreement" json:"agreement" xml:"agreement" binding:"required"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// The language of the confirmation email that will be sent.
|
|
|
|
// swagger:parameters
|
|
|
|
// example: en
|
|
|
|
// Required: true
|
2021-05-21 15:48:26 +02:00
|
|
|
Locale string `form:"locale" json:"locale" xml:"locale" binding:"required"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// The IP of the sign up request, will not be parsed from the form.
|
|
|
|
// swagger:parameters
|
|
|
|
// swagger:ignore
|
2021-05-08 14:25:55 +02:00
|
|
|
IP net.IP `form:"-"`
|
2021-04-01 20:46:45 +02:00
|
|
|
}
|
|
|
|
|
2021-08-02 19:06:44 +02:00
|
|
|
// UpdateCredentialsRequest models an update to an account, by the account owner.
|
|
|
|
//
|
2021-07-31 17:49:59 +02:00
|
|
|
// swagger:ignore
|
2021-04-01 20:46:45 +02:00
|
|
|
type UpdateCredentialsRequest struct {
|
2021-07-31 17:49:59 +02:00
|
|
|
// Account should be made discoverable and shown in the profile directory (if enabled).
|
2023-05-12 11:17:31 +02:00
|
|
|
Discoverable *bool `form:"discoverable" json:"discoverable"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Account is flagged as a bot.
|
2023-05-12 11:17:31 +02:00
|
|
|
Bot *bool `form:"bot" json:"bot"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// The display name to use for the account.
|
2023-05-12 11:17:31 +02:00
|
|
|
DisplayName *string `form:"display_name" json:"display_name"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Bio/description of this account.
|
2023-05-12 11:17:31 +02:00
|
|
|
Note *string `form:"note" json:"note"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Avatar image encoded using multipart/form-data.
|
2023-05-12 11:17:31 +02:00
|
|
|
Avatar *multipart.FileHeader `form:"avatar" json:"-"`
|
2024-07-08 15:47:03 +02:00
|
|
|
// Description of the avatar image, for alt-text.
|
|
|
|
AvatarDescription *string `form:"avatar_description" json:"avatar_description"`
|
2021-04-01 20:46:45 +02:00
|
|
|
// Header image encoded using multipart/form-data
|
2023-05-12 11:17:31 +02:00
|
|
|
Header *multipart.FileHeader `form:"header" json:"-"`
|
2024-07-08 15:47:03 +02:00
|
|
|
// Description of the header image, for alt-text.
|
|
|
|
HeaderDescription *string `form:"header_description" json:"header_description"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Require manual approval of follow requests.
|
2023-05-12 11:17:31 +02:00
|
|
|
Locked *bool `form:"locked" json:"locked"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// New Source values for this account.
|
2023-05-12 11:17:31 +02:00
|
|
|
Source *UpdateSource `form:"source" json:"source"`
|
|
|
|
// Profile metadata names and values.
|
|
|
|
FieldsAttributes *[]UpdateField `form:"fields_attributes" json:"-"`
|
|
|
|
// Profile metadata names and values, parsed from JSON.
|
|
|
|
JSONFieldsAttributes *map[string]UpdateField `form:"-" json:"fields_attributes"`
|
2024-03-25 18:32:24 +01:00
|
|
|
// Theme file name to be used when rendering this account's profile or statuses.
|
|
|
|
// Use empty string to unset.
|
|
|
|
Theme *string `form:"theme" json:"theme"`
|
2022-09-12 13:14:29 +02:00
|
|
|
// Custom CSS to be included when rendering this account's profile or statuses.
|
2024-03-25 18:32:24 +01:00
|
|
|
// Use empty string to unset.
|
2023-05-12 11:17:31 +02:00
|
|
|
CustomCSS *string `form:"custom_css" json:"custom_css"`
|
2022-10-08 14:00:39 +02:00
|
|
|
// Enable RSS feed of public toots for this account at /@[username]/feed.rss
|
2023-05-12 11:17:31 +02:00
|
|
|
EnableRSS *bool `form:"enable_rss" json:"enable_rss"`
|
2024-04-02 11:42:24 +02:00
|
|
|
// Hide this account's following/followers collections.
|
|
|
|
HideCollections *bool `form:"hide_collections" json:"hide_collections"`
|
2021-04-01 20:46:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateSource is to be used specifically in an UpdateCredentialsRequest.
|
2021-08-02 19:06:44 +02:00
|
|
|
//
|
2024-03-06 18:05:45 +01:00
|
|
|
// swagger:ignore
|
2021-04-01 20:46:45 +02:00
|
|
|
type UpdateSource struct {
|
|
|
|
// Default post privacy for authored statuses.
|
2023-05-12 11:17:31 +02:00
|
|
|
Privacy *string `form:"privacy" json:"privacy"`
|
2021-07-31 17:49:59 +02:00
|
|
|
// Mark authored statuses as sensitive by default.
|
2023-05-12 11:17:31 +02:00
|
|
|
Sensitive *bool `form:"sensitive" json:"sensitive"`
|
2021-04-01 20:46:45 +02:00
|
|
|
// Default language to use for authored statuses. (ISO 6391)
|
2023-05-12 11:17:31 +02:00
|
|
|
Language *string `form:"language" json:"language"`
|
2023-03-02 12:06:40 +01:00
|
|
|
// Default format for authored statuses (text/plain or text/markdown).
|
2023-05-12 11:17:31 +02:00
|
|
|
StatusContentType *string `form:"status_content_type" json:"status_content_type"`
|
2021-04-01 20:46:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateField is to be used specifically in an UpdateCredentialsRequest.
|
2023-05-12 11:17:31 +02:00
|
|
|
// By default, max 6 fields and 255 characters per property/value.
|
2021-07-31 17:49:59 +02:00
|
|
|
//
|
2024-03-06 18:05:45 +01:00
|
|
|
// swagger:ignore
|
2021-04-01 20:46:45 +02:00
|
|
|
type UpdateField struct {
|
2023-05-12 11:17:31 +02:00
|
|
|
// Key this form field was submitted with;
|
|
|
|
// only set if it was submitted as JSON.
|
|
|
|
Key int `form:"-" json:"-"`
|
2021-04-01 20:46:45 +02:00
|
|
|
// Name of the field
|
2023-05-12 11:17:31 +02:00
|
|
|
Name *string `form:"name" json:"name"`
|
2021-04-01 20:46:45 +02:00
|
|
|
// Value of the field
|
2023-05-12 11:17:31 +02:00
|
|
|
Value *string `form:"value" json:"value"`
|
2021-05-21 15:48:26 +02:00
|
|
|
}
|
|
|
|
|
2021-08-02 19:06:44 +02:00
|
|
|
// AccountFollowRequest models a request to follow an account.
|
2021-07-31 17:49:59 +02:00
|
|
|
//
|
2021-08-02 19:06:44 +02:00
|
|
|
// swagger:ignore
|
2021-05-21 15:48:26 +02:00
|
|
|
type AccountFollowRequest struct {
|
2021-08-02 19:06:44 +02:00
|
|
|
// The id of the account to follow.
|
|
|
|
ID string `form:"-" json:"-" xml:"-"`
|
|
|
|
// Show reblogs from this account.
|
2021-05-21 15:48:26 +02:00
|
|
|
Reblogs *bool `form:"reblogs" json:"reblogs" xml:"reblogs"`
|
2021-08-02 19:06:44 +02:00
|
|
|
// Notify when this account posts.
|
2021-05-21 15:48:26 +02:00
|
|
|
Notify *bool `form:"notify" json:"notify" xml:"notify"`
|
2021-04-01 20:46:45 +02:00
|
|
|
}
|
2022-03-15 16:12:35 +01:00
|
|
|
|
|
|
|
// AccountDeleteRequest models a request to delete an account.
|
|
|
|
//
|
|
|
|
// swagger:ignore
|
|
|
|
type AccountDeleteRequest struct {
|
|
|
|
// Password of the account's user, for confirmation.
|
|
|
|
Password string `form:"password" json:"password" xml:"password"`
|
|
|
|
}
|
2022-11-15 10:19:32 +01:00
|
|
|
|
2024-01-16 17:22:44 +01:00
|
|
|
// AccountMoveRequest models a request to Move an account.
|
|
|
|
//
|
|
|
|
// swagger:ignore
|
|
|
|
type AccountMoveRequest struct {
|
|
|
|
// Password of the account's user, for confirmation.
|
|
|
|
Password string `form:"password" json:"password" xml:"password"`
|
|
|
|
// ActivityPub URI of the account that's being moved to.
|
|
|
|
MovedToURI string `form:"moved_to_uri" json:"moved_to_uri" xml:"moved_to_uri"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// AccountAliasRequest models a request
|
|
|
|
// to set an account's alsoKnownAs URIs.
|
|
|
|
type AccountAliasRequest struct {
|
|
|
|
// ActivityPub URIs of any accounts that this one is being aliased to.
|
|
|
|
AlsoKnownAsURIs []string `form:"also_known_as_uris" json:"also_known_as_uris" xml:"also_known_as_uris"`
|
|
|
|
}
|
|
|
|
|
2022-11-15 10:19:32 +01:00
|
|
|
// AccountRole models the role of an account.
|
|
|
|
//
|
2023-02-20 17:00:44 +01:00
|
|
|
// swagger:model accountRole
|
|
|
|
type AccountRole struct {
|
|
|
|
Name AccountRoleName `json:"name"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// AccountRoleName represent the name of the role of an account.
|
|
|
|
//
|
2022-11-15 10:19:32 +01:00
|
|
|
// swagger:type string
|
2023-02-20 17:00:44 +01:00
|
|
|
type AccountRoleName string
|
2022-11-15 10:19:32 +01:00
|
|
|
|
|
|
|
const (
|
2023-02-20 17:00:44 +01:00
|
|
|
AccountRoleUser AccountRoleName = "user" // Standard user
|
|
|
|
AccountRoleModerator AccountRoleName = "moderator" // Moderator privileges
|
|
|
|
AccountRoleAdmin AccountRoleName = "admin" // Instance admin
|
|
|
|
AccountRoleUnknown AccountRoleName = "" // We don't know / remote account
|
2022-11-15 10:19:32 +01:00
|
|
|
)
|
2023-07-27 10:30:39 +02:00
|
|
|
|
|
|
|
// AccountNoteRequest models a request to update the private note for an account.
|
|
|
|
//
|
|
|
|
// swagger:ignore
|
|
|
|
type AccountNoteRequest struct {
|
|
|
|
// Comment to use for the note text.
|
|
|
|
Comment string `form:"comment" json:"comment" xml:"comment"`
|
|
|
|
}
|