Add OriginalID to comments

This commit is contained in:
harryzcy 2023-06-24 18:03:13 -05:00
parent 6e3b98051b
commit 186a9a932f
No known key found for this signature in database
GPG Key ID: E3C2287691E40E35
5 changed files with 5 additions and 1 deletions

View File

@ -225,6 +225,7 @@ type Comment struct {
Poster *user_model.User `xorm:"-"`
OriginalAuthor string
OriginalAuthorID int64
OriginalID int64 // Only used in synced comments
IssueID int64 `xorm:"INDEX"`
Issue *Issue `xorm:"-"`
LabelID int64

View File

@ -328,7 +328,7 @@ func UpsertIssueComments(comments []*issues_model.Comment) error {
}
} else {
if _, err := sess.NoAutoTime().Where(
"issue_id = ? AND created_unix = ?", comment.IssueID, comment.CreatedUnix,
"issue_id = ? AND original_id = ?", comment.IssueID, comment.OriginalID,
).Update(comment); err != nil {
return err
}

View File

@ -25,6 +25,7 @@ type Comment struct {
Content string
Reactions []*Reaction
Meta map[string]interface{} `yaml:"meta,omitempty"` // see models/issues/comment.go for fields in Comment struct
OriginalID int64 `yaml:"-"` // ID from the upstream syncing source
}
// GetExternalName ExternalUserMigrated interface

View File

@ -506,6 +506,7 @@ func (g *GiteaLocalUploader) prepareComments(comments ...*base.Comment) ([]*issu
Content: comment.Content,
CreatedUnix: timeutil.TimeStamp(comment.Created.Unix()),
UpdatedUnix: timeutil.TimeStamp(comment.Updated.Unix()),
OriginalID: comment.OriginalID,
}
switch cm.Type {

View File

@ -490,6 +490,7 @@ func (g *GithubDownloaderV3) getCommentsSince(commentable base.Commentable, sinc
Created: comment.GetCreatedAt().Time,
Updated: comment.GetUpdatedAt().Time,
Reactions: reactions,
OriginalID: comment.GetID(),
})
}
if resp.NextPage == 0 {