gitea源码

block.go 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // Copyright 2024 The Gitea Authors.
  2. // SPDX-License-Identifier: MIT
  3. package org
  4. import (
  5. "code.gitea.io/gitea/routers/api/v1/shared"
  6. "code.gitea.io/gitea/services/context"
  7. )
  8. func ListBlocks(ctx *context.APIContext) {
  9. // swagger:operation GET /orgs/{org}/blocks organization organizationListBlocks
  10. // ---
  11. // summary: List users blocked by the organization
  12. // parameters:
  13. // - name: org
  14. // in: path
  15. // description: name of the organization
  16. // type: string
  17. // required: true
  18. // - name: page
  19. // in: query
  20. // description: page number of results to return (1-based)
  21. // type: integer
  22. // - name: limit
  23. // in: query
  24. // description: page size of results
  25. // type: integer
  26. // produces:
  27. // - application/json
  28. // responses:
  29. // "200":
  30. // "$ref": "#/responses/UserList"
  31. shared.ListBlocks(ctx, ctx.Org.Organization.AsUser())
  32. }
  33. func CheckUserBlock(ctx *context.APIContext) {
  34. // swagger:operation GET /orgs/{org}/blocks/{username} organization organizationCheckUserBlock
  35. // ---
  36. // summary: Check if a user is blocked by the organization
  37. // parameters:
  38. // - name: org
  39. // in: path
  40. // description: name of the organization
  41. // type: string
  42. // required: true
  43. // - name: username
  44. // in: path
  45. // description: username of the user to check
  46. // type: string
  47. // required: true
  48. // responses:
  49. // "204":
  50. // "$ref": "#/responses/empty"
  51. // "404":
  52. // "$ref": "#/responses/notFound"
  53. shared.CheckUserBlock(ctx, ctx.Org.Organization.AsUser())
  54. }
  55. func BlockUser(ctx *context.APIContext) {
  56. // swagger:operation PUT /orgs/{org}/blocks/{username} organization organizationBlockUser
  57. // ---
  58. // summary: Block a user
  59. // parameters:
  60. // - name: org
  61. // in: path
  62. // description: name of the organization
  63. // type: string
  64. // required: true
  65. // - name: username
  66. // in: path
  67. // description: username of the user to block
  68. // type: string
  69. // required: true
  70. // - name: note
  71. // in: query
  72. // description: optional note for the block
  73. // type: string
  74. // responses:
  75. // "204":
  76. // "$ref": "#/responses/empty"
  77. // "404":
  78. // "$ref": "#/responses/notFound"
  79. // "422":
  80. // "$ref": "#/responses/validationError"
  81. shared.BlockUser(ctx, ctx.Org.Organization.AsUser())
  82. }
  83. func UnblockUser(ctx *context.APIContext) {
  84. // swagger:operation DELETE /orgs/{org}/blocks/{username} organization organizationUnblockUser
  85. // ---
  86. // summary: Unblock a user
  87. // parameters:
  88. // - name: org
  89. // in: path
  90. // description: name of the organization
  91. // type: string
  92. // required: true
  93. // - name: username
  94. // in: path
  95. // description: username of the user to unblock
  96. // type: string
  97. // required: true
  98. // responses:
  99. // "204":
  100. // "$ref": "#/responses/empty"
  101. // "404":
  102. // "$ref": "#/responses/notFound"
  103. // "422":
  104. // "$ref": "#/responses/validationError"
  105. shared.UnblockUser(ctx, ctx.Doer, ctx.Org.Organization.AsUser())
  106. }