forked from kevadesu/forgejo
Store and use seconds for timeline time comments (#25392)
this will allow us to fully localize it later PS: we can not migrate back as the old value was a one-way conversion prepare for #25213 --- *Sponsored by Kithara Software GmbH*
This commit is contained in:
parent
a954c93a68
commit
b0215c40cd
6 changed files with 67 additions and 18 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
)
|
||||
|
||||
// ToComment converts a issues_model.Comment to the api.Comment format
|
||||
|
@ -66,6 +67,17 @@ func ToTimelineComment(ctx context.Context, c *issues_model.Comment, doer *user_
|
|||
return nil
|
||||
}
|
||||
|
||||
if c.Content != "" {
|
||||
if (c.Type == issues_model.CommentTypeAddTimeManual ||
|
||||
c.Type == issues_model.CommentTypeStopTracking ||
|
||||
c.Type == issues_model.CommentTypeDeleteTimeManual) &&
|
||||
c.Content[0] == '|' {
|
||||
// TimeTracking Comments from v1.21 on store the seconds instead of an formated string
|
||||
// so we check for the "|" delimeter and convert new to legacy format on demand
|
||||
c.Content = util.SecToTime(c.Content[1:])
|
||||
}
|
||||
}
|
||||
|
||||
comment := &api.TimelineComment{
|
||||
ID: c.ID,
|
||||
Type: c.Type.String(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue