🐛 Fix metadata missing author info

This commit is contained in:
2024-08-02 21:38:47 +08:00
parent 03f08f1ff6
commit a696b13837
4 changed files with 8 additions and 14 deletions

View File

@@ -80,11 +80,11 @@ func getAttachmentMeta(c *fiber.Ctx) error {
}
func createAttachment(c *fiber.Ctx) error {
var user *models.Account
var user models.Account
if err := gap.H.EnsureAuthenticated(c); err != nil {
return err
}
user = lo.ToPtr(c.Locals("user").(models.Account))
user = c.Locals("user").(models.Account)
usage := c.FormValue("usage")
if !lo.Contains(viper.GetStringSlice("accepts_usage"), usage) {
@@ -126,6 +126,7 @@ func createAttachment(c *fiber.Ctx) error {
tx.Commit()
metadata.Account = user
services.PublishAnalyzeTask(metadata)
return c.JSON(metadata)

View File

@@ -48,7 +48,7 @@ func GetAttachmentByHash(hash string) (models.Attachment, error) {
return attachment, nil
}
func NewAttachmentMetadata(tx *gorm.DB, user *models.Account, file *multipart.FileHeader, attachment models.Attachment) (models.Attachment, error) {
func NewAttachmentMetadata(tx *gorm.DB, user models.Account, file *multipart.FileHeader, attachment models.Attachment) (models.Attachment, error) {
attachment.Uuid = uuid.NewString()
attachment.Size = file.Size
attachment.Name = file.Filename