forked from forgejo/forgejo
Add an updated_at field to the API call for comment's attachment creation
The update date is applied to the comment, and is set as the asset creation date.
This commit is contained in:
parent
cf787ad7fd
commit
1e4ff424d3
3 changed files with 53 additions and 9 deletions
|
@ -1107,13 +1107,23 @@ func UpdateComment(c *Comment, doer *user_model.User) error {
|
|||
}
|
||||
defer committer.Close()
|
||||
sess := db.GetEngine(ctx).ID(c.ID).AllCols()
|
||||
if c.Issue.NoAutoTime {
|
||||
c.UpdatedUnix = c.Issue.UpdatedUnix
|
||||
sess = sess.NoAutoTime()
|
||||
}
|
||||
if _, err := sess.Update(c); err != nil {
|
||||
return err
|
||||
}
|
||||
if c.Issue.NoAutoTime {
|
||||
// AllCols().Update() does not change the "update_unix" field
|
||||
// even if NoAutoTime is set.
|
||||
// So, we need to commit the former pending Update() and
|
||||
// then call an other Update() specifically to set "updated_unix".
|
||||
if err := committer.Commit(); err != nil {
|
||||
return fmt.Errorf("Commit: %w", err)
|
||||
}
|
||||
c.UpdatedUnix = c.Issue.UpdatedUnix
|
||||
sess := db.GetEngine(ctx).ID(c.ID).Cols("updated_unix").NoAutoTime()
|
||||
if _, err := sess.Update(c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := c.LoadIssue(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue