Skip to content

Node.js based forum software built for the modern web

feat(api): added schema for email unsubscribe token

Julian Lam4fc1337762da
diff --git a/public/openapi/read/email/unsubscribe/token.yaml b/public/openapi/read/email/unsubscribe/token.yaml
index 71c02c8809..3b1c9deaf8 100644
--- a/public/openapi/read/email/unsubscribe/token.yaml
+++ b/public/openapi/read/email/unsubscribe/token.yaml
@@ -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:
tags:
- emails
- summary: Unsubscribe user from email type
+ summary: Unsubscribe user from email type (auto variant)
parameters:
- name: token
in: path
diff --git a/test/api.js b/test/api.js
index 3cfa700d60..7d81b55c04 100644
--- a/test/api.js
+++ b/test/api.js
@@ -7,6 +7,7 @@ const fs = require('fs');
const SwaggerParser = require('@apidevtools/swagger-parser');
const request = require('request-promise-native');
const nconf = require('nconf');
+const jwt = require('jsonwebtoken');
const util = require('util');
const wait = util.promisify(setTimeout);
@@ -34,7 +35,18 @@ describe('API', async () => {
const mocks = {
head: {},
- get: {},
+ get: {
+ '/api/email/unsubscribe/{token}': [
+ {
+ in: 'path',
+ name: 'token',
+ example: (() => jwt.sign({
+ template: 'digest',
+ uid: 1,
+ }, nconf.get('secret')))(),
+ },
+ ],
+ },
post: {},
put: {},
delete: {