From 3f73b3c66de04a55bc101ffb96070ae19e7bf27a Mon Sep 17 00:00:00 2001 From: Bobby Date: Sat, 19 Jul 2025 17:06:56 +0530 Subject: tag adding feature for images --- controllers/posts.go | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'controllers/posts.go') diff --git a/controllers/posts.go b/controllers/posts.go index 57738b5..da2df95 100644 --- a/controllers/posts.go +++ b/controllers/posts.go @@ -4,7 +4,6 @@ import ( "errors" "imageboard/config" "imageboard/database" - "imageboard/models" "imageboard/utils/auth" "imageboard/utils/format" "imageboard/utils/handlers" @@ -380,22 +379,9 @@ func PostsSinglePostEditPageController(ctx *fiber.Ctx) error { return InternalServerErrorController(ctx, err) } - postTags := make([]map[string]models.Tag, 0, len(post.Tags)) - for _, tag := range post.Tags { - switch tag.Type { - case config.TagTypeGeneral: - postTags = append(postTags, map[string]models.Tag{"general": tag}) - case config.TagTypeArtist: - postTags = append(postTags, map[string]models.Tag{"artist": tag}) - case config.TagTypeCharacter: - postTags = append(postTags, map[string]models.Tag{"character": tag}) - case config.TagTypeCopyright: - postTags = append(postTags, map[string]models.Tag{"copyright": tag}) - case config.TagTypeMeta: - postTags = append(postTags, map[string]models.Tag{"meta": tag}) - default: - postTags = append(postTags, map[string]models.Tag{"general": tag}) - } + postTags, err := database.GetImageTags(post.ID) + if err != nil { + return InternalServerErrorController(ctx, err) } ctx.Locals("Title", config.PT_POST_EDIT+" #"+format.Int64ToString(int64(post.ID))) @@ -511,6 +497,5 @@ func PostsSinglePostEditPostController(ctx *fiber.Ctx) error { if nextURL == "" { nextURL = "/posts/" + format.Int64ToString(int64(post.ID)) } - return ctx.Redirect(nextURL, fiber.StatusSeeOther) } -- cgit v1.2.3