mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-11 14:19:19 +08:00
Migration not fail on notmigrated reactions (#13507)
* Refactor: dedub code * skip Reactions with Invalid ID
This commit is contained in:
parent
5a32224a2c
commit
1f72656892
@ -326,45 +326,44 @@ func (g *GiteaDownloader) GetAsset(_ string, relID, id int64) (io.ReadCloser, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *GiteaDownloader) getIssueReactions(index int64) ([]*base.Reaction, error) {
|
func (g *GiteaDownloader) getIssueReactions(index int64) ([]*base.Reaction, error) {
|
||||||
var reactions []*base.Reaction
|
|
||||||
if err := g.client.CheckServerVersionConstraint(">=1.11"); err != nil {
|
if err := g.client.CheckServerVersionConstraint(">=1.11"); err != nil {
|
||||||
log.Info("GiteaDownloader: instance to old, skip getIssueReactions")
|
log.Info("GiteaDownloader: instance to old, skip getIssueReactions")
|
||||||
return reactions, nil
|
return []*base.Reaction{}, nil
|
||||||
}
|
}
|
||||||
rl, _, err := g.client.GetIssueReactions(g.repoOwner, g.repoName, index)
|
rl, _, err := g.client.GetIssueReactions(g.repoOwner, g.repoName, index)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, reaction := range rl {
|
return g.convertReactions(rl), nil
|
||||||
reactions = append(reactions, &base.Reaction{
|
|
||||||
UserID: reaction.User.ID,
|
|
||||||
UserName: reaction.User.UserName,
|
|
||||||
Content: reaction.Reaction,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return reactions, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GiteaDownloader) getCommentReactions(commentID int64) ([]*base.Reaction, error) {
|
func (g *GiteaDownloader) getCommentReactions(commentID int64) ([]*base.Reaction, error) {
|
||||||
var reactions []*base.Reaction
|
|
||||||
if err := g.client.CheckServerVersionConstraint(">=1.11"); err != nil {
|
if err := g.client.CheckServerVersionConstraint(">=1.11"); err != nil {
|
||||||
log.Info("GiteaDownloader: instance to old, skip getCommentReactions")
|
log.Info("GiteaDownloader: instance to old, skip getCommentReactions")
|
||||||
return reactions, nil
|
return []*base.Reaction{}, nil
|
||||||
}
|
}
|
||||||
rl, _, err := g.client.GetIssueCommentReactions(g.repoOwner, g.repoName, commentID)
|
rl, _, err := g.client.GetIssueCommentReactions(g.repoOwner, g.repoName, commentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return g.convertReactions(rl), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *GiteaDownloader) convertReactions(rl []*gitea_sdk.Reaction) []*base.Reaction {
|
||||||
|
var reactions []*base.Reaction
|
||||||
for i := range rl {
|
for i := range rl {
|
||||||
|
if rl[i].User.ID <= 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
reactions = append(reactions, &base.Reaction{
|
reactions = append(reactions, &base.Reaction{
|
||||||
UserID: rl[i].User.ID,
|
UserID: rl[i].User.ID,
|
||||||
UserName: rl[i].User.UserName,
|
UserName: rl[i].User.UserName,
|
||||||
Content: rl[i].Reaction,
|
Content: rl[i].Reaction,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return reactions, nil
|
return reactions
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIssues returns issues according start and limit
|
// GetIssues returns issues according start and limit
|
||||||
|
Loading…
Reference in New Issue
Block a user