diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e3a0853..116194d 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,10 @@
-
+
+
+
+
@@ -33,27 +36,27 @@
- {
+ "keyToString": {
+ "DefaultGoTemplateProperty": "Go File",
+ "Go Build.Backend.executor": "Run",
+ "Go 构建.Backend.executor": "Run",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.go.formatter.settings.were.checked": "true",
+ "RunOnceActivity.go.migrated.go.modules.settings": "true",
+ "RunOnceActivity.go.modules.automatic.dependencies.download": "true",
+ "RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
+ "git-widget-placeholder": "master",
+ "go.import.settings.migrated": "true",
+ "go.sdk.automatically.set": "true",
+ "last_opened_file_path": "/Users/littlesheep/Documents/Projects/Hydrogen/Paperclip/pkg/internal/grpc",
+ "node.js.detected.package.eslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "run.code.analysis.last.selected.profile": "pProject Default",
+ "settings.editor.selected.configurable": "preferences.lookFeel"
}
-}]]>
+}
diff --git a/pkg/internal/server/api/attachments_api.go b/pkg/internal/server/api/attachments_api.go
index ef24643..228e626 100644
--- a/pkg/internal/server/api/attachments_api.go
+++ b/pkg/internal/server/api/attachments_api.go
@@ -72,6 +72,9 @@ func getAttachmentMeta(c *fiber.Ctx) error {
}
func createAttachment(c *fiber.Ctx) error {
+ if err := gap.H.EnsureAuthenticated(c); err != nil {
+ return err
+ }
user := c.Locals("user").(models.Account)
destName := c.Query("destination", viper.GetString("preferred_destination"))
@@ -126,11 +129,11 @@ func createAttachment(c *fiber.Ctx) error {
func updateAttachmentMeta(c *fiber.Ctx) error {
id, _ := c.ParamsInt("id", 0)
- user := c.Locals("user").(models.Account)
if err := gap.H.EnsureAuthenticated(c); err != nil {
return err
}
+ user := c.Locals("user").(models.Account)
var data struct {
Alternative string `json:"alt"`
@@ -165,11 +168,11 @@ func updateAttachmentMeta(c *fiber.Ctx) error {
func deleteAttachment(c *fiber.Ctx) error {
id, _ := c.ParamsInt("id", 0)
- user := c.Locals("user").(models.Account)
if err := gap.H.EnsureAuthenticated(c); err != nil {
return err
}
+ user := c.Locals("user").(models.Account)
attachment, err := services.GetAttachmentByID(uint(id))
if err != nil {