Skip to content

Commit

Permalink
added Delete a Mailbox endpoint to API generation. Add example to Req…
Browse files Browse the repository at this point in the history
…uest Mailbox information API endpoint
  • Loading branch information
NickOvt committed Jan 8, 2024
1 parent 74ebc82 commit 910b9c7
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions lib/api/mailboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,10 @@ module.exports = (db, server, mailboxHandler) => {
path: Joi.string()
.required()
.description('Full path of the mailbox, folders are separated by slashes, ends with the mailbox name (unicode string)'),
specialUse: Joi.string().required().description('Either special use identifier or null. One of Drafts, Junk, Sent or Trash'),
specialUse: Joi.string()
.required()
.example('\\Draft')
.description('Either special use identifier or null. One of Drafts, Junk, Sent or Trash'),
modifyIndex: Joi.number().required().description('Modification sequence number. Incremented on every change in the mailbox.'),
subscribed: booleanSchema.required().description('Mailbox subscription status. IMAP clients may unsubscribe from a folder.'),
hidden: booleanSchema.required().description('Is the folder hidden or not'),
Expand Down Expand Up @@ -620,15 +623,33 @@ module.exports = (db, server, mailboxHandler) => {
);

server.del(
'/users/:user/mailboxes/:mailbox',
{
path: '/users/:user/mailboxes/:mailbox',
summary: 'Delete a Mailbox',
tags: ['Mailboxes'],
validationObjs: {
requestBody: { user: userId, mailbox: mailboxId },
queryParams: { sess: sessSchema, ip: sessIPSchema },
pathParams: {},
response: {
200: {
description: 'Success',
model: Joi.object({
success: successRes
})
}
}
}
},
tools.responseWrapper(async (req, res) => {
res.charSet('utf-8');

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

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

const result = schema.validate(req.params, {
Expand Down

0 comments on commit 910b9c7

Please sign in to comment.