Refactor file key extraction in CreatePost and EditPost logic to handle multiple file types; enhance error logging and simplify utility functions
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 53s
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 53s
This commit is contained in:
@@ -49,23 +49,13 @@ func (l *EditPostLogic) EditPost(req *types.EditPostReq) (resp *types.EditPostRe
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Extract all image file keys from content
|
||||
imageKeys, err := utils.ExtractImageKeysFromContent(req.Content)
|
||||
// Extract all file keys (images, archives, audio, video) from content
|
||||
allFileKeys, err := utils.ExtractAllFileKeysFromContent(req.Content)
|
||||
if err != nil {
|
||||
l.Errorf("Failed to parse content: %v", err)
|
||||
l.Errorf("Failed to parse file references from content: %v", err)
|
||||
return nil, fmt.Errorf("invalid content format")
|
||||
}
|
||||
|
||||
// Extract all archive file keys from content
|
||||
archiveKeys, err := utils.ExtractArchiveKeysFromContent(req.Content)
|
||||
if err != nil {
|
||||
l.Errorf("Failed to parse archive files from content: %v", err)
|
||||
return nil, fmt.Errorf("invalid content format")
|
||||
}
|
||||
|
||||
// Combine all file keys
|
||||
allFileKeys := append(imageKeys, archiveKeys...)
|
||||
|
||||
// Extract all hashtags from content
|
||||
hashtags, err := utils.ExtractHashtagsFromContent(req.Content)
|
||||
if err != nil {
|
||||
@@ -110,7 +100,7 @@ func (l *EditPostLogic) EditPost(req *types.EditPostReq) (resp *types.EditPostRe
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate all content files (images and archives) from tmpfiles to files
|
||||
// Migrate all referenced content files (images, archives, audio, video) from tmpfiles to files
|
||||
for _, fileKey := range allFileKeys {
|
||||
_, err := l.migrateFileFromTmpToFiles(tx, fileKey)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user