[MM-52541] Mark files as deleted along with thread (#23226)
* mark thread files as deleted * add missing check * improve query * Stopped rendering post preview if post is deleted * Fixed lint error * Fixed test * updated types * Removed deleted post from other post's embed data * Added tests * Apply suggestions from code review Co-authored-by: Daniel Espino García <larkox@gmail.com> * lint fix --------- Co-authored-by: Konstantinos Pittas <konstantinos.pittas@mattermost.com> Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com> Co-authored-by: Daniel Espino García <larkox@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
341b34d08f
Коммит
4d41365fbe
@@ -2913,6 +2913,30 @@ func (s *SqlPostStore) deleteThread(transaction *sqlxTxWrapper, postId string, d
|
||||
return errors.Wrapf(err, "failed to mark thread for root post %s as deleted", postId)
|
||||
}
|
||||
|
||||
return s.deleteThreadFiles(transaction, postId, deleteAtTime)
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) deleteThreadFiles(transaction *sqlxTxWrapper, postID string, deleteAtTime int64) error {
|
||||
var query sq.UpdateBuilder
|
||||
if s.DriverName() == model.DatabaseDriverPostgres {
|
||||
query = s.getQueryBuilder().Update("FileInfo").
|
||||
Set("DeleteAt", deleteAtTime).
|
||||
From("Posts")
|
||||
} else {
|
||||
query = s.getQueryBuilder().Update("FileInfo", "Posts").
|
||||
Set("FileInfo.DeleteAt", deleteAtTime)
|
||||
}
|
||||
|
||||
query = query.Where(sq.And{
|
||||
sq.Expr("FileInfo.PostId = Posts.Id"),
|
||||
sq.Eq{"Posts.RootId": postID},
|
||||
})
|
||||
|
||||
_, err := transaction.ExecBuilder(query)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to mark files of thread post %s as deleted", postID)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user