mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
Remove useless async from functions
This commit is contained in:
parent
50fc4dbcf4
commit
b9efd093a6
|
|
@ -15,6 +15,6 @@ module.exports = {
|
|||
rules: {
|
||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||
"@typescript-eslint/no-unsafe-argument": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off"
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,10 +30,7 @@ export const getFromToken = async (
|
|||
* Converts this application to an API application.
|
||||
* @returns The API application representation of this application.
|
||||
*/
|
||||
export const applicationToAPI = async (
|
||||
app: Application
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
): Promise<APIApplication> => {
|
||||
export const applicationToAPI = (app: Application): APIApplication => {
|
||||
return {
|
||||
name: app.name,
|
||||
website: app.website,
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ export const addEmojiIfNotExists = async (emoji: LysandEmoji) => {
|
|||
* Converts the emoji to an APIEmoji object.
|
||||
* @returns The APIEmoji object.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
export const emojiToAPI = async (emoji: Emoji): Promise<APIEmoji> => {
|
||||
export const emojiToAPI = (emoji: Emoji): APIEmoji => {
|
||||
return {
|
||||
shortcode: emoji.shortcode,
|
||||
static_url: emoji.url, // TODO: Add static version
|
||||
|
|
|
|||
|
|
@ -41,10 +41,7 @@ export const createNewRelationship = async (
|
|||
* Converts the relationship to an API-friendly format.
|
||||
* @returns The API-friendly relationship.
|
||||
*/
|
||||
export const relationshipToAPI = async (
|
||||
rel: Relationship
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
): Promise<APIRelationship> => {
|
||||
export const relationshipToAPI = (rel: Relationship): APIRelationship => {
|
||||
return {
|
||||
blocked_by: rel.blockedBy,
|
||||
blocking: rel.blocking,
|
||||
|
|
|
|||
|
|
@ -450,16 +450,14 @@ export const statusToAPI = async (
|
|||
id: status.id,
|
||||
in_reply_to_id: status.inReplyToPostId || null,
|
||||
in_reply_to_account_id: status.inReplyToPost?.authorId || null,
|
||||
account: await userToAPI(status.author),
|
||||
account: userToAPI(status.author),
|
||||
created_at: new Date(status.createdAt).toISOString(),
|
||||
application: status.application
|
||||
? await applicationToAPI(status.application)
|
||||
? applicationToAPI(status.application)
|
||||
: null,
|
||||
card: null,
|
||||
content: status.content,
|
||||
emojis: await Promise.all(
|
||||
status.emojis.map(emoji => emojiToAPI(emoji))
|
||||
),
|
||||
emojis: status.emojis.map(emoji => emojiToAPI(emoji)),
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
favourited: !!(status.likes ?? []).find(
|
||||
like => like.likerId === user?.id
|
||||
|
|
|
|||
|
|
@ -343,11 +343,10 @@ export const generateUserKeys = async () => {
|
|||
};
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
export const userToAPI = async (
|
||||
export const userToAPI = (
|
||||
user: UserWithRelations,
|
||||
isOwnAccount = false
|
||||
): Promise<APIAccount> => {
|
||||
): APIAccount => {
|
||||
const config = getConfig();
|
||||
|
||||
return {
|
||||
|
|
@ -364,7 +363,7 @@ export const userToAPI = async (
|
|||
.length,
|
||||
following_count: user.relationships.filter(r => r.following).length,
|
||||
statuses_count: user._count.statuses,
|
||||
emojis: await Promise.all(user.emojis.map(emoji => emojiToAPI(emoji))),
|
||||
emojis: user.emojis.map(emoji => emojiToAPI(emoji)),
|
||||
// TODO: Add fields
|
||||
fields: [],
|
||||
bot: user.isBot,
|
||||
|
|
|
|||
|
|
@ -83,5 +83,5 @@ export default async (
|
|||
},
|
||||
});
|
||||
|
||||
return jsonResponse(await relationshipToAPI(relationship));
|
||||
return jsonResponse(relationshipToAPI(relationship));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -102,5 +102,5 @@ export default async (
|
|||
},
|
||||
});
|
||||
|
||||
return jsonResponse(await relationshipToAPI(relationship));
|
||||
return jsonResponse(relationshipToAPI(relationship));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -44,5 +44,5 @@ export default async (
|
|||
|
||||
if (!foundUser) return errorResponse("User not found", 404);
|
||||
|
||||
return jsonResponse(await userToAPI(foundUser, user?.id === foundUser.id));
|
||||
return jsonResponse(userToAPI(foundUser, user?.id === foundUser.id));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -96,5 +96,5 @@ export default async (
|
|||
|
||||
// TODO: Implement duration
|
||||
|
||||
return jsonResponse(await relationshipToAPI(relationship));
|
||||
return jsonResponse(relationshipToAPI(relationship));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -86,5 +86,5 @@ export default async (
|
|||
},
|
||||
});
|
||||
|
||||
return jsonResponse(await relationshipToAPI(relationship));
|
||||
return jsonResponse(relationshipToAPI(relationship));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -83,5 +83,5 @@ export default async (
|
|||
},
|
||||
});
|
||||
|
||||
return jsonResponse(await relationshipToAPI(relationship));
|
||||
return jsonResponse(relationshipToAPI(relationship));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -97,5 +97,5 @@ export default async (
|
|||
});
|
||||
}
|
||||
|
||||
return jsonResponse(await relationshipToAPI(relationship));
|
||||
return jsonResponse(relationshipToAPI(relationship));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -83,5 +83,5 @@ export default async (
|
|||
},
|
||||
});
|
||||
|
||||
return jsonResponse(await relationshipToAPI(relationship));
|
||||
return jsonResponse(relationshipToAPI(relationship));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -83,5 +83,5 @@ export default async (
|
|||
},
|
||||
});
|
||||
|
||||
return jsonResponse(await relationshipToAPI(relationship));
|
||||
return jsonResponse(relationshipToAPI(relationship));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -85,5 +85,5 @@ export default async (
|
|||
},
|
||||
});
|
||||
|
||||
return jsonResponse(await relationshipToAPI(relationship));
|
||||
return jsonResponse(relationshipToAPI(relationship));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -83,5 +83,5 @@ export default async (
|
|||
},
|
||||
});
|
||||
|
||||
return jsonResponse(await relationshipToAPI(relationship));
|
||||
return jsonResponse(relationshipToAPI(relationship));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -63,9 +63,5 @@ export default async (req: Request): Promise<Response> => {
|
|||
(a, b) => ids.indexOf(a.subjectId) - ids.indexOf(b.subjectId)
|
||||
);
|
||||
|
||||
return jsonResponse(
|
||||
await Promise.all(
|
||||
relationships.map(async r => await relationshipToAPI(r))
|
||||
)
|
||||
);
|
||||
return jsonResponse(relationships.map(r => relationshipToAPI(r)));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -242,5 +242,5 @@ export default async (req: Request): Promise<Response> => {
|
|||
},
|
||||
});
|
||||
|
||||
return jsonResponse(await userToAPI(user));
|
||||
return jsonResponse(userToAPI(user));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export default async (req: Request): Promise<Response> => {
|
|||
if (!user) return errorResponse("Unauthorized", 401);
|
||||
|
||||
return jsonResponse({
|
||||
...(await userToAPI(user, true)),
|
||||
...userToAPI(user, true),
|
||||
// TODO: Add role support
|
||||
role: {
|
||||
id: 0,
|
||||
|
|
|
|||
|
|
@ -39,5 +39,5 @@ export default async (req: Request): Promise<Response> => {
|
|||
include: userRelations,
|
||||
});
|
||||
|
||||
return jsonResponse(await userToAPI(newUser));
|
||||
return jsonResponse(userToAPI(newUser));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,5 +39,5 @@ export default async (req: Request): Promise<Response> => {
|
|||
include: userRelations,
|
||||
});
|
||||
|
||||
return jsonResponse(await userToAPI(newUser));
|
||||
return jsonResponse(userToAPI(newUser));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ export default async (
|
|||
}
|
||||
|
||||
return jsonResponse(
|
||||
await Promise.all(objects.map(async user => userToAPI(user))),
|
||||
objects.map(user => userToAPI(user)),
|
||||
200,
|
||||
{
|
||||
Link: linkHeader.join(", "),
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ export default async (
|
|||
}
|
||||
|
||||
return jsonResponse(
|
||||
await Promise.all(objects.map(async user => userToAPI(user))),
|
||||
objects.map(user => userToAPI(user)),
|
||||
200,
|
||||
{
|
||||
Link: linkHeader.join(", "),
|
||||
|
|
|
|||
Loading…
Reference in a new issue