@@ -977,6 +977,22 @@ func GetIssueDependencies(ctx *context.APIContext) {
977
977
if i < skip || i >= max {
978
978
continue
979
979
}
980
+
981
+ perm , err := models .GetUserRepoPermission (& depMeta .Repository , ctx .User )
982
+ if err != nil {
983
+ ctx .Error (http .StatusInternalServerError , "GetUserRepoPermission" , err )
984
+ return
985
+ }
986
+ if depMeta .Issue .IsPull {
987
+ if ! perm .CanRead (unit .TypePullRequests ) {
988
+ continue
989
+ }
990
+ } else {
991
+ if ! perm .CanRead (unit .TypeIssues ) {
992
+ continue
993
+ }
994
+ }
995
+
980
996
depMeta .Issue .Repo = & depMeta .Repository
981
997
issues = append (issues , & depMeta .Issue )
982
998
}
@@ -1127,6 +1143,22 @@ func GetIssueBlocks(ctx *context.APIContext) {
1127
1143
if i < skip || i >= max {
1128
1144
continue
1129
1145
}
1146
+
1147
+ perm , err := models .GetUserRepoPermission (& depMeta .Repository , ctx .User )
1148
+ if err != nil {
1149
+ ctx .Error (http .StatusInternalServerError , "GetUserRepoPermission" , err )
1150
+ return
1151
+ }
1152
+ if depMeta .Issue .IsPull {
1153
+ if ! perm .CanRead (unit .TypePullRequests ) {
1154
+ continue
1155
+ }
1156
+ } else {
1157
+ if ! perm .CanRead (unit .TypeIssues ) {
1158
+ continue
1159
+ }
1160
+ }
1161
+
1130
1162
depMeta .Issue .Repo = & depMeta .Repository
1131
1163
issues = append (issues , & depMeta .Issue )
1132
1164
}
@@ -1210,7 +1242,7 @@ func createIssueDependency(ctx *context.APIContext, t models.DependencyType) {
1210
1242
return
1211
1243
}
1212
1244
1213
- dep , err := models .GetIssueWithAttrsByIndex (ctx .Repo .Repository .ID , ctx .ParamsInt64 (":index" ))
1245
+ dep , err := models .GetIssueByIndex (ctx .Repo .Repository .ID , ctx .ParamsInt64 (":index" ))
1214
1246
if err != nil {
1215
1247
if models .IsErrIssueNotExist (err ) {
1216
1248
ctx .NotFound ("IsErrIssueNotExist" , err )
@@ -1242,8 +1274,42 @@ func createIssueDependency(ctx *context.APIContext, t models.DependencyType) {
1242
1274
}
1243
1275
1244
1276
if t == models .DependencyTypeBlockedBy {
1277
+ perm , err := models .GetUserRepoPermission (ctx .Repo .Repository , ctx .User )
1278
+ if err != nil {
1279
+ ctx .Error (http .StatusInternalServerError , "GetUserRepoPermission" , err )
1280
+ return
1281
+ }
1282
+ if issue .IsPull {
1283
+ if ! perm .CanRead (unit .TypePullRequests ) {
1284
+ ctx .NotFound ()
1285
+ return
1286
+ }
1287
+ } else {
1288
+ if ! perm .CanRead (unit .TypeIssues ) {
1289
+ ctx .NotFound ()
1290
+ return
1291
+ }
1292
+ }
1293
+
1245
1294
err = models .CreateIssueDependency (ctx .User , issue , dep )
1246
1295
} else {
1296
+ perm , err := models .GetUserRepoPermission (repo , ctx .User )
1297
+ if err != nil {
1298
+ ctx .Error (http .StatusInternalServerError , "GetUserRepoPermission" , err )
1299
+ return
1300
+ }
1301
+ if issue .IsPull {
1302
+ if ! perm .CanRead (unit .TypePullRequests ) {
1303
+ ctx .NotFound ()
1304
+ return
1305
+ }
1306
+ } else {
1307
+ if ! perm .CanRead (unit .TypeIssues ) {
1308
+ ctx .NotFound ()
1309
+ return
1310
+ }
1311
+ }
1312
+
1247
1313
err = models .CreateIssueDependency (ctx .User , dep , issue )
1248
1314
}
1249
1315
if err != nil {
@@ -1291,6 +1357,23 @@ func removeIssueDependency(ctx *context.APIContext, t models.DependencyType) {
1291
1357
return
1292
1358
}
1293
1359
1360
+ perm , err := models .GetUserRepoPermission (repo , ctx .User )
1361
+ if err != nil {
1362
+ ctx .Error (http .StatusInternalServerError , "GetUserRepoPermission" , err )
1363
+ return
1364
+ }
1365
+ if issue .IsPull {
1366
+ if ! perm .CanRead (unit .TypePullRequests ) {
1367
+ ctx .NotFound ("IsErrRepoNotExist" , err )
1368
+ return
1369
+ }
1370
+ } else {
1371
+ if ! perm .CanRead (unit .TypeIssues ) {
1372
+ ctx .NotFound ("IsErrRepoNotExist" , err )
1373
+ return
1374
+ }
1375
+ }
1376
+
1294
1377
err = models .RemoveIssueDependency (ctx .User , issue , dep , t )
1295
1378
if err != nil {
1296
1379
ctx .Error (http .StatusInternalServerError , "CreateIssueDependency" , err )
0 commit comments