Skip to content

Commit 74ebc82

Browse files
committed
Update Mailbox information endpoint added to API generation
1 parent 79c3b57 commit 74ebc82

File tree

1 file changed

+38
-10
lines changed

1 file changed

+38
-10
lines changed

Diff for: lib/api/mailboxes.js

+38-10
Original file line numberDiff line numberDiff line change
@@ -528,19 +528,47 @@ module.exports = (db, server, mailboxHandler) => {
528528
);
529529

530530
server.put(
531-
'/users/:user/mailboxes/:mailbox',
531+
{
532+
path: '/users/:user/mailboxes/:mailbox',
533+
summary: 'Update Mailbox information',
534+
tags: ['Mailboxes'],
535+
validationObjs: {
536+
requestBody: {
537+
path: Joi.string()
538+
.regex(/\/{2,}|\/$/, { invert: true })
539+
.description('Full path of the mailbox, use this to rename an existing Mailbox'),
540+
retention: Joi.number()
541+
.empty('')
542+
.min(0)
543+
.description(
544+
'Retention policy for the Mailbox (in ms). Changing retention value only affects messages added to this folder after the change'
545+
),
546+
subscribed: booleanSchema.description('Change Mailbox subscription state'),
547+
hidden: booleanSchema.description('Is the folder hidden or not. Hidden folders can not be opened in IMAP.'),
548+
sess: sessSchema,
549+
ip: sessIPSchema
550+
},
551+
pathParams: { user: userId, mailbox: mailboxId },
552+
queryParams: {},
553+
response: {
554+
200: {
555+
description: 'Success',
556+
model: Joi.object({
557+
success: successRes
558+
})
559+
}
560+
}
561+
}
562+
},
532563
tools.responseWrapper(async (req, res) => {
533564
res.charSet('utf-8');
534565

535-
const schema = Joi.object().keys({
536-
user: Joi.string().hex().lowercase().length(24).required(),
537-
mailbox: Joi.string().hex().lowercase().length(24).required(),
538-
path: Joi.string().regex(/\/{2,}|\/$/, { invert: true }),
539-
retention: Joi.number().empty('').min(0),
540-
subscribed: booleanSchema,
541-
hidden: booleanSchema,
542-
sess: sessSchema,
543-
ip: sessIPSchema
566+
const { pathParams, requestBody, queryParams } = req.route.spec.validationObjs;
567+
568+
const schema = Joi.object({
569+
...pathParams,
570+
...requestBody,
571+
...queryParams
544572
});
545573

546574
const result = schema.validate(req.params, {

0 commit comments

Comments
 (0)