| 
									
										
										
										
											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 14:30:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-08 14:25:55 +02:00
										 |  |  | package model | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | import "mime/multipart" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | // AttachmentRequest models media attachment creation parameters. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // swagger: ignore | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | type AttachmentRequest struct { | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | 	// Media file. | 
					
						
							|  |  |  | 	File *multipart.FileHeader `form:"file" binding:"required"` | 
					
						
							|  |  |  | 	// Description of the media file. Optional. | 
					
						
							|  |  |  | 	// This will be used as alt-text for users of screenreaders etc. | 
					
						
							|  |  |  | 	// example: This is an image of some kittens, they are very cute and fluffy. | 
					
						
							|  |  |  | 	Description string `form:"description"` | 
					
						
							|  |  |  | 	// Focus of the media file. Optional. | 
					
						
							|  |  |  | 	// If present, it should be in the form of two comma-separated floats between -1 and 1. | 
					
						
							|  |  |  | 	// example: -0.5,0.565 | 
					
						
							|  |  |  | 	Focus string `form:"focus"` | 
					
						
							| 
									
										
										
										
											2021-05-10 16:29:05 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | // AttachmentUpdateRequest models an update request for an attachment. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // swagger:ignore | 
					
						
							| 
									
										
										
										
											2021-05-10 16:29:05 +02:00
										 |  |  | type AttachmentUpdateRequest struct { | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | 	// Description of the media file. | 
					
						
							|  |  |  | 	// This will be used as alt-text for users of screenreaders etc. | 
					
						
							|  |  |  | 	// allowEmptyValue: true | 
					
						
							| 
									
										
										
										
											2021-05-15 11:58:11 +02:00
										 |  |  | 	Description *string `form:"description" json:"description" xml:"description"` | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | 	// Focus of the media file. | 
					
						
							|  |  |  | 	// If present, it should be in the form of two comma-separated floats between -1 and 1. | 
					
						
							|  |  |  | 	// allowEmptyValue: true | 
					
						
							|  |  |  | 	Focus *string `form:"focus" json:"focus" xml:"focus"` | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | // Attachment models a media attachment. | 
					
						
							| 
									
										
										
										
											2021-07-31 17:49:59 +02:00
										 |  |  | // | 
					
						
							|  |  |  | // swagger:model attachment | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | type Attachment struct { | 
					
						
							| 
									
										
										
										
											2021-07-31 17:49:59 +02:00
										 |  |  | 	// The ID of the attachment. | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | 	// example: 01FC31DZT1AYWDZ8XTCRWRBYRK | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | 	ID string `json:"id"` | 
					
						
							|  |  |  | 	// The type of the attachment. | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | 	// enum: | 
					
						
							|  |  |  | 	//   - unknown | 
					
						
							|  |  |  | 	//   - image | 
					
						
							|  |  |  | 	//   - gifv | 
					
						
							|  |  |  | 	//   - video | 
					
						
							|  |  |  | 	//   - audio | 
					
						
							| 
									
										
										
										
											2021-07-31 17:49:59 +02:00
										 |  |  | 	// example: image | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | 	Type string `json:"type"` | 
					
						
							|  |  |  | 	// The location of the original full-size attachment. | 
					
						
							| 
									
										
										
										
											2021-07-31 17:49:59 +02:00
										 |  |  | 	// example: https://example.org/fileserver/some_id/attachments/some_id/original/attachment.jpeg | 
					
						
							| 
									
										
										
										
											2022-07-22 12:48:19 +02:00
										 |  |  | 	URL *string `json:"url"` | 
					
						
							| 
									
										
										
										
											2022-05-28 19:59:55 +02:00
										 |  |  | 	// A shorter URL for the attachment. | 
					
						
							|  |  |  | 	// In our case, we just give the URL again since we don't create smaller URLs. | 
					
						
							| 
									
										
										
										
											2023-11-10 19:29:26 +01:00
										 |  |  | 	TextURL *string `json:"text_url"` | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | 	// The location of a scaled-down preview of the attachment. | 
					
						
							| 
									
										
										
										
											2021-07-31 17:49:59 +02:00
										 |  |  | 	// example: https://example.org/fileserver/some_id/attachments/some_id/small/attachment.jpeg | 
					
						
							| 
									
										
										
										
											2023-11-10 19:29:26 +01:00
										 |  |  | 	PreviewURL *string `json:"preview_url"` | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 	// The location of the full-size original attachment on the remote server. | 
					
						
							| 
									
										
										
										
											2021-07-31 17:49:59 +02:00
										 |  |  | 	// Only defined for instances other than our own. | 
					
						
							|  |  |  | 	// example: https://some-other-server.org/attachments/original/ahhhhh.jpeg | 
					
						
							| 
									
										
										
										
											2022-07-22 12:48:19 +02:00
										 |  |  | 	RemoteURL *string `json:"remote_url"` | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 	// The location of a scaled-down preview of the attachment on the remote server. | 
					
						
							| 
									
										
										
										
											2021-07-31 17:49:59 +02:00
										 |  |  | 	// Only defined for instances other than our own. | 
					
						
							|  |  |  | 	// example: https://some-other-server.org/attachments/small/ahhhhh.jpeg | 
					
						
							| 
									
										
										
										
											2022-07-22 12:48:19 +02:00
										 |  |  | 	PreviewRemoteURL *string `json:"preview_remote_url"` | 
					
						
							| 
									
										
										
										
											2021-07-31 17:49:59 +02:00
										 |  |  | 	// Metadata for this attachment. | 
					
						
							| 
									
										
										
										
											2023-11-10 19:29:26 +01:00
										 |  |  | 	Meta *MediaMeta `json:"meta"` | 
					
						
							| 
									
										
										
										
											2021-07-31 17:49:59 +02:00
										 |  |  | 	// Alt text that describes what is in the media attachment. | 
					
						
							|  |  |  | 	// example: This is a picture of a kitten. | 
					
						
							| 
									
										
										
										
											2022-07-22 12:48:19 +02:00
										 |  |  | 	Description *string `json:"description"` | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | 	// A hash computed by the BlurHash algorithm, for generating colorful preview thumbnails when media has not been downloaded yet. | 
					
						
							|  |  |  | 	// See https://github.com/woltapp/blurhash | 
					
						
							| 
									
										
										
										
											2023-11-10 19:29:26 +01:00
										 |  |  | 	Blurhash *string `json:"blurhash"` | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | // MediaMeta models media metadata. | 
					
						
							|  |  |  | // This can be metadata about an image, an audio file, video, etc. | 
					
						
							| 
									
										
										
										
											2021-07-31 17:49:59 +02:00
										 |  |  | // | 
					
						
							|  |  |  | // swagger:model mediaMeta | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | type MediaMeta struct { | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | 	// Dimensions of the original media. | 
					
						
							|  |  |  | 	Original MediaDimensions `json:"original"` | 
					
						
							|  |  |  | 	// Dimensions of the thumbnail/small version of the media. | 
					
						
							|  |  |  | 	Small MediaDimensions `json:"small,omitempty"` | 
					
						
							|  |  |  | 	// Focus data for the media. | 
					
						
							| 
									
										
										
										
											2023-01-16 16:19:17 +01:00
										 |  |  | 	Focus *MediaFocus `json:"focus,omitempty"` | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | // MediaFocus models the focal point of a piece of media. | 
					
						
							| 
									
										
										
										
											2021-07-31 17:49:59 +02:00
										 |  |  | // | 
					
						
							|  |  |  | // swagger:model mediaFocus | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | type MediaFocus struct { | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | 	// x position of the focus | 
					
						
							|  |  |  | 	// should be between -1 and 1 | 
					
						
							|  |  |  | 	X float32 `json:"x"` | 
					
						
							|  |  |  | 	// y position of the focus | 
					
						
							|  |  |  | 	// should be between -1 and 1 | 
					
						
							|  |  |  | 	Y float32 `json:"y"` | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | // MediaDimensions models detailed properties of a piece of media. | 
					
						
							| 
									
										
										
										
											2021-07-31 17:49:59 +02:00
										 |  |  | // | 
					
						
							|  |  |  | // swagger:model mediaDimensions | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | type MediaDimensions struct { | 
					
						
							| 
									
										
										
										
											2021-08-02 19:06:44 +02:00
										 |  |  | 	// Width of the media in pixels. | 
					
						
							|  |  |  | 	// Not set for audio. | 
					
						
							|  |  |  | 	// example: 1920 | 
					
						
							|  |  |  | 	Width int `json:"width,omitempty"` | 
					
						
							|  |  |  | 	// Height of the media in pixels. | 
					
						
							|  |  |  | 	// Not set for audio. | 
					
						
							|  |  |  | 	// example: 1080 | 
					
						
							|  |  |  | 	Height int `json:"height,omitempty"` | 
					
						
							|  |  |  | 	// Framerate of the media. | 
					
						
							|  |  |  | 	// Only set for video and gifs. | 
					
						
							|  |  |  | 	// example: 30 | 
					
						
							|  |  |  | 	FrameRate string `json:"frame_rate,omitempty"` | 
					
						
							|  |  |  | 	// Duration of the media in seconds. | 
					
						
							|  |  |  | 	// Only set for video and audio. | 
					
						
							|  |  |  | 	// example: 5.43 | 
					
						
							|  |  |  | 	Duration float32 `json:"duration,omitempty"` | 
					
						
							|  |  |  | 	// Bitrate of the media in bits per second. | 
					
						
							|  |  |  | 	// example: 1000000 | 
					
						
							|  |  |  | 	Bitrate int `json:"bitrate,omitempty"` | 
					
						
							|  |  |  | 	// Size of the media, in the format `[width]x[height]`. | 
					
						
							|  |  |  | 	// Not set for audio. | 
					
						
							|  |  |  | 	// example: 1920x1080 | 
					
						
							|  |  |  | 	Size string `json:"size,omitempty"` | 
					
						
							|  |  |  | 	// Aspect ratio of the media. | 
					
						
							|  |  |  | 	// Equal to width / height. | 
					
						
							|  |  |  | 	// example: 1.777777778 | 
					
						
							|  |  |  | 	Aspect float32 `json:"aspect,omitempty"` | 
					
						
							| 
									
										
										
										
											2021-03-11 14:30:14 +01:00
										 |  |  | } |