/
reject_leave_requests.go
54 lines (51 loc) · 1.85 KB
/
reject_leave_requests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package groups
import (
"net/http"
"github.com/France-ioi/AlgoreaBackend/app/service"
)
// swagger:operation POST /groups/{parent_group_id}/leave-requests/reject group-memberships groupLeaveRequestsReject
//
// ---
// summary: Reject group leave requests
// description:
// Lets an admin reject requests (of users with ids in {group_ids}) to leave a group (identified by {parent_group_id}).
// On success the service removes rows with `type` = 'leave_request' from `group_pending_requests` and
// creates new rows with `action` = 'leave_request_refused' and `at` = current UTC time in `group_membership_changes`
// for each of `group_ids`.
//
//
// The authenticated user should be a manager of the `parent_group_id` with `can_manage` >= 'memberships',
// otherwise the 'forbidden' error is returned. If the group is a user, the 'forbidden' error is returned as well.
//
//
// There should be a row with `type` = 'leave_request' and `group_id` = `{parent_group_id}`
// in `group_pending_requests` for each of the input `group_ids`, otherwise the `group_id` gets skipped with
// `invalid` as the result.
//
//
// The response status code on success (200) doesn't depend on per-group results.
// parameters:
// - name: parent_group_id
// in: path
// type: integer
// required: true
// - name: group_ids
// in: query
// type: array
// items:
// type: integer
// required: true
// responses:
// "200":
// "$ref": "#/responses/updatedGroupRelationsResponse"
// "400":
// "$ref": "#/responses/badRequestResponse"
// "401":
// "$ref": "#/responses/unauthorizedResponse"
// "403":
// "$ref": "#/responses/forbiddenResponse"
// "500":
// "$ref": "#/responses/internalErrorResponse"
func (srv *Service) rejectLeaveRequests(w http.ResponseWriter, r *http.Request) service.APIError {
return srv.performBulkMembershipAction(w, r, rejectLeaveRequestsAction)
}