Skip to content

armgit / memos

Public Imported from GitHub
0

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.

chore: tweak get memo by name

Stevenc38404b5d50b
diff --git a/api/v2/acl_config.go b/api/v2/acl_config.go
index 8e9d7c385..f3482eb7a 100644
--- a/api/v2/acl_config.go
+++ b/api/v2/acl_config.go
@@ -8,6 +8,7 @@ var authenticationAllowlistMethods = map[string]bool{
"/memos.api.v2.UserService/GetUser": true,
"/memos.api.v2.MemoService/ListMemos": true,
"/memos.api.v2.MemoService/GetMemo": true,
+ "/memos.api.v2.MemoService/GetMemoByName": true,
"/memos.api.v2.MemoService/ListMemoResources": true,
"/memos.api.v2.MemoService/ListMemoRelations": true,
"/memos.api.v2.MemoService/ListMemoComments": true,
diff --git a/api/v2/memo_service.go b/api/v2/memo_service.go
index 3260f26f6..f71f4a154 100644
--- a/api/v2/memo_service.go
+++ b/api/v2/memo_service.go
@@ -247,6 +247,18 @@ func (s *APIV2Service) GetMemoByName(ctx context.Context, request *apiv2pb.GetMe
if memo == nil {
return nil, status.Errorf(codes.NotFound, "memo not found")
}
+ if memo.Visibility != store.Public {
+ user, err := getCurrentUser(ctx, s.Store)
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to get user")
+ }
+ if user == nil {
+ return nil, status.Errorf(codes.PermissionDenied, "permission denied")
+ }
+ if memo.Visibility == store.Private && memo.CreatorID != user.ID {
+ return nil, status.Errorf(codes.PermissionDenied, "permission denied")
+ }
+ }
memoMessage, err := s.convertMemoFromStore(ctx, memo)
if err != nil {