attachment.go (5493B)
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 "mime/multipart" 21 22 // AttachmentRequest models media attachment creation parameters. 23 // 24 // swagger: ignore 25 type AttachmentRequest struct { 26 // Media file. 27 File *multipart.FileHeader `form:"file" binding:"required"` 28 // Description of the media file. Optional. 29 // This will be used as alt-text for users of screenreaders etc. 30 // example: This is an image of some kittens, they are very cute and fluffy. 31 Description string `form:"description"` 32 // Focus of the media file. Optional. 33 // If present, it should be in the form of two comma-separated floats between -1 and 1. 34 // example: -0.5,0.565 35 Focus string `form:"focus"` 36 } 37 38 // AttachmentUpdateRequest models an update request for an attachment. 39 // 40 // swagger:ignore 41 type AttachmentUpdateRequest struct { 42 // Description of the media file. 43 // This will be used as alt-text for users of screenreaders etc. 44 // allowEmptyValue: true 45 Description *string `form:"description" json:"description" xml:"description"` 46 // Focus of the media file. 47 // If present, it should be in the form of two comma-separated floats between -1 and 1. 48 // allowEmptyValue: true 49 Focus *string `form:"focus" json:"focus" xml:"focus"` 50 } 51 52 // Attachment models a media attachment. 53 // 54 // swagger:model attachment 55 type Attachment struct { 56 // The ID of the attachment. 57 // example: 01FC31DZT1AYWDZ8XTCRWRBYRK 58 ID string `json:"id"` 59 // The type of the attachment. 60 // enum: 61 // - unknown 62 // - image 63 // - gifv 64 // - video 65 // - audio 66 // example: image 67 Type string `json:"type"` 68 // The location of the original full-size attachment. 69 // example: https://example.org/fileserver/some_id/attachments/some_id/original/attachment.jpeg 70 URL *string `json:"url"` 71 // A shorter URL for the attachment. 72 // In our case, we just give the URL again since we don't create smaller URLs. 73 TextURL string `json:"text_url"` 74 // The location of a scaled-down preview of the attachment. 75 // example: https://example.org/fileserver/some_id/attachments/some_id/small/attachment.jpeg 76 PreviewURL string `json:"preview_url"` 77 // The location of the full-size original attachment on the remote server. 78 // Only defined for instances other than our own. 79 // example: https://some-other-server.org/attachments/original/ahhhhh.jpeg 80 RemoteURL *string `json:"remote_url"` 81 // The location of a scaled-down preview of the attachment on the remote server. 82 // Only defined for instances other than our own. 83 // example: https://some-other-server.org/attachments/small/ahhhhh.jpeg 84 PreviewRemoteURL *string `json:"preview_remote_url"` 85 // Metadata for this attachment. 86 Meta MediaMeta `json:"meta,omitempty"` 87 // Alt text that describes what is in the media attachment. 88 // example: This is a picture of a kitten. 89 Description *string `json:"description"` 90 // A hash computed by the BlurHash algorithm, for generating colorful preview thumbnails when media has not been downloaded yet. 91 // See https://github.com/woltapp/blurhash 92 Blurhash string `json:"blurhash,omitempty"` 93 } 94 95 // MediaMeta models media metadata. 96 // This can be metadata about an image, an audio file, video, etc. 97 // 98 // swagger:model mediaMeta 99 type MediaMeta struct { 100 // Dimensions of the original media. 101 Original MediaDimensions `json:"original"` 102 // Dimensions of the thumbnail/small version of the media. 103 Small MediaDimensions `json:"small,omitempty"` 104 // Focus data for the media. 105 Focus *MediaFocus `json:"focus,omitempty"` 106 } 107 108 // MediaFocus models the focal point of a piece of media. 109 // 110 // swagger:model mediaFocus 111 type MediaFocus struct { 112 // x position of the focus 113 // should be between -1 and 1 114 X float32 `json:"x"` 115 // y position of the focus 116 // should be between -1 and 1 117 Y float32 `json:"y"` 118 } 119 120 // MediaDimensions models detailed properties of a piece of media. 121 // 122 // swagger:model mediaDimensions 123 type MediaDimensions struct { 124 // Width of the media in pixels. 125 // Not set for audio. 126 // example: 1920 127 Width int `json:"width,omitempty"` 128 // Height of the media in pixels. 129 // Not set for audio. 130 // example: 1080 131 Height int `json:"height,omitempty"` 132 // Framerate of the media. 133 // Only set for video and gifs. 134 // example: 30 135 FrameRate string `json:"frame_rate,omitempty"` 136 // Duration of the media in seconds. 137 // Only set for video and audio. 138 // example: 5.43 139 Duration float32 `json:"duration,omitempty"` 140 // Bitrate of the media in bits per second. 141 // example: 1000000 142 Bitrate int `json:"bitrate,omitempty"` 143 // Size of the media, in the format `[width]x[height]`. 144 // Not set for audio. 145 // example: 1920x1080 146 Size string `json:"size,omitempty"` 147 // Aspect ratio of the media. 148 // Equal to width / height. 149 // example: 1.777777778 150 Aspect float32 `json:"aspect,omitempty"` 151 }