Migrate shroom

This commit is contained in:
Timur Ismagilov 2024-09-07 22:58:59 +03:00
parent 72f7d5d1c1
commit 72b079cc2e
2 changed files with 22 additions and 7 deletions

View File

@ -1,21 +1,36 @@
package shroom
import (
"log"
"log/slog"
"github.com/bouncepaw/mycorrhiza/internal/hyphae"
"github.com/bouncepaw/mycorrhiza/internal/user"
)
func rejectRenameLog(h hyphae.Hypha, u *user.User, errmsg string) {
log.Printf("Reject rename %s by @%s: %s\n", h.CanonicalName(), u.Name, errmsg)
slog.Info("Reject rename",
"hyphaName", h.CanonicalName(),
"username", u.Name,
"errmsg", errmsg)
}
func rejectRemoveMediaLog(h hyphae.Hypha, u *user.User, errmsg string) {
log.Printf("Reject remove media %s by @%s: %s\n", h.CanonicalName(), u.Name, errmsg)
slog.Info("Reject remove media",
"hyphaName", h.CanonicalName(),
"username", u.Name,
"errmsg", errmsg)
}
func rejectEditLog(h hyphae.Hypha, u *user.User, errmsg string) {
log.Printf("Reject edit %s by @%s: %s\n", h.CanonicalName(), u.Name, errmsg)
slog.Info("Reject edit",
"hyphaName", h.CanonicalName(),
"username", u.Name,
"errmsg", errmsg)
}
func rejectUploadMediaLog(h hyphae.Hypha, u *user.User, errmsg string) {
log.Printf("Reject upload media %s by @%s: %s\n", h.CanonicalName(), u.Name, errmsg)
slog.Info("Reject upload media",
"hyphaName", h.CanonicalName(),
"username", u.Name,
"errmsg", errmsg)
}

View File

@ -5,7 +5,7 @@ import (
"errors"
"fmt"
"io"
"log"
"log/slog"
"mime/multipart"
"os"
"path/filepath"
@ -201,7 +201,7 @@ func UploadBinary(h hyphae.Hypha, mime string, file multipart.File, u *user.User
if err := history.Rename(prevFilePath, uploadedFilePath); err != nil {
return err
}
log.Printf("Move %s to %s\n", prevFilePath, uploadedFilePath)
slog.Info("Move file", "from", prevFilePath, "to", uploadedFilePath)
h.SetMediaFilePath(uploadedFilePath)
}
}