mirror of
https://github.com/go-gitea/gitea
synced 2024-11-14 06:04:25 +00:00
c337ff0ec7
Fixes #17453 This PR adds the abbility to block a user from a personal account or organization to restrict how the blocked user can interact with the blocker. The docs explain what's the consequence of blocking a user. Screenshots: ![grafik](https://github.com/go-gitea/gitea/assets/1666336/4ed884f3-e06a-4862-afd3-3b8aa2488dc6) ![grafik](https://github.com/go-gitea/gitea/assets/1666336/ae6d4981-f252-4f50-a429-04f0f9f1cdf1) ![grafik](https://github.com/go-gitea/gitea/assets/1666336/ca153599-5b0f-4b4a-90fe-18bdfd6f0b6b) --------- Co-authored-by: Lauris BH <lauris@nix.lv>
97 lines
2.2 KiB
Go
97 lines
2.2 KiB
Go
// Copyright 2024 The Gitea Authors.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package user
|
|
|
|
import (
|
|
"code.gitea.io/gitea/routers/api/v1/shared"
|
|
"code.gitea.io/gitea/services/context"
|
|
)
|
|
|
|
func ListBlocks(ctx *context.APIContext) {
|
|
// swagger:operation GET /user/blocks user userListBlocks
|
|
// ---
|
|
// summary: List users blocked by the authenticated user
|
|
// 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
|
|
// produces:
|
|
// - application/json
|
|
// responses:
|
|
// "200":
|
|
// "$ref": "#/responses/UserList"
|
|
|
|
shared.ListBlocks(ctx, ctx.Doer)
|
|
}
|
|
|
|
func CheckUserBlock(ctx *context.APIContext) {
|
|
// swagger:operation GET /user/blocks/{username} user userCheckUserBlock
|
|
// ---
|
|
// summary: Check if a user is blocked by the authenticated user
|
|
// parameters:
|
|
// - name: username
|
|
// in: path
|
|
// description: user to check
|
|
// type: string
|
|
// required: true
|
|
// responses:
|
|
// "204":
|
|
// "$ref": "#/responses/empty"
|
|
// "404":
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
shared.CheckUserBlock(ctx, ctx.Doer)
|
|
}
|
|
|
|
func BlockUser(ctx *context.APIContext) {
|
|
// swagger:operation PUT /user/blocks/{username} user userBlockUser
|
|
// ---
|
|
// summary: Block a user
|
|
// parameters:
|
|
// - name: username
|
|
// in: path
|
|
// description: user to block
|
|
// type: string
|
|
// required: true
|
|
// - name: note
|
|
// in: query
|
|
// description: optional note for the block
|
|
// type: string
|
|
// responses:
|
|
// "204":
|
|
// "$ref": "#/responses/empty"
|
|
// "404":
|
|
// "$ref": "#/responses/notFound"
|
|
// "422":
|
|
// "$ref": "#/responses/validationError"
|
|
|
|
shared.BlockUser(ctx, ctx.Doer)
|
|
}
|
|
|
|
func UnblockUser(ctx *context.APIContext) {
|
|
// swagger:operation DELETE /user/blocks/{username} user userUnblockUser
|
|
// ---
|
|
// summary: Unblock a user
|
|
// parameters:
|
|
// - name: username
|
|
// in: path
|
|
// description: user to unblock
|
|
// type: string
|
|
// required: true
|
|
// responses:
|
|
// "204":
|
|
// "$ref": "#/responses/empty"
|
|
// "404":
|
|
// "$ref": "#/responses/notFound"
|
|
// "422":
|
|
// "$ref": "#/responses/validationError"
|
|
|
|
shared.UnblockUser(ctx, ctx.Doer, ctx.Doer)
|
|
}
|