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.

fix: duplicated/reflexive relation in v2 api. (#2750)

Hanqin Guan16e68fbfff06
diff --git a/api/v2/memo_relation_service.go b/api/v2/memo_relation_service.go
index 0f3fa6c2d..3c20e43f1 100644
--- a/api/v2/memo_relation_service.go
+++ b/api/v2/memo_relation_service.go
@@ -21,6 +21,15 @@ func (s *APIV2Service) SetMemoRelations(ctx context.Context, request *apiv2pb.Se
}
for _, relation := range request.Relations {
+ // Ignore reflexive relations.
+ if request.Id == relation.RelatedMemoId {
+ continue
+ }
+ // Ignore comment relations as there's no need to update a comment's relation.
+ // Inserting/Deleting a comment is handled elsewhere.
+ if relation.Type == apiv2pb.MemoRelation_COMMENT {
+ continue
+ }
if _, err := s.Store.UpsertMemoRelation(ctx, &store.MemoRelation{
MemoID: request.Id,
RelatedMemoID: relation.RelatedMemoId,