Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix: delete tag (#1062)
boojackb366ce7594dc
diff --git a/api/tag.go b/api/tag.goindex 50e6b5ed1..8202688ab 100644--- a/api/tag.go+++ b/api/tag.go@@ -15,6 +15,6 @@ type TagFind struct {}type TagDelete struct {- Name string+ Name string `json:"name"`CreatorID int}diff --git a/server/tag.go b/server/tag.goindex 1d1395010..d63f6ecd8 100644--- a/server/tag.go+++ b/server/tag.go@@ -4,7 +4,6 @@ import ("encoding/json""fmt""net/http"- "net/url""regexp""sort"@@ -127,29 +126,27 @@ func (s *Server) registerTagRoutes(g *echo.Group) {return nil})- g.DELETE("/tag/:tagName", func(c echo.Context) error {+ g.POST("/tag/delete", func(c echo.Context) error {ctx := c.Request().Context()userID, ok := c.Get(getUserIDContextKey()).(int)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}- tagName, err := url.QueryUnescape(c.Param("tagName"))- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Invalid tag name").SetInternal(err)- } else if tagName == "" {- return echo.NewHTTPError(http.StatusBadRequest, "Tag name cannot be empty")+ tagDelete := &api.TagDelete{}+ if err := json.NewDecoder(c.Request().Body).Decode(tagDelete); err != nil {+ return echo.NewHTTPError(http.StatusBadRequest, "Malformatted post tag request").SetInternal(err)}-- tagDelete := &api.TagDelete{- Name: tagName,- CreatorID: userID,+ if tagDelete.Name == "" {+ return echo.NewHTTPError(http.StatusBadRequest, "Tag name shouldn't be empty")}++ tagDelete.CreatorID = userIDif err := s.Store.DeleteTag(ctx, tagDelete); err != nil {if common.ErrorCode(err) == common.NotFound {- return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Tag name not found: %s", tagName))+ return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Tag name not found: %s", tagDelete.Name))}- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to delete tag name: %v", tagName)).SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to delete tag name: %v", tagDelete.Name)).SetInternal(err)}return c.JSON(http.StatusOK, true)diff --git a/web/src/helpers/api.ts b/web/src/helpers/api.tsindex f347de17e..6c6a8eb85 100644--- a/web/src/helpers/api.ts+++ b/web/src/helpers/api.ts@@ -202,7 +202,9 @@ export function upsertTag(tagName: string) {}export function deleteTag(tagName: string) {- return axios.delete<ResponseObject<string>>(`/api/tag/${encodeURIComponent(tagName)}`);+ return axios.post<ResponseObject<boolean>>(`/api/tag/delete`, {+ name: tagName,+ });}export async function getRepoStarCount() {