diff options
author | Zettat123 <zettat123@gmail.com> | 2023-04-04 21:35:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-04 21:35:31 +0800 |
commit | 6b0df6d8da76d77a9b5c42dcfa78dbfe197fd56d (patch) | |
tree | 6d78855ec0f8e4bed42a0ae7587687a4755b6536 /routers/api/v1/user | |
parent | d149093ce3c32503b95c66208de6cb5861e4e666 (diff) | |
download | gitea-6b0df6d8da76d77a9b5c42dcfa78dbfe197fd56d.tar.gz gitea-6b0df6d8da76d77a9b5c42dcfa78dbfe197fd56d.zip |
Add activity feeds API (#23494)
Close #5666
Add APIs for getting activity feeds.
Diffstat (limited to 'routers/api/v1/user')
-rw-r--r-- | routers/api/v1/user/user.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index 6fd4b3a95c..314116962b 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -145,3 +145,60 @@ func GetUserHeatmapData(ctx *context.APIContext) { } ctx.JSON(http.StatusOK, heatmap) } + +func ListUserActivityFeeds(ctx *context.APIContext) { + // swagger:operation GET /users/{username}/activities/feeds user userListActivityFeeds + // --- + // summary: List a user's activity feeds + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of user + // type: string + // required: true + // - name: only-performed-by + // in: query + // description: if true, only show actions performed by the requested user + // type: boolean + // - name: date + // in: query + // description: the date of the activities to be found + // type: string + // format: date + // - name: page + // in: query + // description: page number of results to return (1-based) + // type: integer + // - name: limit + // in: query + // description: page size of results + // type: integer + // responses: + // "200": + // "$ref": "#/responses/ActivityFeedsList" + // "404": + // "$ref": "#/responses/notFound" + + includePrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID) + listOptions := utils.GetListOptions(ctx) + + opts := activities_model.GetFeedsOptions{ + RequestedUser: ctx.ContextUser, + Actor: ctx.Doer, + IncludePrivate: includePrivate, + OnlyPerformedBy: ctx.FormBool("only-performed-by"), + Date: ctx.FormString("date"), + ListOptions: listOptions, + } + + feeds, count, err := activities_model.GetFeeds(ctx, opts) + if err != nil { + ctx.Error(http.StatusInternalServerError, "GetFeeds", err) + return + } + ctx.SetTotalCountHeader(count) + + ctx.JSON(http.StatusOK, convert.ToActivities(ctx, feeds, ctx.Doer)) +} |