fix: get all memo api (#2091)

This commit is contained in:
boojack 2023-08-06 10:14:30 +08:00 committed by GitHub
parent e097e8331e
commit 5d5d8de9fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -531,30 +531,13 @@ func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {
g.GET("/memo/all", func(c echo.Context) error { g.GET("/memo/all", func(c echo.Context) error {
ctx := c.Request().Context() ctx := c.Request().Context()
findMemoMessage := &store.FindMemo{} findMemoMessage := &store.FindMemo{}
_, ok := c.Get(auth.UserIDContextKey).(int) _, ok := c.Get(auth.UserIDContextKey).(int32)
if !ok { if !ok {
findMemoMessage.VisibilityList = []store.Visibility{store.Public} findMemoMessage.VisibilityList = []store.Visibility{store.Public}
} else { } else {
findMemoMessage.VisibilityList = []store.Visibility{store.Public, store.Protected} findMemoMessage.VisibilityList = []store.Visibility{store.Public, store.Protected}
} }
pinnedStr := c.QueryParam("pinned")
if pinnedStr != "" {
pinned := pinnedStr == "true"
findMemoMessage.Pinned = &pinned
}
contentSearch := []string{}
tag := c.QueryParam("tag")
if tag != "" {
contentSearch = append(contentSearch, "#"+tag+" ")
}
contentSlice := c.QueryParams()["content"]
if len(contentSlice) > 0 {
contentSearch = append(contentSearch, contentSlice...)
}
findMemoMessage.ContentSearch = contentSearch
if limit, err := strconv.Atoi(c.QueryParam("limit")); err == nil { if limit, err := strconv.Atoi(c.QueryParam("limit")); err == nil {
findMemoMessage.Limit = &limit findMemoMessage.Limit = &limit
} }