chore: formatting
This commit is contained in:
parent
4e84d45a20
commit
e9d55ff44b
4 changed files with 16 additions and 13 deletions
|
@ -71,9 +71,9 @@ mastoRouter.use(
|
||||||
mastoRouter.use(async (ctx, next) => {
|
mastoRouter.use(async (ctx, next) => {
|
||||||
if (ctx.request.query) {
|
if (ctx.request.query) {
|
||||||
if (!ctx.request.body || Object.keys(ctx.request.body).length === 0) {
|
if (!ctx.request.body || Object.keys(ctx.request.body).length === 0) {
|
||||||
ctx.request.body = ctx.request.query
|
ctx.request.body = ctx.request.query;
|
||||||
} else {
|
} else {
|
||||||
ctx.request.body = {...ctx.request.body, ...ctx.request.query}
|
ctx.request.body = { ...ctx.request.body, ...ctx.request.query };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await next();
|
await next();
|
||||||
|
|
|
@ -79,14 +79,17 @@ export function apiAccountMastodon(router: Router): void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (userArray.length === 1) {
|
if (userArray.length === 1) {
|
||||||
const q: FindOptionsWhere<User> = { usernameLower: userArray[0].toLowerCase(), host: IsNull() };
|
const q: FindOptionsWhere<User> = {
|
||||||
|
usernameLower: userArray[0].toLowerCase(),
|
||||||
|
host: IsNull(),
|
||||||
|
};
|
||||||
|
|
||||||
const user = await Users.findOneBy(q);
|
const user = await Users.findOneBy(q);
|
||||||
userid = user?.id;
|
userid = user?.id;
|
||||||
} else {
|
} else {
|
||||||
userid = (await resolveUser(userArray[0], userArray[1])).id;
|
userid = (await resolveUser(userArray[0], userArray[1])).id;
|
||||||
}
|
}
|
||||||
const data = await client.getAccount(userid ? userid : '');
|
const data = await client.getAccount(userid ? userid : "");
|
||||||
ctx.body = data.data;
|
ctx.body = data.data;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
@ -311,7 +314,7 @@ export function apiAccountMastodon(router: Router): void {
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
console.error(e.response.data);
|
console.error(e.response.data);
|
||||||
e.response.data.user = users ? users : 'null';
|
e.response.data.user = users ? users : "null";
|
||||||
ctx.status = 401;
|
ctx.status = 401;
|
||||||
ctx.body = e.response.data;
|
ctx.body = e.response.data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,11 @@ export function limitToInt(q: ParsedUrlQuery) {
|
||||||
export function argsToBools(q: ParsedUrlQuery) {
|
export function argsToBools(q: ParsedUrlQuery) {
|
||||||
let object: any = q;
|
let object: any = q;
|
||||||
if (q.only_media)
|
if (q.only_media)
|
||||||
if (typeof q.only_media === "string") object.only_media = q.only_media.toLowerCase() === "true";
|
if (typeof q.only_media === "string")
|
||||||
|
object.only_media = q.only_media.toLowerCase() === "true";
|
||||||
if (q.exclude_replies)
|
if (q.exclude_replies)
|
||||||
if (typeof q.exclude_replies === "string") object.exclude_replies = q.exclude_replies.toLowerCase() === "true";
|
if (typeof q.exclude_replies === "string")
|
||||||
|
object.exclude_replies = q.exclude_replies.toLowerCase() === "true";
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,9 +145,7 @@ export function apiTimelineMastodon(router: Router): void {
|
||||||
const accessTokens = ctx.headers.authorization;
|
const accessTokens = ctx.headers.authorization;
|
||||||
const client = getClient(BASE_URL, accessTokens);
|
const client = getClient(BASE_URL, accessTokens);
|
||||||
try {
|
try {
|
||||||
const data = await client.getConversationTimeline(
|
const data = await client.getConversationTimeline(limitToInt(ctx.query));
|
||||||
limitToInt(ctx.query),
|
|
||||||
);
|
|
||||||
ctx.body = data.data;
|
ctx.body = data.data;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
|
@ -81,9 +81,9 @@ mastoRouter.use(
|
||||||
mastoRouter.use(async (ctx, next) => {
|
mastoRouter.use(async (ctx, next) => {
|
||||||
if (ctx.request.query) {
|
if (ctx.request.query) {
|
||||||
if (!ctx.request.body || Object.keys(ctx.request.body).length === 0) {
|
if (!ctx.request.body || Object.keys(ctx.request.body).length === 0) {
|
||||||
ctx.request.body = ctx.request.query
|
ctx.request.body = ctx.request.query;
|
||||||
} else {
|
} else {
|
||||||
ctx.request.body = {...ctx.request.body, ...ctx.request.query}
|
ctx.request.body = { ...ctx.request.body, ...ctx.request.query };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await next();
|
await next();
|
||||||
|
|
Loading…
Reference in a new issue