mirror of
https://github.com/usememos/memos.git
synced 2025-01-31 17:48:12 +08:00
fix: duplicated/reflexive relation in v2 api. (#2750)
This commit is contained in:
parent
81942b3b98
commit
16e68fbfff
1 changed files with 9 additions and 0 deletions
|
@ -21,6 +21,15 @@ func (s *APIV2Service) SetMemoRelations(ctx context.Context, request *apiv2pb.Se
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, relation := range request.Relations {
|
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{
|
if _, err := s.Store.UpsertMemoRelation(ctx, &store.MemoRelation{
|
||||||
MemoID: request.Id,
|
MemoID: request.Id,
|
||||||
RelatedMemoID: relation.RelatedMemoId,
|
RelatedMemoID: relation.RelatedMemoId,
|
||||||
|
|
Loading…
Reference in a new issue