fetching mailboxes from api
This commit is contained in:
20
back/controllers/addMailbox.js
Normal file
20
back/controllers/addMailbox.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const statusCode = require("../utils/statusCodes").statusCodes;
|
||||
const { registerMailbox } = require("../db/api");
|
||||
const { getAddresseId } = require("../db/mail");
|
||||
|
||||
async function addMailbox(body, res) {
|
||||
const { email, pwd, xoauth, xoauth2, host, port, tls } = body;
|
||||
getAddresseId(email).then((addressId) => {
|
||||
registerMailbox(addressId, pwd, xoauth, xoauth2, host, port, tls)
|
||||
.then((mailboxId) => {
|
||||
res.status(statusCode.OK).json({ id: mailboxId });
|
||||
})
|
||||
.catch(() => {
|
||||
res.status(statusCode.INTERNAL_SERVER_ERROR);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
addMailbox,
|
||||
};
|
||||
Reference in New Issue
Block a user