| 
									
										
										
										
											2021-03-11 21:15:51 +01:00
										 |  |  | /* | 
					
						
							|  |  |  |    GoToSocial | 
					
						
							|  |  |  |    Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    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-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-03-11 21:15:51 +01:00
										 |  |  | // Account represents a mastodon-api Account object, as described here: https://docs.joinmastodon.org/entities/account/ | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | type Account struct { | 
					
						
							| 
									
										
										
										
											2021-03-11 21:15:51 +01:00
										 |  |  | 	// The account id | 
					
						
							|  |  |  | 	ID string `json:"id"` | 
					
						
							|  |  |  | 	// The username of the account, not including domain. | 
					
						
							|  |  |  | 	Username string `json:"username"` | 
					
						
							|  |  |  | 	// The Webfinger account URI. Equal to username for local users, or username@domain for remote users. | 
					
						
							|  |  |  | 	Acct string `json:"acct"` | 
					
						
							|  |  |  | 	// The profile's display name. | 
					
						
							|  |  |  | 	DisplayName string `json:"display_name"` | 
					
						
							|  |  |  | 	// Whether the account manually approves follow requests. | 
					
						
							|  |  |  | 	Locked bool `json:"locked"` | 
					
						
							|  |  |  | 	// Whether the account has opted into discovery features such as the profile directory. | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	Discoverable bool `json:"discoverable,omitempty"` | 
					
						
							| 
									
										
										
										
											2021-03-11 21:15:51 +01:00
										 |  |  | 	// A presentational flag. Indicates that the account may perform automated actions, may not be monitored, or identifies as a robot. | 
					
						
							|  |  |  | 	Bot bool `json:"bot"` | 
					
						
							|  |  |  | 	// When the account was created. (ISO 8601 Datetime) | 
					
						
							|  |  |  | 	CreatedAt string `json:"created_at"` | 
					
						
							|  |  |  | 	// The profile's bio / description. | 
					
						
							|  |  |  | 	Note string `json:"note"` | 
					
						
							|  |  |  | 	// The location of the user's profile page. | 
					
						
							|  |  |  | 	URL string `json:"url"` | 
					
						
							|  |  |  | 	// An image icon that is shown next to statuses and in the profile. | 
					
						
							|  |  |  | 	Avatar string `json:"avatar"` | 
					
						
							|  |  |  | 	// A static version of the avatar. Equal to avatar if its value is a static image; different if avatar is an animated GIF. | 
					
						
							|  |  |  | 	AvatarStatic string `json:"avatar_static"` | 
					
						
							|  |  |  | 	// An image banner that is shown above the profile and in profile cards. | 
					
						
							|  |  |  | 	Header string `json:"header"` | 
					
						
							|  |  |  | 	// A static version of the header. Equal to header if its value is a static image; different if header is an animated GIF. | 
					
						
							|  |  |  | 	HeaderStatic string `json:"header_static"` | 
					
						
							|  |  |  | 	//  The reported followers of this profile. | 
					
						
							|  |  |  | 	FollowersCount int `json:"followers_count"` | 
					
						
							|  |  |  | 	// The reported follows of this profile. | 
					
						
							|  |  |  | 	FollowingCount int `json:"following_count"` | 
					
						
							|  |  |  | 	// How many statuses are attached to this account. | 
					
						
							|  |  |  | 	StatusesCount int `json:"statuses_count"` | 
					
						
							|  |  |  | 	// When the most recent status was posted. (ISO 8601 Datetime) | 
					
						
							|  |  |  | 	LastStatusAt string `json:"last_status_at"` | 
					
						
							|  |  |  | 	// Custom emoji entities to be used when rendering the profile. If none, an empty array will be returned. | 
					
						
							|  |  |  | 	Emojis []Emoji `json:"emojis"` | 
					
						
							|  |  |  | 	// Additional metadata attached to a profile as name-value pairs. | 
					
						
							|  |  |  | 	Fields []Field `json:"fields"` | 
					
						
							|  |  |  | 	// An extra entity returned when an account is suspended. | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	Suspended bool `json:"suspended,omitempty"` | 
					
						
							| 
									
										
										
										
											2021-03-11 21:15:51 +01:00
										 |  |  | 	// When a timed mute will expire, if applicable. (ISO 8601 Datetime) | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	MuteExpiresAt string `json:"mute_expires_at,omitempty"` | 
					
						
							| 
									
										
										
										
											2021-03-11 21:15:51 +01:00
										 |  |  | 	// An extra entity to be used with API methods to verify credentials and update credentials. | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 	Source *Source `json:"source,omitempty"` | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | // AccountCreateRequest represents the form submitted during a POST request to /api/v1/accounts. | 
					
						
							|  |  |  | // See https://docs.joinmastodon.org/methods/accounts/ | 
					
						
							|  |  |  | 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-04-01 20:46:45 +02:00
										 |  |  | 	// The desired username for the account | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Username string `form:"username" json:"username" xml:"username" binding:"required"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// The email address to be used for login | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Email string `form:"email" json:"email" xml:"email" binding:"required"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// The password to be used for login | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Password string `form:"password" json:"password" xml:"password" binding:"required"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// Whether the user agrees to the local rules, terms, and policies. | 
					
						
							|  |  |  | 	// These should be presented to the user in order to allow them to consent before setting this parameter to TRUE. | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Agreement bool `form:"agreement"  json:"agreement" xml:"agreement" binding:"required"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// The language of the confirmation email that will be sent | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Locale string `form:"locale" json:"locale" xml:"locale" binding:"required"` | 
					
						
							| 
									
										
										
										
											2021-05-08 14:25:55 +02:00
										 |  |  | 	// The IP of the sign up request, will not be parsed from the form but must be added manually | 
					
						
							|  |  |  | 	IP net.IP `form:"-"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // UpdateCredentialsRequest represents the form submitted during a PATCH request to /api/v1/accounts/update_credentials. | 
					
						
							|  |  |  | // See https://docs.joinmastodon.org/methods/accounts/ | 
					
						
							|  |  |  | type UpdateCredentialsRequest struct { | 
					
						
							|  |  |  | 	// Whether the account should be shown in the profile directory. | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Discoverable *bool `form:"discoverable" json:"discoverable" xml:"discoverable"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// Whether the account has a bot flag. | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Bot *bool `form:"bot" json:"bot" xml:"bot"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// The display name to use for the profile. | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	DisplayName *string `form:"display_name" json:"display_name" xml:"display_name"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// The account bio. | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Note *string `form:"note" json:"note" xml:"note"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// Avatar image encoded using multipart/form-data | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Avatar *multipart.FileHeader `form:"avatar" json:"avatar" xml:"avatar"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// Header image encoded using multipart/form-data | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Header *multipart.FileHeader `form:"header" json:"header" xml:"header"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// Whether manual approval of follow requests is required. | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Locked *bool `form:"locked" json:"locked" xml:"locked"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// New Source values for this account | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Source *UpdateSource `form:"source" json:"source" xml:"source"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// Profile metadata name and value | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	FieldsAttributes *[]UpdateField `form:"fields_attributes" json:"fields_attributes" xml:"fields_attributes"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // UpdateSource is to be used specifically in an UpdateCredentialsRequest. | 
					
						
							|  |  |  | type UpdateSource struct { | 
					
						
							|  |  |  | 	// Default post privacy for authored statuses. | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Privacy *string `form:"privacy" json:"privacy" xml:"privacy"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// Whether to mark authored statuses as sensitive by default. | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Sensitive *bool `form:"sensitive" json:"sensitive" xml:"sensitive"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// Default language to use for authored statuses. (ISO 6391) | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Language *string `form:"language" json:"language" xml:"language"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // UpdateField is to be used specifically in an UpdateCredentialsRequest. | 
					
						
							|  |  |  | // By default, max 4 fields and 255 characters per property/value. | 
					
						
							|  |  |  | type UpdateField struct { | 
					
						
							|  |  |  | 	// Name of the field | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Name *string `form:"name" json:"name" xml:"name"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	// Value of the field | 
					
						
							| 
									
										
										
										
											2021-05-21 15:48:26 +02:00
										 |  |  | 	Value *string `form:"value" json:"value" xml:"value"` | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // AccountFollowRequest is for parsing requests at /api/v1/accounts/:id/follow | 
					
						
							|  |  |  | type AccountFollowRequest struct { | 
					
						
							|  |  |  | 	// ID of the account to follow request | 
					
						
							|  |  |  | 	// This should be a URL parameter not a form field | 
					
						
							|  |  |  | 	TargetAccountID string `form:"-"` | 
					
						
							|  |  |  | 	// Show reblogs for this account? | 
					
						
							|  |  |  | 	Reblogs *bool `form:"reblogs" json:"reblogs" xml:"reblogs"` | 
					
						
							|  |  |  | 	// Notify when this account posts? | 
					
						
							|  |  |  | 	Notify *bool `form:"notify" json:"notify" xml:"notify"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | } |