Finish mailboxes view
This commit is contained in:
@@ -32,7 +32,7 @@ function create() {
|
||||
async remove(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/app_passwords/${id}`, { access_token: accessToken });
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/app_passwords/${id}`, null, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ function create() {
|
||||
async remove(id) {
|
||||
let result;
|
||||
try {
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/applinks/${id}`, { access_token: accessToken });
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/applinks/${id}`, null, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
return [e];
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ function create() {
|
||||
async remove(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/archives/${id}`, { access_token: accessToken });
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/archives/${id}`, null, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ export function createDirectoryModel(origin, accessToken, api) {
|
||||
await fetcher.post(`${origin}/api/v1/${api}/files/${folderPath}`, {}, { directory: true, access_token: accessToken });
|
||||
},
|
||||
async remove(filePath) {
|
||||
await fetcher.del(`${origin}/api/v1/${api}/files/${filePath}`, { access_token: accessToken });
|
||||
await fetcher.del(`${origin}/api/v1/${api}/files/${filePath}`, null, { access_token: accessToken });
|
||||
},
|
||||
async rename(fromFilePath, toFilePath, overwrite = false) {
|
||||
return await fetcher.put(`${origin}/api/v1/${api}/files/${fromFilePath}`, { action: 'rename', newFilePath: sanitize(toFilePath), overwrite }, { access_token: accessToken });
|
||||
|
||||
@@ -67,7 +67,7 @@ function create() {
|
||||
async remove(domain) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/domains/${domain}`, { access_token: accessToken });
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/domains/${domain}`, null, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ function create() {
|
||||
async remove(id) {
|
||||
let result;
|
||||
try {
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/groups/${id}`, { access_token: accessToken });
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/groups/${id}`, null, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
return [e];
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ function create() {
|
||||
name: 'ProfileModel',
|
||||
async logout() {
|
||||
// destroy oidc session in the spirit of true SSO
|
||||
await fetcher.del(`${API_ORIGIN}/api/v1/oidc/sessions`, { access_token: accessToken });
|
||||
await fetcher.del(`${API_ORIGIN}/api/v1/oidc/sessions`, null, { access_token: accessToken });
|
||||
|
||||
localStorage.removeItem('token');
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ function create() {
|
||||
async remove(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/tokens/${id}`, { access_token: accessToken });
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/tokens/${id}`, null, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ function create() {
|
||||
async removeOpenIdClient(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/oidc/clients/${id}`, { access_token: accessToken });
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/oidc/clients/${id}`, null, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ function create() {
|
||||
async remove(id) {
|
||||
let result;
|
||||
try {
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/users/${id}`, { access_token: accessToken });
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/users/${id}`, null, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
return [e];
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ function create() {
|
||||
async remove(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/volumes/${id}`, { access_token: accessToken });
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/volumes/${id}`, null, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user