🗑️ Remove account
This commit is contained in:
@ -2,6 +2,8 @@ package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/gap"
|
||||
"git.solsynth.dev/hypernet/passport/pkg/authkit"
|
||||
"github.com/spf13/viper"
|
||||
"gorm.io/datatypes"
|
||||
"strings"
|
||||
@ -53,12 +55,9 @@ func listAttachment(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
if len(c.Query("author")) > 0 {
|
||||
var author models.Account
|
||||
if err := database.C.Where("name = ?", c.Query("author")).First(&author).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
} else {
|
||||
prefix := viper.GetString("database.prefix")
|
||||
tx = tx.Where(fmt.Sprintf("%sattachments.account_id = ?", prefix), author.ID)
|
||||
author, err := authkit.GetUserByName(gap.Nx, c.Query("author"))
|
||||
if err == nil {
|
||||
tx = tx.Where("attachments.account_id = ?", author.ID)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,11 @@ package api
|
||||
import (
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
|
||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/gap"
|
||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/models"
|
||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/server/exts"
|
||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/services"
|
||||
"git.solsynth.dev/hypernet/passport/pkg/authkit"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@ -20,10 +22,8 @@ func listStickerPacks(c *fiber.Ctx) error {
|
||||
tx := database.C
|
||||
|
||||
if len(c.Query("author")) > 0 {
|
||||
var author models.Account
|
||||
if err := database.C.Where("name = ?", c.Query("author")).First(&author).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
} else {
|
||||
author, err := authkit.GetUserByName(gap.Nx, c.Query("author"))
|
||||
if err == nil {
|
||||
tx = tx.Where("account_id = ?", author.ID)
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package api
|
||||
import (
|
||||
"fmt"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/gap"
|
||||
"git.solsynth.dev/hypernet/passport/pkg/authkit"
|
||||
"strings"
|
||||
|
||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
|
||||
@ -41,10 +43,8 @@ func listStickers(c *fiber.Ctx) error {
|
||||
tx := database.C
|
||||
|
||||
if len(c.Query("author")) > 0 {
|
||||
var author models.Account
|
||||
if err := database.C.Where("name = ?", c.Query("author")).First(&author).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
} else {
|
||||
author, err := authkit.GetUserByName(gap.Nx, c.Query("author"))
|
||||
if err == nil {
|
||||
tx = tx.Where("account_id = ?", author.ID)
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ func createAttachmentDirectly(c *fiber.Ctx) error {
|
||||
|
||||
tx.Commit()
|
||||
|
||||
metadata.Account = models.Account{UserInfo: user}
|
||||
metadata.Pool = &pool
|
||||
services.PublishAnalyzeTask(metadata)
|
||||
|
||||
|
Reference in New Issue
Block a user