🗑️ Remove account
This commit is contained in:
parent
94b777a3e4
commit
2d119826fe
@ -6,29 +6,19 @@
|
|||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":recycle: Migrated to nexus">
|
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":recycle: Migrated to nexus">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/database/migrator.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/migrator.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/database/migrator.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/migrator.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/database/source.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/source.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/database/source.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/source.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/services.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/services.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/services.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/services.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/attachments_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/attachments_api.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/models/accounts.go" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/internal/models/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/attachments.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/internal/models/pools.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/pools.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/internal/models/stickers.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/stickers.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/index_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/index_api.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/index_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/index_api.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/pools_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/pools_api.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/sticker_packs_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/sticker_packs_api.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/sticker_packs_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/sticker_packs_api.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/stickers_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/stickers_api.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/stickers_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/stickers_api.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/up_direct_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/up_direct_api.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/up_multipart_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/up_multipart_api.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/server/server.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/server.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/attachments.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/services/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/attachments.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/cleaner.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/cleaner.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/merger.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/merger.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/pools.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/pools.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/recycler.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/recycler.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/sticker_packs.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/sticker_packs.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/stickers.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/stickers.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/uploader.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/uploader.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/main.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/main.go" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@ -64,33 +54,33 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"DefaultGoTemplateProperty": "Go File",
|
"DefaultGoTemplateProperty": "Go File",
|
||||||
"Go Build.Backend.executor": "Run",
|
"Go Build.Backend.executor": "Run",
|
||||||
"Go 构建.Backend.executor": "Run",
|
"Go 构建.Backend.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.go.formatter.settings.were.checked": "true",
|
"RunOnceActivity.go.formatter.settings.were.checked": "true",
|
||||||
"RunOnceActivity.go.migrated.go.modules.settings": "true",
|
"RunOnceActivity.go.migrated.go.modules.settings": "true",
|
||||||
"RunOnceActivity.go.modules.automatic.dependencies.download": "true",
|
"RunOnceActivity.go.modules.automatic.dependencies.download": "true",
|
||||||
"RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
|
"RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
|
||||||
"git-widget-placeholder": "refactor/nexus",
|
"git-widget-placeholder": "master",
|
||||||
"go.import.settings.migrated": "true",
|
"go.import.settings.migrated": "true",
|
||||||
"go.sdk.automatically.set": "true",
|
"go.sdk.automatically.set": "true",
|
||||||
"last_opened_file_path": "/Users/littlesheep/Documents/Projects/Hydrogen/Paperclip/pkg/internal/gap",
|
"last_opened_file_path": "/Users/littlesheep/Documents/Projects/Hypernet/Paperclip",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"run.code.analysis.last.selected.profile": "pProject Default",
|
"run.code.analysis.last.selected.profile": "pProject Default",
|
||||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
},
|
},
|
||||||
"keyToStringList": {
|
"keyToStringList": {
|
||||||
"DatabaseDriversLRU": [
|
"DatabaseDriversLRU": [
|
||||||
"postgresql"
|
"postgresql"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}</component>
|
}]]></component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="$PROJECT_DIR$/pkg/internal/gap" />
|
<recent name="$PROJECT_DIR$/pkg/internal/gap" />
|
||||||
|
8
go.mod
8
go.mod
@ -1,11 +1,10 @@
|
|||||||
module git.solsynth.dev/hypernet/paperclip
|
module git.solsynth.dev/hypernet/paperclip
|
||||||
|
|
||||||
go 1.22.0
|
go 1.23.2
|
||||||
|
|
||||||
toolchain go1.23.2
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.solsynth.dev/hypernet/nexus v0.0.0-20241031133156-6bb8eab3fcd8
|
git.solsynth.dev/hypernet/nexus v0.0.0-20241102174036-194d27090415
|
||||||
|
git.solsynth.dev/hypernet/passport v0.0.0-20241102174750-808e7998dd1c
|
||||||
github.com/barasher/go-exiftool v1.10.0
|
github.com/barasher/go-exiftool v1.10.0
|
||||||
github.com/dgraph-io/ristretto v0.1.1
|
github.com/dgraph-io/ristretto v0.1.1
|
||||||
github.com/eko/gocache/lib/v4 v4.1.6
|
github.com/eko/gocache/lib/v4 v4.1.6
|
||||||
@ -31,6 +30,7 @@ require (
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
|
git.solsynth.dev/hypernet/pusher v0.0.0-20241026153052-cd2c326efa4e // indirect
|
||||||
github.com/andybalholm/brotli v1.1.1 // indirect
|
github.com/andybalholm/brotli v1.1.1 // indirect
|
||||||
github.com/armon/go-metrics v0.4.1 // indirect
|
github.com/armon/go-metrics v0.4.1 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
|
10
go.sum
10
go.sum
@ -33,10 +33,12 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
|||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||||
git.solsynth.dev/hypernet/nexus v0.0.0-20241027051235-ae3583ead196 h1:vTT1Vhz9OJHUh+D07AUFO3jjm3p8/dRo194REny0Wk4=
|
git.solsynth.dev/hypernet/nexus v0.0.0-20241102174036-194d27090415 h1:7K6rv7fLgT1KQptFHJPp6+fHITLdl3Or3uT7cl8fnOM=
|
||||||
git.solsynth.dev/hypernet/nexus v0.0.0-20241027051235-ae3583ead196/go.mod h1:fXQsHXGio+7/0U95IitKF07wS4yTdCMp5ms8wpFBwVI=
|
git.solsynth.dev/hypernet/nexus v0.0.0-20241102174036-194d27090415/go.mod h1:fXQsHXGio+7/0U95IitKF07wS4yTdCMp5ms8wpFBwVI=
|
||||||
git.solsynth.dev/hypernet/nexus v0.0.0-20241031133156-6bb8eab3fcd8 h1:fo9WuAXcmxdGfYXZKTiAbqGLHAkeL7vf0zpwbjoUNc0=
|
git.solsynth.dev/hypernet/passport v0.0.0-20241102174750-808e7998dd1c h1:RVY0xsYGpb22ZuITxS+xpFu76XpPDrOpbIuSMDjW1+Q=
|
||||||
git.solsynth.dev/hypernet/nexus v0.0.0-20241031133156-6bb8eab3fcd8/go.mod h1:fXQsHXGio+7/0U95IitKF07wS4yTdCMp5ms8wpFBwVI=
|
git.solsynth.dev/hypernet/passport v0.0.0-20241102174750-808e7998dd1c/go.mod h1:Gj8uWVKUeUxU3Z6v1sYLGHB79ln1nubQ5XfsJVUcvWM=
|
||||||
|
git.solsynth.dev/hypernet/pusher v0.0.0-20241026153052-cd2c326efa4e h1:DtHhMjgxS/spUt/KEdbRFtaVnepI6Vx8pbHdJaNH1hs=
|
||||||
|
git.solsynth.dev/hypernet/pusher v0.0.0-20241026153052-cd2c326efa4e/go.mod h1:XHTqFU/vBe4JiuAjl87GUcL8+w/IizSNoqH6n3WkQFc=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var AutoMaintainRange = []any{
|
var AutoMaintainRange = []any{
|
||||||
&models.Account{},
|
|
||||||
&models.AttachmentPool{},
|
&models.AttachmentPool{},
|
||||||
&models.Attachment{},
|
&models.Attachment{},
|
||||||
&models.StickerPack{},
|
&models.StickerPack{},
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
var C *gorm.DB
|
var C *gorm.DB
|
||||||
|
|
||||||
func NewSource() error {
|
func NewGorm() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
dsn, err := cruda.NewCrudaConn(gap.Nx).AllocDatabase("paperclip")
|
dsn, err := cruda.NewCrudaConn(gap.Nx).AllocDatabase("paperclip")
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
"git.solsynth.dev/hypernet/nexus/pkg/proto"
|
"git.solsynth.dev/hypernet/nexus/pkg/proto"
|
||||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
|
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
|
||||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (v *Server) BroadcastEvent(ctx context.Context, in *proto.EventInfo) (*proto.EventResponse, error) {
|
func (v *Server) BroadcastEvent(ctx context.Context, in *proto.EventInfo) (*proto.EventResponse, error) {
|
||||||
@ -35,10 +34,6 @@ func (v *Server) BroadcastEvent(ctx context.Context, in *proto.EventInfo) (*prot
|
|||||||
tx.Delete(model, "account_id = ?", numericId)
|
tx.Delete(model, "account_id = ?", numericId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if tx.Delete(&models.Account{}, "id = ?", numericId).Error != nil {
|
|
||||||
tx.Rollback()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
import "git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
|
||||||
|
|
||||||
type Account struct {
|
|
||||||
sec.UserInfo
|
|
||||||
|
|
||||||
Attachments []Attachment `json:"attachments"`
|
|
||||||
Pools []AttachmentPool `json:"pools"`
|
|
||||||
}
|
|
@ -46,6 +46,5 @@ type Attachment struct {
|
|||||||
Pool *AttachmentPool `json:"pool"`
|
Pool *AttachmentPool `json:"pool"`
|
||||||
PoolID *uint `json:"pool_id"`
|
PoolID *uint `json:"pool_id"`
|
||||||
|
|
||||||
Account Account `json:"account"`
|
AccountID uint `json:"account_id"`
|
||||||
AccountID uint `json:"account_id"`
|
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,7 @@ type AttachmentPool struct {
|
|||||||
|
|
||||||
Attachments []Attachment `json:"attachments" gorm:"foreignKey:PoolID"`
|
Attachments []Attachment `json:"attachments" gorm:"foreignKey:PoolID"`
|
||||||
|
|
||||||
Account *Account `json:"account"`
|
AccountID *uint `json:"account_id"`
|
||||||
AccountID *uint `json:"account_id"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type AttachmentPoolConfig struct {
|
type AttachmentPoolConfig struct {
|
||||||
|
@ -14,7 +14,6 @@ type Sticker struct {
|
|||||||
PackID uint `json:"pack_id"`
|
PackID uint `json:"pack_id"`
|
||||||
Pack StickerPack `json:"pack"`
|
Pack StickerPack `json:"pack"`
|
||||||
AccountID uint `json:"account_id"`
|
AccountID uint `json:"account_id"`
|
||||||
Account Account `json:"account"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type StickerPack struct {
|
type StickerPack struct {
|
||||||
@ -25,5 +24,4 @@ type StickerPack struct {
|
|||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Stickers []Sticker `json:"stickers" gorm:"foreignKey:PackID;constraint:OnDelete:CASCADE"`
|
Stickers []Sticker `json:"stickers" gorm:"foreignKey:PackID;constraint:OnDelete:CASCADE"`
|
||||||
AccountID uint `json:"account_id"`
|
AccountID uint `json:"account_id"`
|
||||||
Account Account `json:"account"`
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.solsynth.dev/hypernet/paperclip/pkg/internal/gap"
|
||||||
|
"git.solsynth.dev/hypernet/passport/pkg/authkit"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"gorm.io/datatypes"
|
"gorm.io/datatypes"
|
||||||
"strings"
|
"strings"
|
||||||
@ -53,12 +55,9 @@ func listAttachment(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(c.Query("author")) > 0 {
|
if len(c.Query("author")) > 0 {
|
||||||
var author models.Account
|
author, err := authkit.GetUserByName(gap.Nx, c.Query("author"))
|
||||||
if err := database.C.Where("name = ?", c.Query("author")).First(&author).Error; err != nil {
|
if err == nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
tx = tx.Where("attachments.account_id = ?", author.ID)
|
||||||
} else {
|
|
||||||
prefix := viper.GetString("database.prefix")
|
|
||||||
tx = tx.Where(fmt.Sprintf("%sattachments.account_id = ?", prefix), author.ID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,9 +3,11 @@ package api
|
|||||||
import (
|
import (
|
||||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
|
"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/models"
|
||||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/server/exts"
|
"git.solsynth.dev/hypernet/paperclip/pkg/internal/server/exts"
|
||||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/services"
|
"git.solsynth.dev/hypernet/paperclip/pkg/internal/services"
|
||||||
|
"git.solsynth.dev/hypernet/passport/pkg/authkit"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,10 +22,8 @@ func listStickerPacks(c *fiber.Ctx) error {
|
|||||||
tx := database.C
|
tx := database.C
|
||||||
|
|
||||||
if len(c.Query("author")) > 0 {
|
if len(c.Query("author")) > 0 {
|
||||||
var author models.Account
|
author, err := authkit.GetUserByName(gap.Nx, c.Query("author"))
|
||||||
if err := database.C.Where("name = ?", c.Query("author")).First(&author).Error; err != nil {
|
if err == nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
} else {
|
|
||||||
tx = tx.Where("account_id = ?", author.ID)
|
tx = tx.Where("account_id = ?", author.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package api
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||||
|
"git.solsynth.dev/hypernet/paperclip/pkg/internal/gap"
|
||||||
|
"git.solsynth.dev/hypernet/passport/pkg/authkit"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
|
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
|
||||||
@ -41,10 +43,8 @@ func listStickers(c *fiber.Ctx) error {
|
|||||||
tx := database.C
|
tx := database.C
|
||||||
|
|
||||||
if len(c.Query("author")) > 0 {
|
if len(c.Query("author")) > 0 {
|
||||||
var author models.Account
|
author, err := authkit.GetUserByName(gap.Nx, c.Query("author"))
|
||||||
if err := database.C.Where("name = ?", c.Query("author")).First(&author).Error; err != nil {
|
if err == nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
} else {
|
|
||||||
tx = tx.Where("account_id = ?", author.ID)
|
tx = tx.Where("account_id = ?", author.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,6 @@ func createAttachmentDirectly(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
||||||
metadata.Account = models.Account{UserInfo: user}
|
|
||||||
metadata.Pool = &pool
|
metadata.Pool = &pool
|
||||||
services.PublishAnalyzeTask(metadata)
|
services.PublishAnalyzeTask(metadata)
|
||||||
|
|
||||||
|
@ -53,9 +53,7 @@ func GetAttachmentByRID(rid string) (models.Attachment, error) {
|
|||||||
GetAttachmentCacheKey(rid),
|
GetAttachmentCacheKey(rid),
|
||||||
new(models.Attachment),
|
new(models.Attachment),
|
||||||
); err == nil {
|
); err == nil {
|
||||||
if val.(models.Attachment).Account.ID > 0 {
|
return val.(models.Attachment), nil
|
||||||
return val.(models.Attachment), nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var attachment models.Attachment
|
var attachment models.Attachment
|
||||||
@ -90,9 +88,7 @@ func GetAttachmentCache(rid string) (models.Attachment, bool) {
|
|||||||
GetAttachmentCacheKey(rid),
|
GetAttachmentCacheKey(rid),
|
||||||
new(models.Attachment),
|
new(models.Attachment),
|
||||||
); err == nil {
|
); err == nil {
|
||||||
if val.(models.Attachment).Account.ID > 0 {
|
return val.(models.Attachment), true
|
||||||
return val.(models.Attachment), true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return models.Attachment{}, false
|
return models.Attachment{}, false
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Connect to database
|
// Connect to database
|
||||||
if err := database.NewSource(); err != nil {
|
if err := database.NewGorm(); err != nil {
|
||||||
log.Fatal().Err(err).Msg("An error occurred when connect to database.")
|
log.Fatal().Err(err).Msg("An error occurred when connect to database.")
|
||||||
} else if err := database.RunMigration(database.C); err != nil {
|
} else if err := database.RunMigration(database.C); err != nil {
|
||||||
log.Fatal().Err(err).Msg("An error occurred when running database auto migration.")
|
log.Fatal().Err(err).Msg("An error occurred when running database auto migration.")
|
||||||
|
Loading…
Reference in New Issue
Block a user