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: add max content length
Stevenddcf1d669d41
diff --git a/api/v2/memo_service.go b/api/v2/memo_service.goindex e1d72c6aa..0e00e72ab 100644--- a/api/v2/memo_service.go+++ b/api/v2/memo_service.go@@ -27,6 +27,10 @@ import ("github.com/usememos/memos/store")+const (+ MaxContentLength = 8 * 1024+)+func (s *APIV2Service) CreateMemo(ctx context.Context, request *apiv2pb.CreateMemoRequest) (*apiv2pb.CreateMemoResponse, error) {user, err := getCurrentUser(ctx, s.Store)if err != nil {@@ -35,6 +39,9 @@ func (s *APIV2Service) CreateMemo(ctx context.Context, request *apiv2pb.CreateMeif user == nil {return nil, status.Errorf(codes.PermissionDenied, "permission denied")}+ if len(request.Content) > MaxContentLength {+ return nil, status.Errorf(codes.InvalidArgument, "content too long")+ }nodes, err := parser.Parse(tokenizer.Tokenize(request.Content))if err != nil {@@ -260,6 +267,9 @@ func (s *APIV2Service) UpdateMemo(ctx context.Context, request *apiv2pb.UpdateMe}}}+ if update.Content != nil && len(*update.Content) > MaxContentLength {+ return nil, status.Errorf(codes.InvalidArgument, "content too long")+ }if err = s.Store.UpdateMemo(ctx, update); err != nil {return nil, status.Errorf(codes.Internal, "failed to update memo")diff --git a/web/src/store/v1/memo.ts b/web/src/store/v1/memo.tsindex 530183df2..4f942b3a4 100644--- a/web/src/store/v1/memo.ts+++ b/web/src/store/v1/memo.ts@@ -21,6 +21,7 @@ export const useMemoStore = create(for (const memo of memos) {memoMap[memo.id] = memo;}+ console.log("memos", memos);set({ memoMapById: memoMap });return memos;},