More work on the API. Primarely defining jsonapi types
This commit is contained in:
parent
4f4d05a335
commit
0ed50aca60
13 changed files with 165 additions and 48 deletions
|
@ -24,6 +24,10 @@ type MediaMetadata struct {
|
|||
// Descriptive name for a media file
|
||||
// Emote name for example or servername.filetype for a server's icon
|
||||
Name string
|
||||
// Alternative description of the media file's content
|
||||
AltText string
|
||||
// Whether the media is to be blurred by default
|
||||
Blurred bool
|
||||
}
|
||||
|
||||
func (s *Storage) NewMediaMetadata(location, mediaType, name string) (*MediaMetadata, error) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
var ErrUnknownImageType = errors.New("unknown image format")
|
||||
|
||||
func Compress(dataReader io.Reader, mimeType *string) (io.Reader, error) {
|
||||
// TODO: Get inspired by GTS and use wasm ffmpeg (https://codeberg.org/gruf/go-ffmpreg) for compression
|
||||
data, err := io.ReadAll(dataReader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -51,7 +52,11 @@ func compressVideo(dataIn []byte, subType string) (dataOut []byte, err error) {
|
|||
panic("Implement me")
|
||||
}
|
||||
|
||||
func compressImage(dataIn []byte, subType string, maxSizeX, maxSizeY uint) (dataOut []byte, err error) {
|
||||
func compressImage(
|
||||
dataIn []byte,
|
||||
subType string,
|
||||
maxSizeX, maxSizeY uint,
|
||||
) (dataOut []byte, err error) {
|
||||
imageSize := image.Rect(0, 0, int(maxSizeX), int(maxSizeY))
|
||||
dst := image.NewRGBA(imageSize)
|
||||
var sourceImage image.Image
|
||||
|
|
|
@ -10,15 +10,15 @@ import (
|
|||
//go:generate stringer -type NoteTarget
|
||||
|
||||
// What feed a note is targeting (public, home, followers or dm)
|
||||
type NoteTarget uint8
|
||||
type NoteAccessLevel uint8
|
||||
|
||||
const (
|
||||
// The note is intended for the public
|
||||
NOTE_TARGET_PUBLIC NoteTarget = 0
|
||||
NOTE_TARGET_PUBLIC NoteAccessLevel = 0
|
||||
// The note is intended only for the home screen
|
||||
// not really any idea what the difference is compared to public
|
||||
// Maybe home notes don't show up on the server feed but still for everyone's home feed if it reaches them via follow or boost
|
||||
NOTE_TARGET_HOME NoteTarget = 1 << iota
|
||||
NOTE_TARGET_HOME NoteAccessLevel = 1 << iota
|
||||
// The note is intended only for followers
|
||||
NOTE_TARGET_FOLLOWERS
|
||||
// The note is intended only for a DM to one or more targets
|
||||
|
@ -26,16 +26,16 @@ const (
|
|||
)
|
||||
|
||||
// Converts the NoteTarget value into a type the DB can use
|
||||
func (n *NoteTarget) Value() (driver.Value, error) {
|
||||
func (n *NoteAccessLevel) Value() (driver.Value, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// Converts the raw value from the DB into a NoteTarget
|
||||
func (n *NoteTarget) Scan(value any) error {
|
||||
func (n *NoteAccessLevel) Scan(value any) error {
|
||||
vBig, ok := value.(int64)
|
||||
if !ok {
|
||||
return errors.New("not an int64")
|
||||
}
|
||||
*n = NoteTarget(vBig)
|
||||
*n = NoteAccessLevel(vBig)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -28,15 +28,15 @@ type Note struct {
|
|||
// Raw content of the note. So without additional formatting applied
|
||||
// Might already have formatting applied beforehand from the origin server
|
||||
RawContent string
|
||||
ContentWarning *string // Content warnings of the note, if it contains any
|
||||
Attachments []string `gorm:"serializer:json"` // Links to attachments
|
||||
Emotes []string `gorm:"serializer:json"` // Emotes used in that message
|
||||
RepliesTo *string // Url of the message this replies to
|
||||
Quotes *string // url of the message this note quotes
|
||||
Target NoteTarget // Where to send this message to (public, home, followers, dm)
|
||||
Pings []string `gorm:"serializer:json"` // Who is being tagged in this message. Also serves as DM targets
|
||||
OriginServer string // Url of the origin server. Also the primary key for those
|
||||
Tags []string `gorm:"serializer:json"` // Hashtags
|
||||
ContentWarning *string // Content warnings of the note, if it contains any
|
||||
Attachments []string `gorm:"serializer:json"` // List of Ids for mediaFiles
|
||||
Emotes []string `gorm:"serializer:json"` // Emotes used in that message
|
||||
RepliesTo *string // Url of the message this replies to
|
||||
Quotes *string // url of the message this note quotes
|
||||
AccessLevel NoteAccessLevel // Where to send this message to (public, home, followers, dm)
|
||||
Pings []string `gorm:"serializer:json"` // Who is being tagged in this message. Also serves as DM targets
|
||||
OriginServer string // Url of the origin server. Also the primary key for those
|
||||
Tags []string `gorm:"serializer:json"` // Hashtags
|
||||
}
|
||||
|
||||
func (s *Storage) FindNoteById(id string) (*Note, error) {
|
||||
|
|
|
@ -21,7 +21,7 @@ const (
|
|||
_NoteTarget_name_3 = "NOTE_TARGET_DM"
|
||||
)
|
||||
|
||||
func (i NoteTarget) String() string {
|
||||
func (i NoteAccessLevel) String() string {
|
||||
switch {
|
||||
case i == 0:
|
||||
return _NoteTarget_name_0
|
||||
|
|
|
@ -19,6 +19,8 @@ const (
|
|||
REMOTE_SERVER_MISSKEY = RemoteServerType("Misskey")
|
||||
// Includes Akkoma
|
||||
REMOTE_SERVER_PLEMORA = RemoteServerType("Plemora")
|
||||
// Wafrn is a new entry
|
||||
REMOTE_SERVER_WAFRN = RemoteServerType("Wafrn")
|
||||
// And of course, yours truly
|
||||
REMOTE_SERVER_LINSTROM = RemoteServerType("Linstrom")
|
||||
)
|
||||
|
|
|
@ -12,6 +12,11 @@ type UserInfoField struct {
|
|||
Name string
|
||||
Value string
|
||||
LastUrlCheckDate *time.Time // Used if the value is an url to somewhere. Empty if value is not an url
|
||||
// If the value is an url, this attribute indicates whether Linstrom was able to verify ownership
|
||||
// of the provided url via the common method of
|
||||
// "Does the target url contain a rel='me' link to the owner's account"
|
||||
Confirmed bool
|
||||
BelongsTo string // Id of account this info field belongs to
|
||||
}
|
||||
|
||||
// TODO: Add functions to store, load, update and delete these
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue