mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-11-01 06:51:18 +00:00
[MODERATION] add user blocking API
- Follow up for: #540, #802 - Add API routes for user blocking from user and organization perspective. - The new routes have integration testing. - The new model functions have unit tests. - Actually quite boring to write and to read this pull request. (cherry picked from commitf3afaf15c7) (cherry picked from commit6d754db3e5) (cherry picked from commitd0fc8bc9d3) (cherry picked from commit9a53b0d1a0) (cherry picked from commit44a2a4fd48) (cherry picked from commit182025db9c) (cherry picked from commit558a35963e)
This commit is contained in:
parent
cdf6318f51
commit
73776d6195
12 changed files with 626 additions and 9 deletions
|
|
@ -202,3 +202,80 @@ func ListUserActivityFeeds(ctx *context.APIContext) {
|
|||
|
||||
ctx.JSON(http.StatusOK, convert.ToActivities(ctx, feeds, ctx.Doer))
|
||||
}
|
||||
|
||||
// ListBlockedUsers list the authenticated user's blocked users.
|
||||
func ListBlockedUsers(ctx *context.APIContext) {
|
||||
// swagger:operation GET /user/list_blocked user userListBlockedUsers
|
||||
// ---
|
||||
// summary: List the authenticated user's blocked users
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - 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/BlockedUserList"
|
||||
|
||||
utils.ListUserBlockedUsers(ctx, ctx.Doer)
|
||||
}
|
||||
|
||||
// BlockUser blocks a user from the doer.
|
||||
func BlockUser(ctx *context.APIContext) {
|
||||
// swagger:operation PUT /user/block/{username} user userBlockUser
|
||||
// ---
|
||||
// summary: Blocks a user from the doer.
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: username
|
||||
// in: path
|
||||
// description: username of the user
|
||||
// type: string
|
||||
// required: true
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
user := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
|
||||
utils.BlockUser(ctx, ctx.Doer, user)
|
||||
}
|
||||
|
||||
// UnblockUser unblocks a user from the doer.
|
||||
func UnblockUser(ctx *context.APIContext) {
|
||||
// swagger:operation PUT /user/unblock/{username} user userUnblockUser
|
||||
// ---
|
||||
// summary: Unblocks a user from the doer.
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: username
|
||||
// in: path
|
||||
// description: username of the user
|
||||
// type: string
|
||||
// required: true
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
user := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
|
||||
utils.UnblockUser(ctx, ctx.Doer, user)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue