Unverified Commit 16e68fbf authored by Hanqin Guan's avatar Hanqin Guan Committed by GitHub

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

parent 81942b3b
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment