@@ -326,45 +326,44 @@ func (g *GiteaDownloader) GetAsset(_ string, relID, id int64) (io.ReadCloser, er
326
326
}
327
327
328
328
func (g * GiteaDownloader ) getIssueReactions (index int64 ) ([]* base.Reaction , error ) {
329
- var reactions []* base.Reaction
330
329
if err := g .client .CheckServerVersionConstraint (">=1.11" ); err != nil {
331
330
log .Info ("GiteaDownloader: instance to old, skip getIssueReactions" )
332
- return reactions , nil
331
+ return [] * base. Reaction {} , nil
333
332
}
334
333
rl , _ , err := g .client .GetIssueReactions (g .repoOwner , g .repoName , index )
335
334
if err != nil {
336
335
return nil , err
337
336
}
338
337
339
- for _ , reaction := range rl {
340
- reactions = append (reactions , & base.Reaction {
341
- UserID : reaction .User .ID ,
342
- UserName : reaction .User .UserName ,
343
- Content : reaction .Reaction ,
344
- })
345
- }
346
- return reactions , nil
338
+ return g .convertReactions (rl ), nil
347
339
}
348
340
349
341
func (g * GiteaDownloader ) getCommentReactions (commentID int64 ) ([]* base.Reaction , error ) {
350
- var reactions []* base.Reaction
351
342
if err := g .client .CheckServerVersionConstraint (">=1.11" ); err != nil {
352
343
log .Info ("GiteaDownloader: instance to old, skip getCommentReactions" )
353
- return reactions , nil
344
+ return [] * base. Reaction {} , nil
354
345
}
355
346
rl , _ , err := g .client .GetIssueCommentReactions (g .repoOwner , g .repoName , commentID )
356
347
if err != nil {
357
348
return nil , err
358
349
}
359
350
351
+ return g .convertReactions (rl ), nil
352
+ }
353
+
354
+ func (g * GiteaDownloader ) convertReactions (rl []* gitea_sdk.Reaction ) []* base.Reaction {
355
+ var reactions []* base.Reaction
360
356
for i := range rl {
357
+ if rl [i ].User .ID <= 0 {
358
+ continue
359
+ }
361
360
reactions = append (reactions , & base.Reaction {
362
361
UserID : rl [i ].User .ID ,
363
362
UserName : rl [i ].User .UserName ,
364
363
Content : rl [i ].Reaction ,
365
364
})
366
365
}
367
- return reactions , nil
366
+ return reactions
368
367
}
369
368
370
369
// GetIssues returns issues according start and limit
0 commit comments