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
feat: add support for content search (#1728)
Athurg Gooth4ea5426e185c
diff --git a/api/memo.go b/api/memo.goindex b93f9641a..579d65ee4 100644--- a/api/memo.go+++ b/api/memo.go@@ -84,7 +84,7 @@ type FindMemoRequest struct {// Domain specific fieldsPinned *bool- ContentSearch *string+ ContentSearch []stringVisibilityList []Visibility// Paginationdiff --git a/server/memo.go b/server/memo.goindex f6cbe6150..41fc763f7 100644--- a/server/memo.go+++ b/server/memo.go@@ -272,11 +272,18 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {pinned := pinnedStr == "true"findMemoMessage.Pinned = &pinned}++ contentSearch := []string{}tag := c.QueryParam("tag")if tag != "" {- contentSearch := "#" + tag- findMemoMessage.ContentSearch = &contentSearch+ contentSearch = append(contentSearch, "#"+tag)+ }+ contentSlice := c.QueryParams()["content"]+ if len(contentSlice) > 0 {+ contentSearch = append(contentSearch, contentSlice...)}+ findMemoMessage.ContentSearch = contentSearch+visibilityListStr := c.QueryParam("visibility")if visibilityListStr != "" {visibilityList := []store.Visibility{}@@ -431,11 +438,18 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {pinned := pinnedStr == "true"findMemoMessage.Pinned = &pinned}++ contentSearch := []string{}tag := c.QueryParam("tag")if tag != "" {- contentSearch := "#" + tag + " "- findMemoMessage.ContentSearch = &contentSearch+ contentSearch = append(contentSearch, "#"+tag+" ")+ }+ contentSlice := c.QueryParams()["content"]+ if len(contentSlice) > 0 {+ contentSearch = append(contentSearch, contentSlice...)}+ findMemoMessage.ContentSearch = contentSearch+visibilityListStr := c.QueryParam("visibility")if visibilityListStr != "" {visibilityList := []store.Visibility{}diff --git a/server/tag.go b/server/tag.goindex 82722370e..efd8b0dc7 100644--- a/server/tag.go+++ b/server/tag.go@@ -71,11 +71,10 @@ func (s *Server) registerTagRoutes(g *echo.Group) {if !ok {return echo.NewHTTPError(http.StatusBadRequest, "Missing user session")}- contentSearch := "#"normalRowStatus := store.NormalmemoFind := &store.FindMemoMessage{CreatorID: &userID,- ContentSearch: &contentSearch,+ ContentSearch: []string{"#"},RowStatus: &normalRowStatus,}diff --git a/store/memo.go b/store/memo.goindex 205a0b12d..e9abe4a1a 100644--- a/store/memo.go+++ b/store/memo.go@@ -62,7 +62,7 @@ type FindMemoMessage struct {// Domain specific fieldsPinned *bool- ContentSearch *string+ ContentSearch []stringVisibilityList []Visibility// Pagination@@ -233,8 +233,10 @@ func listMemos(ctx context.Context, tx *sql.Tx, find *FindMemoMessage) ([]*MemoMif v := find.Pinned; v != nil {where = append(where, "memo_organizer.pinned = 1")}- if v := find.ContentSearch; v != nil {- where, args = append(where, "memo.content LIKE ?"), append(args, "%"+*v+"%")+ if v := find.ContentSearch; len(v) != 0 {+ for _, s := range v {+ where, args = append(where, "memo.content LIKE ?"), append(args, "%"+s+"%")+ }}if v := find.VisibilityList; len(v) != 0 {list := []string{}