mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat(api): added schema for email unsubscribe token
This commit is contained in:
@@ -1,8 +1,51 @@
|
|||||||
# TODO: Need GET route here as well
|
get:
|
||||||
|
tags:
|
||||||
|
- emails
|
||||||
|
summary: Unsubscribe user from email type (user variant)
|
||||||
|
parameters:
|
||||||
|
- name: token
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
example: testToken
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ""
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- type: object
|
||||||
|
properties:
|
||||||
|
payload:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
uid:
|
||||||
|
type: number
|
||||||
|
template:
|
||||||
|
type: string
|
||||||
|
description: The type of email template to unsubscribe from.
|
||||||
|
enum:
|
||||||
|
- digest
|
||||||
|
- notification
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
description: Only used if `template` is `notification`, signifies the type of notification to unsubscribe from.
|
||||||
|
nullable: true
|
||||||
|
iat:
|
||||||
|
type: number
|
||||||
|
description: Reflection of the token's "issued at" claim
|
||||||
|
required:
|
||||||
|
- uid
|
||||||
|
- template
|
||||||
|
- $ref: ../../../components/schemas/CommonProps.yaml#/CommonProps
|
||||||
|
"500":
|
||||||
|
description: "Server-side error (likely token verification failure)"
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- emails
|
- emails
|
||||||
summary: Unsubscribe user from email type
|
summary: Unsubscribe user from email type (auto variant)
|
||||||
parameters:
|
parameters:
|
||||||
- name: token
|
- name: token
|
||||||
in: path
|
in: path
|
||||||
|
|||||||
14
test/api.js
14
test/api.js
@@ -7,6 +7,7 @@ const fs = require('fs');
|
|||||||
const SwaggerParser = require('@apidevtools/swagger-parser');
|
const SwaggerParser = require('@apidevtools/swagger-parser');
|
||||||
const request = require('request-promise-native');
|
const request = require('request-promise-native');
|
||||||
const nconf = require('nconf');
|
const nconf = require('nconf');
|
||||||
|
const jwt = require('jsonwebtoken');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const wait = util.promisify(setTimeout);
|
const wait = util.promisify(setTimeout);
|
||||||
|
|
||||||
@@ -34,7 +35,18 @@ describe('API', async () => {
|
|||||||
|
|
||||||
const mocks = {
|
const mocks = {
|
||||||
head: {},
|
head: {},
|
||||||
get: {},
|
get: {
|
||||||
|
'/api/email/unsubscribe/{token}': [
|
||||||
|
{
|
||||||
|
in: 'path',
|
||||||
|
name: 'token',
|
||||||
|
example: (() => jwt.sign({
|
||||||
|
template: 'digest',
|
||||||
|
uid: 1,
|
||||||
|
}, nconf.get('secret')))(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
post: {},
|
post: {},
|
||||||
put: {},
|
put: {},
|
||||||
delete: {
|
delete: {
|
||||||
|
|||||||
Reference in New Issue
Block a user