Self reference detection

This commit is contained in:
2024-08-11 01:08:08 +08:00
parent 3e000b6f9e
commit d34e6f068b
4 changed files with 35 additions and 25 deletions

View File

@@ -109,6 +109,10 @@ func TryLinkAttachment(tx *gorm.DB, og models.Attachment, hash string) (bool, er
og.Uuid = prev.Uuid
og.Destination = prev.Destination
if og.AccountID == prev.AccountID {
og.IsSelfRef = true
}
if err := tx.Save(&og).Error; err != nil {
tx.Rollback()
return true, err