fix(api-users-updates): added users/updates api endpoint to api docs generation ZMS-155 (#687)

* Added submission api endpoint to api docs generation

* added users updates api endpoin to api docs generation
This commit is contained in:
NickOvt 2024-05-09 11:13:21 +03:00 committed by GitHub
parent e9abf8581f
commit 490b4e5118
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,18 +7,39 @@ const tools = require('../tools');
const roles = require('../roles'); const roles = require('../roles');
const base32 = require('base32.js'); const base32 = require('base32.js');
const { sessSchema, sessIPSchema } = require('../schemas'); const { sessSchema, sessIPSchema } = require('../schemas');
const { userId } = require('../schemas/request/general-schemas');
module.exports = (db, server, notifier) => { module.exports = (db, server, notifier) => {
server.get( server.get(
'/users/:user/updates', {
path: '/users/:user/updates',
tags: ['Users'],
summary: 'Open change stream',
description:
'This api call returns an EventSource response. Listen on this stream to get notifications about changes in messages and mailboxes. Returned events are JSON encoded strings',
validationObjs: {
requestBody: {},
queryParams: {
'Last-Event-ID': Joi.string().hex().lowercase().length(24).description('Last event ID header as query param'),
sess: sessSchema,
ip: sessIPSchema
},
pathParams: {
user: userId
},
response: { 200: { description: 'Success', model: Joi.string() } }
},
responseType: 'text/event-stream'
},
tools.responseWrapper(async (req, res) => { tools.responseWrapper(async (req, res) => {
res.charSet('utf-8'); res.charSet('utf-8');
const schema = Joi.object().keys({ const { pathParams, requestBody, queryParams } = req.route.spec.validationObjs;
user: Joi.string().hex().lowercase().length(24).required(),
'Last-Event-ID': Joi.string().hex().lowercase().length(24), const schema = Joi.object({
sess: sessSchema, ...pathParams,
ip: sessIPSchema ...requestBody,
...queryParams
}); });
if (req.header('Last-Event-ID')) { if (req.header('Last-Event-ID')) {