✨ Self reference detection
This commit is contained in:
@ -25,6 +25,7 @@ type Attachment struct {
|
||||
Metadata datatypes.JSONMap `json:"metadata"`
|
||||
IsMature bool `json:"is_mature"`
|
||||
IsAnalyzed bool `json:"is_analyzed"`
|
||||
IsSelfRef bool `json:"is_self_ref"`
|
||||
|
||||
Ref *Attachment `json:"ref"`
|
||||
RefID *uint `json:"ref_id"`
|
||||
|
@ -187,7 +187,7 @@ func AnalyzeAttachment(file models.Attachment) error {
|
||||
|
||||
start = time.Now()
|
||||
|
||||
// Move temporary to permanet
|
||||
// Move temporary to permanent
|
||||
if !linked {
|
||||
if err := ReUploadFileToPermanent(file); err != nil {
|
||||
return fmt.Errorf("unable to move file to permanet storage: %v", err)
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user