Finish mailboxes view

This commit is contained in:
Johannes Zellner
2025-03-14 18:48:13 +01:00
parent 44b02961ac
commit 9676cabcb8
17 changed files with 377 additions and 49 deletions
+74
View File
@@ -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];
},
};
}