mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-12 21:52:40 +01:00
Merge branch 'slowcord' of github.com:MaddyUnderStars/fosscord-server into slowcord
This commit is contained in:
commit
65143966d3
@ -31,7 +31,7 @@ const toDataURL = async (url: string) => {
|
|||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
const buffer = Buffer.from(await blob.text());
|
const buffer = Buffer.from(await blob.text());
|
||||||
return `data:${blob.type};base64,${buffer.toString("base64")}`;
|
return `data:${blob.type};base64,${buffer.toString("base64")}`;
|
||||||
}
|
};
|
||||||
|
|
||||||
class Discord {
|
class Discord {
|
||||||
static getAccessToken = async (req: Request, res: Response) => {
|
static getAccessToken = async (req: Request, res: Response) => {
|
||||||
@ -126,10 +126,15 @@ app.get("/oauth/:type", async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (details.avatar_url) {
|
if (details.avatar_url) {
|
||||||
|
try {
|
||||||
const avatar = await handleFile(`/avatars/${user.id}`, await toDataURL(details.avatar_url) as string);
|
const avatar = await handleFile(`/avatars/${user.id}`, await toDataURL(details.avatar_url) as string);
|
||||||
user.avatar = avatar;
|
user.avatar = avatar;
|
||||||
await user.save();
|
await user.save();
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = await generateToken(user.id);
|
const token = await generateToken(user.id);
|
||||||
|
Loading…
Reference in New Issue
Block a user