mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Add activity feeds API (#23494)
Close #5666 Add APIs for getting activity feeds.
This commit is contained in:
		@@ -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))
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user