Skip to content

Commit

Permalink
fix(api-users-updates): added users/updates api endpoint to api docs …
Browse files Browse the repository at this point in the history
…generation ZMS-155 (#687)

* Added submission api endpoint to api docs generation

* added users updates api endpoin to api docs generation
  • Loading branch information
NickOvt authored May 9, 2024
1 parent e9abf85 commit 490b4e5
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions lib/api/updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,39 @@ const tools = require('../tools');
const roles = require('../roles');
const base32 = require('base32.js');
const { sessSchema, sessIPSchema } = require('../schemas');
const { userId } = require('../schemas/request/general-schemas');

module.exports = (db, server, notifier) => {
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) => {
res.charSet('utf-8');

const schema = Joi.object().keys({
user: Joi.string().hex().lowercase().length(24).required(),
'Last-Event-ID': Joi.string().hex().lowercase().length(24),
sess: sessSchema,
ip: sessIPSchema
const { pathParams, requestBody, queryParams } = req.route.spec.validationObjs;

const schema = Joi.object({
...pathParams,
...requestBody,
...queryParams
});

if (req.header('Last-Event-ID')) {
Expand Down

0 comments on commit 490b4e5

Please sign in to comment.