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: restrict archived memo access to creator only (#5707)
memoclawf4154d090be3
diff --git a/server/router/api/v1/memo_service.go b/server/router/api/v1/memo_service.goindex f563dde68..dcc01668a 100644--- a/server/router/api/v1/memo_service.go+++ b/server/router/api/v1/memo_service.go@@ -153,9 +153,19 @@ func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosReq// Exclude comments by default.ExcludeComments: true,}+ currentUser, err := s.fetchCurrentUser(ctx)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to get user")+ }+if request.State == v1pb.State_ARCHIVED {state := store.ArchivedmemoFind.RowStatus = &state+ // Archived memos are only visible to their creator.+ if currentUser == nil {+ return &v1pb.ListMemosResponse{}, nil+ }+ memoFind.CreatorID = ¤tUser.ID} else {state := store.NormalmemoFind.RowStatus = &state@@ -178,10 +188,6 @@ func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosReqmemoFind.Filters = append(memoFind.Filters, request.Filter)}- currentUser, err := s.fetchCurrentUser(ctx)- if err != nil {- return nil, status.Errorf(codes.Internal, "failed to get user")- }if currentUser == nil {memoFind.VisibilityList = []store.Visibility{store.Public}} else {@@ -311,6 +317,18 @@ func (s *APIV1Service) GetMemo(ctx context.Context, request *v1pb.GetMemoRequestif memo == nil {return nil, status.Errorf(codes.NotFound, "memo not found")}++ // Archived memos are only visible to their creator.+ if memo.RowStatus == store.Archived {+ user, err := s.fetchCurrentUser(ctx)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to get user")+ }+ if user == nil || memo.CreatorID != user.ID {+ return nil, status.Errorf(codes.NotFound, "memo not found")+ }+ }+if memo.Visibility != store.Public {user, err := s.fetchCurrentUser(ctx)if err != nil {