gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

types.go (4044B)


      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 media
     19 
     20 import (
     21 	"context"
     22 	"io"
     23 	"time"
     24 )
     25 
     26 // mime consts
     27 const (
     28 	mimeImage = "image"
     29 	mimeVideo = "video"
     30 
     31 	mimeJpeg      = "jpeg"
     32 	mimeImageJpeg = mimeImage + "/" + mimeJpeg
     33 
     34 	mimeGif      = "gif"
     35 	mimeImageGif = mimeImage + "/" + mimeGif
     36 
     37 	mimePng      = "png"
     38 	mimeImagePng = mimeImage + "/" + mimePng
     39 
     40 	mimeWebp      = "webp"
     41 	mimeImageWebp = mimeImage + "/" + mimeWebp
     42 
     43 	mimeMp4      = "mp4"
     44 	mimeVideoMp4 = mimeVideo + "/" + mimeMp4
     45 )
     46 
     47 // EmojiMaxBytes is the maximum permitted bytes of an emoji upload (50kb)
     48 // const EmojiMaxBytes = 51200
     49 
     50 type Size string
     51 
     52 const (
     53 	SizeSmall    Size = "small"    // SizeSmall is the key for small/thumbnail versions of media
     54 	SizeOriginal Size = "original" // SizeOriginal is the key for original/fullsize versions of media and emoji
     55 	SizeStatic   Size = "static"   // SizeStatic is the key for static (non-animated) versions of emoji
     56 )
     57 
     58 type Type string
     59 
     60 const (
     61 	TypeAttachment Type = "attachment" // TypeAttachment is the key for media attachments
     62 	TypeHeader     Type = "header"     // TypeHeader is the key for profile header requests
     63 	TypeAvatar     Type = "avatar"     // TypeAvatar is the key for profile avatar requests
     64 	TypeEmoji      Type = "emoji"      // TypeEmoji is the key for emoji type requests
     65 )
     66 
     67 // AdditionalMediaInfo represents additional information that should be added to an attachment
     68 // when processing a piece of media.
     69 type AdditionalMediaInfo struct {
     70 	// Time that this media was created; defaults to time.Now().
     71 	CreatedAt *time.Time
     72 	// ID of the status to which this media is attached; defaults to "".
     73 	StatusID *string
     74 	// URL of the media on a remote instance; defaults to "".
     75 	RemoteURL *string
     76 	// Image description of this media; defaults to "".
     77 	Description *string
     78 	// Blurhash of this media; defaults to "".
     79 	Blurhash *string
     80 	// ID of the scheduled status to which this media is attached; defaults to "".
     81 	ScheduledStatusID *string
     82 	// Mark this media as in-use as an avatar; defaults to false.
     83 	Avatar *bool
     84 	// Mark this media as in-use as a header; defaults to false.
     85 	Header *bool
     86 	// X focus coordinate for this media; defaults to 0.
     87 	FocusX *float32
     88 	// Y focus coordinate for this media; defaults to 0.
     89 	FocusY *float32
     90 }
     91 
     92 // AdditionalEmojiInfo represents additional information
     93 // that should be taken into account when processing an emoji.
     94 type AdditionalEmojiInfo struct {
     95 	// Time that this emoji was created; defaults to time.Now().
     96 	CreatedAt *time.Time
     97 	// Domain the emoji originated from. Blank for this instance's domain. Defaults to "".
     98 	Domain *string
     99 	// URL of this emoji on a remote instance; defaults to "".
    100 	ImageRemoteURL *string
    101 	// URL of the static version of this emoji on a remote instance; defaults to "".
    102 	ImageStaticRemoteURL *string
    103 	// Whether this emoji should be disabled (not shown) on this instance; defaults to false.
    104 	Disabled *bool
    105 	// Whether this emoji should be visible in the instance's emoji picker; defaults to true.
    106 	VisibleInPicker *bool
    107 	// ID of the category this emoji should be placed in; defaults to "".
    108 	CategoryID *string
    109 }
    110 
    111 // DataFunc represents a function used to retrieve the raw bytes of a piece of media.
    112 type DataFunc func(ctx context.Context) (reader io.ReadCloser, fileSize int64, err error)