@@ -7,6 +7,7 @@ package org
7
7
import (
8
8
"net/http"
9
9
10
+ activities_model "code.gitea.io/gitea/models/activities"
10
11
"code.gitea.io/gitea/models/db"
11
12
"code.gitea.io/gitea/models/organization"
12
13
"code.gitea.io/gitea/models/perm"
@@ -370,3 +371,69 @@ func Delete(ctx *context.APIContext) {
370
371
}
371
372
ctx .Status (http .StatusNoContent )
372
373
}
374
+
375
+ func ListOrgActivityFeeds (ctx * context.APIContext ) {
376
+ // swagger:operation GET /orgs/{org}/activities/feeds organization orgListActivityFeeds
377
+ // ---
378
+ // summary: List an organization's activity feeds
379
+ // produces:
380
+ // - application/json
381
+ // parameters:
382
+ // - name: org
383
+ // in: path
384
+ // description: name of the org
385
+ // type: string
386
+ // required: true
387
+ // - name: date
388
+ // in: query
389
+ // description: the date of the activities to be found
390
+ // type: string
391
+ // format: date
392
+ // - name: page
393
+ // in: query
394
+ // description: page number of results to return (1-based)
395
+ // type: integer
396
+ // - name: limit
397
+ // in: query
398
+ // description: page size of results
399
+ // type: integer
400
+ // responses:
401
+ // "200":
402
+ // "$ref": "#/responses/ActivityFeedsList"
403
+ // "404":
404
+ // "$ref": "#/responses/notFound"
405
+
406
+ includePrivate := false
407
+ if ctx .IsSigned {
408
+ if ctx .Doer .IsAdmin {
409
+ includePrivate = true
410
+ } else {
411
+ org := organization .OrgFromUser (ctx .ContextUser )
412
+ isMember , err := org .IsOrgMember (ctx .Doer .ID )
413
+ if err != nil {
414
+ ctx .Error (http .StatusInternalServerError , "IsOrgMember" , err )
415
+ return
416
+ }
417
+ includePrivate = isMember
418
+ }
419
+ }
420
+
421
+ listOptions := utils .GetListOptions (ctx )
422
+
423
+ opts := activities_model.GetFeedsOptions {
424
+ RequestedUser : ctx .ContextUser ,
425
+ Actor : ctx .Doer ,
426
+ IncludePrivate : includePrivate ,
427
+ Date : ctx .FormString ("date" ),
428
+ ListOptions : listOptions ,
429
+ }
430
+
431
+ feeds , count , err := activities_model .GetFeeds (ctx , opts )
432
+ if err != nil {
433
+ ctx .Error (http .StatusInternalServerError , "GetFeeds" , err )
434
+ return
435
+ }
436
+ ctx .SetTotalCountHeader (count )
437
+
438
+ ctx .JSON (http .StatusOK , convert .ToActivities (ctx , feeds , ctx .Doer ))
439
+ }
0 commit comments