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
chore(go): use `json` instead of `jsonapi`
emaild6418f5ff9b1
diff --git a/api/auth.go b/api/auth.goindex 5e8bf3e69..504c8c0bc 100644--- a/api/auth.go+++ b/api/auth.go@@ -1,11 +1,11 @@package apitype Login struct {- Name string `jsonapi:"attr,name"`- Password string `jsonapi:"attr,password"`+ Name string `json:"name"`+ Password string `json:"password"`}type Signup struct {- Name string `jsonapi:"attr,name"`- Password string `jsonapi:"attr,password"`+ Name string `json:"name"`+ Password string `json:"password"`}diff --git a/api/memo.go b/api/memo.goindex c3950f6fe..19945404a 100644--- a/api/memo.go+++ b/api/memo.go@@ -1,17 +1,17 @@package apitype Memo struct {- Id int `jsonapi:"primary,memo"`- CreatedTs int64 `jsonapi:"attr,createdTs"`- UpdatedTs int64 `jsonapi:"attr,updatedTs"`- RowStatus string `jsonapi:"attr,rowStatus"`+ Id int `json:"id"`+ CreatedTs int64 `json:"createdTs"`+ UpdatedTs int64 `json:"updatedTs"`+ RowStatus string `json:"rowStatus"`- Content string `jsonapi:"attr,content"`- CreatorId int `jsonapi:"attr,creatorId"`+ Content string `json:"content"`+ CreatorId int `json:"creatorId"`}type MemoCreate struct {- Content string `jsonapi:"attr,content"`+ Content string `json:"content"`CreatorId int}@@ -28,7 +28,7 @@ type MemoFind struct {}type MemoDelete struct {- Id *int `jsonapi:"primary,memo"`+ Id *int `json:"id"`CreatorId *int}diff --git a/api/resource.go b/api/resource.goindex 19f8295f8..da6a4a444 100644--- a/api/resource.go+++ b/api/resource.go@@ -1,31 +1,31 @@package apitype Resource struct {- Id int `jsonapi:"primary,resource"`- CreatedTs int64 `jsonapi:"attr,createdTs"`- UpdatedTs int64 `jsonapi:"attr,updatedTs"`+ Id int `json:"id"`+ CreatedTs int64 `json:"createdTs"`+ UpdatedTs int64 `json:"updatedTs"`- Filename string `jsonapi:"attr,filename"`- Blob []byte `jsonapi:"attr,blob"`- Type string `jsonapi:"attr,type"`- Size int64 `jsonapi:"attr,size"`+ Filename string `json:"filename"`+ Blob []byte `json:"blob"`+ Type string `json:"type"`+ Size int64 `json:"size"`- CreatorId int `jsonapi:"attr,creatorId"`+ CreatorId int `json:"creatorId"`}type ResourceCreate struct {- Filename string `jsonapi:"attr,filename"`- Blob []byte `jsonapi:"attr,blob"`- Type string `jsonapi:"attr,type"`- Size int64 `jsonapi:"attr,size"`+ Filename string `json:"filename"`+ Blob []byte `json:"blob"`+ Type string `json:"type"`+ Size int64 `json:"size"`- CreatorId int `jsonapi:"attr,creatorId"`+ CreatorId int}type ResourceFind struct {- Id *int- CreatorId *int- Filename *string+ Id *int `json:"id"`+ CreatorId *int `json:"creatorId"`+ Filename *string `json:"filename"`}type ResourceDelete struct {diff --git a/api/shortcut.go b/api/shortcut.goindex b200da9cb..b240dc3e5 100644--- a/api/shortcut.go+++ b/api/shortcut.go@@ -1,13 +1,13 @@package apitype Shortcut struct {- Id int `jsonapi:"primary,shortcut"`- CreatedTs int64 `jsonapi:"attr,createdTs"`- UpdatedTs int64 `jsonapi:"attr,updatedTs"`+ Id int `json:"id"`+ CreatedTs int64 `json:"createdTs"`+ UpdatedTs int64 `json:"updatedTs"`- Title string `jsonapi:"attr,title"`- Payload string `jsonapi:"attr,payload"`- PinnedTs int64 `jsonapi:"attr,pinnedTs"`+ Title string `json:"title"`+ Payload string `json:"payload"`+ RowStatus string `json:"rowStatus"`CreatorId int}@@ -16,18 +16,16 @@ type ShortcutCreate struct {CreatorId int// Domain specific fields- Title string `jsonapi:"attr,title"`- Payload string `jsonapi:"attr,payload"`+ Title string `json:"title"`+ Payload string `json:"payload"`}type ShortcutPatch struct {Id int- Title *string `jsonapi:"attr,title"`- Payload *string `jsonapi:"attr,payload"`- PinnedTs *int64-- Pinned *bool `jsonapi:"attr,pinned"`+ Title *string `json:"title"`+ Payload *string `json:"payload"`+ RowStatus *string `json:"rowStatus"`}type ShortcutFind struct {@@ -37,7 +35,7 @@ type ShortcutFind struct {CreatorId *int// Domain specific fields- Title *string `jsonapi:"attr,title"`+ Title *string `json:"title"`}type ShortcutDelete struct {diff --git a/api/user.go b/api/user.goindex 800421178..4ba9169c7 100644--- a/api/user.go+++ b/api/user.go@@ -1,19 +1,19 @@package apitype User struct {- Id int `jsonapi:"primary,user"`- CreatedTs int64 `jsonapi:"attr,createdTs"`- UpdatedTs int64 `jsonapi:"attr,updatedTs"`+ Id int `json:"id"`+ CreatedTs int64 `json:"createdTs"`+ UpdatedTs int64 `json:"updatedTs"`- OpenId string `jsonapi:"attr,openId"`- Name string `jsonapi:"attr,name"`+ OpenId string `json:"openId"`+ Name string `json:"name"`Password string}type UserCreate struct {- OpenId string `jsonapi:"attr,openId"`- Name string `jsonapi:"attr,name"`- Password string `jsonapi:"attr,password"`+ OpenId string `json:"openId"`+ Name string `json:"name"`+ Password string `json:"password"`}type UserPatch struct {@@ -21,18 +21,26 @@ type UserPatch struct {OpenId *string- Name *string `jsonapi:"attr,name"`- Password *string `jsonapi:"attr,password"`- ResetOpenId *bool `jsonapi:"attr,resetOpenId"`+ Name *string `json:"name"`+ Password *string `json:"password"`+ ResetOpenId *bool `json:"resetOpenId"`}type UserFind struct {- Id *int `jsonapi:"attr,id"`+ Id *int `json:"id"`- Name *string `jsonapi:"attr,name"`+ Name *string `json:"name"`OpenId *string}+type UserRenameCheck struct {+ Name string `json:"name"`+}++type UserPasswordCheck struct {+ Password string `json:"password"`+}+type UserService interface {CreateUser(create *UserCreate) (*User, error)PatchUser(patch *UserPatch) (*User, error)diff --git a/go.mod b/go.modindex 623915ce8..4ee1d61ff 100644--- a/go.mod+++ b/go.mod@@ -23,7 +23,6 @@ require ()require (- github.com/google/jsonapi v1.0.0github.com/gorilla/securecookie v1.1.1 // indirectgithub.com/gorilla/sessions v1.2.1github.com/labstack/echo-contrib v0.12.0diff --git a/go.sum b/go.sumindex 3024fd4f1..530251b8c 100644--- a/go.sum+++ b/go.sum@@ -133,8 +133,6 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=-github.com/google/jsonapi v1.0.0 h1:qIGgO5Smu3yJmSs+QlvhQnrscdZfFhiV6S8ryJAglqU=-github.com/google/jsonapi v1.0.0/go.mod h1:YYHiRPJT8ARXGER8In9VuLv4qvLfDmA9ULQqptbLE4s=github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=diff --git a/server/auth.go b/server/auth.goindex fe28f85b7..85f8bf501 100644--- a/server/auth.go+++ b/server/auth.go@@ -1,19 +1,19 @@package serverimport (+ "encoding/json""fmt""memos/api""memos/common""net/http"- "github.com/google/jsonapi""github.com/labstack/echo/v4")func (s *Server) registerAuthRoutes(g *echo.Group) {g.POST("/auth/login", func(c echo.Context) error {login := &api.Login{}- if err := jsonapi.UnmarshalPayload(c.Request().Body, login); err != nil {+ if err := json.NewDecoder(c.Request().Body).Decode(login); err != nil {return echo.NewHTTPError(http.StatusBadRequest, "Malformatted login request").SetInternal(err)}@@ -40,7 +40,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, user); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(user); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal create user response").SetInternal(err)}@@ -57,7 +57,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {})g.POST("/auth/signup", func(c echo.Context) error {signup := &api.Signup{}- if err := jsonapi.UnmarshalPayload(c.Request().Body, signup); err != nil {+ if err := json.NewDecoder(c.Request().Body).Decode(signup); err != nil {return echo.NewHTTPError(http.StatusBadRequest, "Malformatted signup request").SetInternal(err)}@@ -88,7 +88,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, user); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(user); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal create user response").SetInternal(err)}diff --git a/server/memo.go b/server/memo.goindex fbd5cd4ca..41bd7046c 100644--- a/server/memo.go+++ b/server/memo.go@@ -1,13 +1,13 @@package serverimport (+ "encoding/json""fmt""memos/api""memos/common""net/http""strconv"- "github.com/google/jsonapi""github.com/labstack/echo/v4")@@ -17,7 +17,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {memoCreate := &api.MemoCreate{CreatorId: userId,}- if err := jsonapi.UnmarshalPayload(c.Request().Body, memoCreate); err != nil {+ if err := json.NewDecoder(c.Request().Body).Decode(memoCreate); err != nil {return echo.NewHTTPError(http.StatusBadRequest, "Malformatted post memo request").SetInternal(err)}@@ -27,7 +27,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, memo); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(memo); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal memo response").SetInternal(err)}@@ -42,7 +42,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {memoPatch := &api.MemoPatch{Id: memoId,}- if err := jsonapi.UnmarshalPayload(c.Request().Body, memoPatch); err != nil {+ if err := json.NewDecoder(c.Request().Body).Decode(memoPatch); err != nil {return echo.NewHTTPError(http.StatusBadRequest, "Malformatted patch memo request").SetInternal(err)}@@ -52,7 +52,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, memo); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(memo); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal memo response").SetInternal(err)}@@ -69,7 +69,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, list); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(list); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal memo list response").SetInternal(err)}@@ -93,7 +93,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, memo); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(memo); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal memo response").SetInternal(err)}diff --git a/server/resource.go b/server/resource.goindex a727712fd..e1dd4c0a5 100644--- a/server/resource.go+++ b/server/resource.go@@ -1,13 +1,13 @@package serverimport (+ "encoding/json""fmt""io/ioutil""memos/api""net/http""strconv"- "github.com/google/jsonapi""github.com/labstack/echo/v4")@@ -53,7 +53,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, resource); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(resource); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal shortcut response").SetInternal(err)}@@ -70,7 +70,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, list); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(list); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal resource list response").SetInternal(err)}diff --git a/server/server.go b/server/server.goindex 633b127d5..56ed641ab 100644--- a/server/server.go+++ b/server/server.go@@ -29,9 +29,10 @@ func NewServer() *Server {e.HidePort = falsee.Use(middleware.StaticWithConfig(middleware.StaticConfig{- Root: "web/dist",- Browse: false,- HTML5: true,+ Skipper: middleware.DefaultSkipper,+ Root: "web/dist",+ Browse: false,+ HTML5: true,}))e.Use(session.Middleware(sessions.NewCookieStore([]byte(common.GenUUID()))))diff --git a/server/shortcut.go b/server/shortcut.goindex 406f96487..c6afcbba7 100644--- a/server/shortcut.go+++ b/server/shortcut.go@@ -1,13 +1,12 @@package serverimport (+ "encoding/json""fmt""memos/api""net/http""strconv"- "time"- "github.com/google/jsonapi""github.com/labstack/echo/v4")@@ -17,7 +16,7 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {shortcutCreate := &api.ShortcutCreate{CreatorId: userId,}- if err := jsonapi.UnmarshalPayload(c.Request().Body, shortcutCreate); err != nil {+ if err := json.NewDecoder(c.Request().Body).Decode(shortcutCreate); err != nil {return echo.NewHTTPError(http.StatusBadRequest, "Malformatted post shortcut request").SetInternal(err)}@@ -27,7 +26,7 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, shortcut); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(shortcut); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal shortcut response").SetInternal(err)}@@ -42,25 +41,17 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {shortcutPatch := &api.ShortcutPatch{Id: shortcutId,}- if err := jsonapi.UnmarshalPayload(c.Request().Body, shortcutPatch); err != nil {+ if err := json.NewDecoder(c.Request().Body).Decode(shortcutPatch); err != nil {return echo.NewHTTPError(http.StatusBadRequest, "Malformatted patch shortcut request").SetInternal(err)}- if shortcutPatch.Pinned != nil {- pinnedTs := int64(0)- if *shortcutPatch.Pinned {- pinnedTs = time.Now().Unix()- }- shortcutPatch.PinnedTs = &pinnedTs- }-shortcut, err := s.ShortcutService.PatchShortcut(shortcutPatch)if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to patch shortcut").SetInternal(err)}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, shortcut); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(shortcut); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal shortcut response").SetInternal(err)}@@ -71,13 +62,13 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {shortcutFind := &api.ShortcutFind{CreatorId: &userId,}- list, err := s.ShortcutService.FindShortcut(shortcutFind)+ list, err := s.ShortcutService.FindShortcutList(shortcutFind)if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch shortcut list").SetInternal(err)}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, list); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(list); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal shortcut list response").SetInternal(err)}@@ -98,7 +89,7 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, shortcut); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(shortcut); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal shortcut response").SetInternal(err)}diff --git a/server/user.go b/server/user.goindex 99ce594dd..b1ac50fea 100644--- a/server/user.go+++ b/server/user.go@@ -1,11 +1,11 @@package serverimport (+ "encoding/json""memos/api""memos/common""net/http"- "github.com/google/jsonapi""github.com/labstack/echo/v4")@@ -21,9 +21,35 @@ func (s *Server) registerUserRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, user); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(user); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal user response").SetInternal(err)}++ return nil+ })+ g.POST("/user/rename_check", func(c echo.Context) error {+ userRenameCheck := &api.UserRenameCheck{}+ if err := json.NewDecoder(c.Request().Body).Decode(userRenameCheck); err != nil {+ return echo.NewHTTPError(http.StatusBadRequest, "Malformatted post user rename check request").SetInternal(err)+ }++ if userRenameCheck.Name == "" {+ return echo.NewHTTPError(http.StatusBadRequest, "Malformatted post user rename check request")+ }++ userFind := &api.UserFind{+ Name: &userRenameCheck.Name,+ }+ user, err := s.UserService.FindUser(userFind)+ if err != nil {+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find user").SetInternal(err)+ }++ c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)+ if err := json.NewEncoder(c.Response().Writer).Encode(user); err != nil {+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal user response").SetInternal(err)+ }+return nil})g.PATCH("user/me", func(c echo.Context) error {@@ -31,7 +57,7 @@ func (s *Server) registerUserRoutes(g *echo.Group) {userPatch := &api.UserPatch{Id: userId,}- if err := jsonapi.UnmarshalPayload(c.Request().Body, userPatch); err != nil {+ if err := json.NewDecoder(c.Request().Body).Decode(userPatch); err != nil {return echo.NewHTTPError(http.StatusBadRequest, "Malformatted patch user request").SetInternal(err)}@@ -46,7 +72,7 @@ func (s *Server) registerUserRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, user); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(user); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal user response").SetInternal(err)}diff --git a/server/webhook.go b/server/webhook.goindex 070dc0996..b98216e1b 100644--- a/server/webhook.go+++ b/server/webhook.go@@ -1,12 +1,12 @@package serverimport (+ "encoding/json""fmt""memos/api""net/http""strconv"- "github.com/google/jsonapi""github.com/labstack/echo/v4")@@ -31,7 +31,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {memoCreate := &api.MemoCreate{CreatorId: user.Id,}- if err := jsonapi.UnmarshalPayload(c.Request().Body, memoCreate); err != nil {+ if err := json.NewDecoder(c.Request().Body).Decode(memoCreate); err != nil {return echo.NewHTTPError(http.StatusBadRequest, "Malformatted post memo request by open api").SetInternal(err)}@@ -41,7 +41,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, memo); err != nil {+ if err := json.NewEncoder(c.Response().Writer).Encode(memo); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal memo response").SetInternal(err)}diff --git a/store/seed/10001_schema.sql b/store/seed/10001_schema.sqlindex 3a21b3297..cdfdea613 100644--- a/store/seed/10001_schema.sql+++ b/store/seed/10001_schema.sql@@ -64,7 +64,8 @@ CREATE TABLE shortcut (title TEXT NOT NULL DEFAULT '',payload TEXT NOT NULL DEFAULT '',creator_id INTEGER NOT NULL,- pinned_ts BIGINT NOT NULL DEFAULT 0,+ -- allowed row status are 'NORMAL', 'ARCHIVED'.+ row_status TEXT NOT NULL DEFAULT 'NORMAL',FOREIGN KEY(creator_id) REFERENCES users(id));diff --git a/store/shortcut.go b/store/shortcut.goindex 323a93cc9..3e3ae3ea6 100644--- a/store/shortcut.go+++ b/store/shortcut.go@@ -72,7 +72,7 @@ func createShortcut(db *DB, create *api.ShortcutCreate) (*api.Shortcut, error) {creator_id,)VALUES (?, ?, ?)- RETURNING id, title, payload, creator_id, created_ts, updated_ts, pinned_ts+ RETURNING id, title, payload, creator_id, created_ts, updated_ts, row_status`,create.Title,create.Payload,@@ -93,7 +93,7 @@ func createShortcut(db *DB, create *api.ShortcutCreate) (*api.Shortcut, error) {&shortcut.CreatorId,&shortcut.CreatedTs,&shortcut.UpdatedTs,- &shortcut.PinnedTs,+ &shortcut.RowStatus,); err != nil {return nil, FormatError(err)}@@ -109,8 +109,8 @@ func patchShortcut(db *DB, patch *api.ShortcutPatch) (*api.Shortcut, error) {if v := patch.Payload; v != nil {set, args = append(set, "payload = ?"), append(args, *v)}- if v := patch.PinnedTs; v != nil {- set, args = append(set, "pinned_ts = ?"), append(args, *v)+ if v := patch.RowStatus; v != nil {+ set, args = append(set, "row_status = ?"), append(args, *v)}args = append(args, patch.Id)@@ -119,7 +119,7 @@ func patchShortcut(db *DB, patch *api.ShortcutPatch) (*api.Shortcut, error) {UPDATE shortcutSET `+strings.Join(set, ", ")+`WHERE id = ?- RETURNING id, title, payload, created_ts, updated_ts, pinned_ts+ RETURNING id, title, payload, created_ts, updated_ts, row_status`, args...)if err != nil {return nil, FormatError(err)@@ -137,7 +137,7 @@ func patchShortcut(db *DB, patch *api.ShortcutPatch) (*api.Shortcut, error) {&shortcut.Payload,&shortcut.CreatedTs,&shortcut.UpdatedTs,- &shortcut.PinnedTs,+ &shortcut.RowStatus,); err != nil {return nil, FormatError(err)}@@ -166,7 +166,7 @@ func findShortcutList(db *DB, find *api.ShortcutFind) ([]*api.Shortcut, error) {creator_id,created_ts,updated_ts,- pinned_ts+ row_statusFROM shortcutWHERE `+strings.Join(where, " AND "),args...,@@ -186,7 +186,7 @@ func findShortcutList(db *DB, find *api.ShortcutFind) ([]*api.Shortcut, error) {&shortcut.CreatorId,&shortcut.CreatedTs,&shortcut.UpdatedTs,- &shortcut.PinnedTs,+ &shortcut.RowStatus,); err != nil {return nil, FormatError(err)}