feat: invites regardless of registration type, invite privilege, groups to join on acceptance (#8786)

* feat: allow invites in normal registration mode + invite privilege

* feat: select groups to join from an invite

* test: check if groups from invitations have been joined

* fix: remove unused variable

* feat: write API versions of socket calls

* docs: openapi specs for the new routes

* test: iron out mongo redis difference

* refactor: move inviteGroups endpoint into write API

* refactor: use GET /api/v3/users/:uid/invites/groups

Instead of GET /api/v3/users/:uid/inviteGroups

* fix: no need for /api/v3 prefix when using api module

* fix: tests

* refactor: change POST /api/v3/users/invite

To POST /api/v3/users/:uid/invites

* refactor: make helpers.invite awaitable

* fix: restrict invite API to self-use only

* fix: move invite groups controller to write api, +tests

* fix: tests

Co-authored-by: Julian Lam <julian@nodebb.org>
This commit is contained in:
gasoved
2020-11-16 22:47:23 +03:00
committed by GitHub
parent dde9f1890f
commit 3ccebf112e
23 changed files with 725 additions and 220 deletions

View File

@@ -0,0 +1,48 @@
post:
tags:
- users
summary: invite users with email by email
description: This operation sends an invitation email to the given addresses, with an option to join selected groups on acceptance
parameters:
- in: path
name: uid
schema:
type: integer
required: true
description: uid of the user sending invitations
example: 1
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
emails:
type: string
description: A single or list of comma separated email addresses
example: friend01@example.com,friend02@example.com
groupsToJoin:
type: array
description: A collection of group names
example: ['administrators']
required:
- emails
responses:
'200':
description: invitation email(s) sent
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
'400':
$ref: ../../../components/responses/400.yaml#/400
'401':
$ref: ../../../components/responses/401.yaml#/401
'403':
$ref: ../../../components/responses/403.yaml#/403

View File

@@ -0,0 +1,23 @@
get:
tags:
- users
summary: Get group names that the user can invite
parameters:
- in: path
name: uid
schema:
type: integer
required: true
description: uid of the user to make the query for
example: 1
responses:
'200':
description: A collection of group names returned
content:
application/json:
schema:
type: array
items:
type: string
'401':
$ref: ../../../../components/responses/401.yaml#/401