19 lines
644 B
TypeScript
19 lines
644 B
TypeScript
import statusCode from "../utils/statusCodes";
|
|
import { registerAccount } from "../db/api";
|
|
import { getAddresseId } from "../db/utils/mail";
|
|
|
|
export async function addAccount(body, res) {
|
|
const { email, pwd, xoauth, xoauth2, host, port, tls } = body;
|
|
getAddresseId(email).then((addressId) => {
|
|
registerAccount(addressId, pwd, xoauth, xoauth2, host, port, tls)
|
|
.then((mailboxId) => {
|
|
res.status(statusCode.OK).json({ id: mailboxId });
|
|
})
|
|
.catch(() => {
|
|
res.status(statusCode.INTERNAL_SERVER_ERROR);
|
|
});
|
|
});
|
|
}
|
|
|
|
// todo change mailbox to account
|