@@ -1275,43 +1275,9 @@ func GetParticipantsIDsByIssueID(issueID int64) ([]int64, error) {
1275
1275
Find (& userIDs )
1276
1276
}
1277
1277
1278
- // GetParticipantsByIssueID returns all users who are participated in comments of an issue.
1279
- func GetParticipantsByIssueID (issueID int64 ) ([]* User , error ) {
1280
- issue , err := getIssueByID (x , issueID )
1281
- if err != nil {
1282
- return nil , err
1283
- }
1284
- userIDs , err := getParticipantsByIssueID (x , issue )
1285
- if err != nil {
1286
- return nil , err
1287
- }
1288
- if len (userIDs ) == 0 {
1289
- return nil , nil
1290
- }
1291
- return GetUsersByIDs (userIDs )
1292
- }
1293
-
1294
- func getParticipantsByIssueID (e Engine , issue * Issue ) ([]int64 , error ) {
1295
- userIDs := make ([]int64 , 0 , 5 )
1296
- if err := e .Table ("comment" ).Cols ("poster_id" ).
1297
- Where ("`comment`.issue_id = ?" , issue .ID ).
1298
- And ("`comment`.type in (?,?,?)" , CommentTypeComment , CommentTypeCode , CommentTypeReview ).
1299
- And ("`user`.is_active = ?" , true ).
1300
- And ("`user`.prohibit_login = ?" , false ).
1301
- Join ("INNER" , "`user`" , "`user`.id = `comment`.poster_id" ).
1302
- Distinct ("poster_id" ).
1303
- Find (& userIDs ); err != nil {
1304
- return nil , fmt .Errorf ("get poster IDs: %v" , err )
1305
- }
1306
- if ! util .IsInt64InSlice (issue .PosterID , userIDs ) {
1307
- return append (userIDs , issue .PosterID ), nil
1308
- }
1309
- return userIDs , nil
1310
- }
1311
-
1312
1278
// IsUserParticipantsOfIssue return true if user is participants of an issue
1313
1279
func IsUserParticipantsOfIssue (user * User , issue * Issue ) bool {
1314
- userIDs , err := getParticipantsByIssueID ( x , issue )
1280
+ userIDs , err := issue . getParticipantIDsByIssue ( x )
1315
1281
if err != nil {
1316
1282
log .Error (err .Error ())
1317
1283
return false
@@ -1710,6 +1676,28 @@ type DependencyInfo struct {
1710
1676
Repository `xorm:"extends"`
1711
1677
}
1712
1678
1679
+ // getParticipantIDsByIssue returns all userIDs who are participated in comments of an issue and issue author
1680
+ func (issue * Issue ) getParticipantIDsByIssue (e Engine ) ([]int64 , error ) {
1681
+ if issue == nil {
1682
+ return nil , nil
1683
+ }
1684
+ userIDs := make ([]int64 , 0 , 5 )
1685
+ if err := e .Table ("comment" ).Cols ("poster_id" ).
1686
+ Where ("`comment`.issue_id = ?" , issue .ID ).
1687
+ And ("`comment`.type in (?,?,?)" , CommentTypeComment , CommentTypeCode , CommentTypeReview ).
1688
+ And ("`user`.is_active = ?" , true ).
1689
+ And ("`user`.prohibit_login = ?" , false ).
1690
+ Join ("INNER" , "`user`" , "`user`.id = `comment`.poster_id" ).
1691
+ Distinct ("poster_id" ).
1692
+ Find (& userIDs ); err != nil {
1693
+ return nil , fmt .Errorf ("get poster IDs: %v" , err )
1694
+ }
1695
+ if ! util .IsInt64InSlice (issue .PosterID , userIDs ) {
1696
+ return append (userIDs , issue .PosterID ), nil
1697
+ }
1698
+ return userIDs , nil
1699
+ }
1700
+
1713
1701
// Get Blocked By Dependencies, aka all issues this issue is blocked by.
1714
1702
func (issue * Issue ) getBlockedByDependencies (e Engine ) (issueDeps []* DependencyInfo , err error ) {
1715
1703
return issueDeps , e .
0 commit comments