More work on the API. Primarely defining jsonapi types

This commit is contained in:
Melody Becker 2024-10-30 16:05:20 +01:00
parent 4f4d05a335
commit 0ed50aca60
13 changed files with 165 additions and 48 deletions

View file

@ -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
}