Work on AP-ing media and extending likes and whatnot
All checks were successful
/ docker (push) Successful in 1m56s
All checks were successful
/ docker (push) Successful in 1m56s
Also added two fields to roles model, but haven't ran the various generators yet
This commit is contained in:
parent
1fcf47bffc
commit
81a01fbf8b
10 changed files with 59 additions and 4 deletions
|
@ -177,6 +177,12 @@ func importRemoteNoteRecursive(
|
|||
// In which case, you need to remove tags that don't exist anymore
|
||||
// and only create the ones not yet stored
|
||||
err = dbgen.NoteToPing.Save(pings...)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
err = dbgen.NoteTag.Save(hashtags...)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return dbNote.ID, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package translators
|
|||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/config"
|
||||
"git.mstar.dev/mstar/linstrom/storage-new/dbgen"
|
||||
)
|
||||
|
||||
|
@ -10,17 +12,39 @@ type Media struct {
|
|||
Type string `json:"type"`
|
||||
Url string `json:"url"`
|
||||
MediaType string `json:"mediaType"`
|
||||
Name string `json:"name"`
|
||||
Summary string `json:"summary"`
|
||||
Sensitive bool `json:"sensitive"`
|
||||
}
|
||||
|
||||
func MediaFromStorage(ctx context.Context, id string) (*Media, error) {
|
||||
metadata, err := dbgen.MediaMetadata.Where(dbgen.MediaMetadata.ID.Eq(id)).First()
|
||||
metadata, err := dbgen.MediaMetadata.Where(dbgen.MediaMetadata.ID.Eq(id), dbgen.MediaMetadata.Remote.Is(false)).
|
||||
First()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data := Media{
|
||||
Type: "Image", // FIXME: Change this to a sort of dynamic detection based on mimetype
|
||||
MediaType: metadata.Type,
|
||||
Url: metadata.Location,
|
||||
Url: config.GlobalConfig.General.GetFullPublicUrl() + "/media/" + id,
|
||||
Name: metadata.AltText,
|
||||
Summary: metadata.AltText,
|
||||
Sensitive: metadata.Blurred,
|
||||
}
|
||||
switch strings.SplitN(metadata.Type, "/", 2)[0] {
|
||||
case "audio":
|
||||
data.Type = "Audio"
|
||||
case "application":
|
||||
data.Type = "Document"
|
||||
case "image":
|
||||
data.Type = "Image"
|
||||
case "video":
|
||||
data.Type = "Video"
|
||||
case "text":
|
||||
data.Type = "Document"
|
||||
case "font":
|
||||
data.Type = "Document"
|
||||
default:
|
||||
data.Type = "Document"
|
||||
}
|
||||
return &data, nil
|
||||
}
|
||||
|
|
|
@ -51,6 +51,9 @@ func UserFromStorage(ctx context.Context, id string) (*User, error) {
|
|||
Preload(dbgen.User.Icon).Preload(dbgen.User.Banner).
|
||||
Preload(dbgen.User.BeingTypes).
|
||||
First()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = storage.EnsureLocalUserIdHasLinks(id)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue