Updated to latest Index as well as some minor bug fixes.
This commit is contained in:
parent
ad89d45cf0
commit
5ba8b30047
77 changed files with 900 additions and 937 deletions
assets
|
@ -1,4 +1,12 @@
|
|||
const MszCommentsApi = (() => {
|
||||
const argsToFormData = args => {
|
||||
const formData = new FormData;
|
||||
for(const name in args)
|
||||
formData.append(name, args[name]);
|
||||
|
||||
return formData;
|
||||
};
|
||||
|
||||
return {
|
||||
getCategory: async name => {
|
||||
if(typeof name !== 'string' || name.trim() === '')
|
||||
|
@ -62,7 +70,7 @@ const MszCommentsApi = (() => {
|
|||
const { status, body } = await $xhr.post(
|
||||
'/comments/posts',
|
||||
{ csrf: true, type: 'json' },
|
||||
args
|
||||
argsToFormData(args)
|
||||
);
|
||||
if(status !== 201)
|
||||
throw new Error(body.error?.text ?? 'something went wrong', { cause: body.error?.name ?? 'something' });
|
||||
|
@ -75,10 +83,10 @@ const MszCommentsApi = (() => {
|
|||
if(typeof args !== 'object' || args === null)
|
||||
throw new Error('args must be a non-null object');
|
||||
|
||||
const { status, body } = await $xhr.post(
|
||||
const { status, body } = await $xhr.patch(
|
||||
`/comments/posts/${post}`,
|
||||
{ csrf: true, type: 'json' },
|
||||
args
|
||||
argsToFormData(args)
|
||||
);
|
||||
if(status !== 200)
|
||||
throw new Error(body.error?.text ?? 'something went wrong', { cause: body.error?.name ?? 'something' });
|
||||
|
|
|
@ -52,7 +52,7 @@ const MszMessages = () => {
|
|||
formData.append('format', format);
|
||||
formData.append('draft', draft);
|
||||
|
||||
const { body } = await $xhr.post(`/messages/${encodeURIComponent(messageId)}`, { type: 'json', csrf: true }, formData);
|
||||
const { body } = await $xhr.patch(`/messages/${encodeURIComponent(messageId)}`, { type: 'json', csrf: true }, formData);
|
||||
if(body.error !== undefined)
|
||||
throw body.error;
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ const MszOAuth2Authorise = async () => {
|
|||
params.scope = scope;
|
||||
|
||||
try {
|
||||
const { body } = await $xhr.post('/oauth2/authorise', { authed: true, csrf: true, type: 'json' }, params);
|
||||
const { body } = await $xhr.post('/oauth2/authorize', { authed: true, csrf: true, type: 'json' }, params);
|
||||
if(!body)
|
||||
throw 'authorisation failed';
|
||||
if(typeof body.error === 'string')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue