Finish mailboxes view
This commit is contained in:
@@ -17,6 +17,80 @@ function create() {
|
||||
if (result.status !== 200) return [result];
|
||||
return [null, result.body.mailboxes];
|
||||
},
|
||||
async get(domain, name) {
|
||||
let result;
|
||||
try {
|
||||
result = await fetcher.get(`${API_ORIGIN}/api/v1/mail/${domain}/mailboxes/${name}`, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
return [e];
|
||||
}
|
||||
|
||||
if (result.status !== 200) return [result];
|
||||
return [null, result.body.mailbox];
|
||||
},
|
||||
async add(domain, name, options) {
|
||||
const data = {
|
||||
name: name,
|
||||
ownerId: options.ownerId,
|
||||
ownerType: options.ownerType,
|
||||
active: !!options.active,
|
||||
enablePop3: !!options.enablePop3,
|
||||
storageQuota: options.storageQuota ||0,
|
||||
messagesQuota: options.messagesQuota || 0,
|
||||
};
|
||||
|
||||
let result;
|
||||
try {
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/mail/${domain}/mailboxes`, data, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
return [e];
|
||||
}
|
||||
|
||||
if (result.status !== 201) return [result];
|
||||
return [null];
|
||||
},
|
||||
async update(domain, name, options) {
|
||||
const data = {
|
||||
ownerId: options.ownerId,
|
||||
ownerType: options.ownerType,
|
||||
active: !!options.active,
|
||||
enablePop3: !!options.enablePop3,
|
||||
storageQuota: options.storageQuota ||0,
|
||||
messagesQuota: options.messagesQuota || 0,
|
||||
};
|
||||
|
||||
let result;
|
||||
try {
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/mail/${domain}/mailboxes/${name}`, data, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
return [e];
|
||||
}
|
||||
|
||||
if (result.status !== 204) return [result];
|
||||
return [null];
|
||||
},
|
||||
async remove(domain, name, deleteMails = false) {
|
||||
let result;
|
||||
try {
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/mail/${domain}/mailboxes/${name}`, { deleteMails }, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
return [e];
|
||||
}
|
||||
|
||||
if (result.status !== 201) return [result];
|
||||
return [null];
|
||||
},
|
||||
async setAliases(domain, name, aliases) {
|
||||
let result;
|
||||
try {
|
||||
result = await fetcher.put(`${API_ORIGIN}/api/v1/mail/${domain}/mailboxes/${name}/aliases`, { aliases }, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
return [e];
|
||||
}
|
||||
|
||||
if (result.status !== 202) return [result];
|
||||
return [null];
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user