mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 05:02:37 +01:00
Merge pull request #190 from BanTheNons/profile-banners
Implemented profile banners!
This commit is contained in:
commit
a95ecf4287
14
package-lock.json
generated
14
package-lock.json
generated
@ -9,7 +9,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fosscord/server-util": "^1.3.39",
|
"@fosscord/server-util": "^1.3.40",
|
||||||
"@types/jest": "^26.0.22",
|
"@types/jest": "^26.0.22",
|
||||||
"@types/json-schema": "^7.0.7",
|
"@types/json-schema": "^7.0.7",
|
||||||
"ajv": "^8.4.0",
|
"ajv": "^8.4.0",
|
||||||
@ -678,9 +678,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@fosscord/server-util": {
|
"node_modules/@fosscord/server-util": {
|
||||||
"version": "1.3.39",
|
"version": "1.3.40",
|
||||||
"resolved": "https://registry.npmjs.org/@fosscord/server-util/-/server-util-1.3.39.tgz",
|
"resolved": "https://registry.npmjs.org/@fosscord/server-util/-/server-util-1.3.40.tgz",
|
||||||
"integrity": "sha512-skDV2SMBsKMy0Ngz73aXHi9Nkhx6V6FH9pi9TuiJam976g2Dv/QWaBgfPgPNYu6euta986PTFrOqi8R8D2WYWw==",
|
"integrity": "sha512-LXB5Dby4dVNgIXy6Fehx+EsTboTy+Dbs5cqWj4av776qHfcn/EndyZLWX5XKcS++xJocHU8ci+A8T7ZaN04oiQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/jsonwebtoken": "^8.5.0",
|
"@types/jsonwebtoken": "^8.5.0",
|
||||||
"@types/mongoose-autopopulate": "^0.10.1",
|
"@types/mongoose-autopopulate": "^0.10.1",
|
||||||
@ -11457,9 +11457,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@fosscord/server-util": {
|
"@fosscord/server-util": {
|
||||||
"version": "1.3.39",
|
"version": "1.3.40",
|
||||||
"resolved": "https://registry.npmjs.org/@fosscord/server-util/-/server-util-1.3.39.tgz",
|
"resolved": "https://registry.npmjs.org/@fosscord/server-util/-/server-util-1.3.40.tgz",
|
||||||
"integrity": "sha512-skDV2SMBsKMy0Ngz73aXHi9Nkhx6V6FH9pi9TuiJam976g2Dv/QWaBgfPgPNYu6euta986PTFrOqi8R8D2WYWw==",
|
"integrity": "sha512-LXB5Dby4dVNgIXy6Fehx+EsTboTy+Dbs5cqWj4av776qHfcn/EndyZLWX5XKcS++xJocHU8ci+A8T7ZaN04oiQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/jsonwebtoken": "^8.5.0",
|
"@types/jsonwebtoken": "^8.5.0",
|
||||||
"@types/mongoose-autopopulate": "^0.10.1",
|
"@types/mongoose-autopopulate": "^0.10.1",
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/fosscord/fosscord-api#readme",
|
"homepage": "https://github.com/fosscord/fosscord-api#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fosscord/server-util": "^1.3.39",
|
"@fosscord/server-util": "^1.3.40",
|
||||||
"@types/jest": "^26.0.22",
|
"@types/jest": "^26.0.22",
|
||||||
"@types/json-schema": "^7.0.7",
|
"@types/json-schema": "^7.0.7",
|
||||||
"ajv": "^8.4.0",
|
"ajv": "^8.4.0",
|
||||||
|
@ -197,6 +197,7 @@ router.post(
|
|||||||
discriminator,
|
discriminator,
|
||||||
avatar: null,
|
avatar: null,
|
||||||
accent_color: null,
|
accent_color: null,
|
||||||
|
banner: null,
|
||||||
bot: false,
|
bot: false,
|
||||||
system: false,
|
system: false,
|
||||||
desktop: false,
|
desktop: false,
|
||||||
|
@ -43,8 +43,8 @@ router.patch("/", check(GuildUpdateSchema), async (req: Request, res: Response)
|
|||||||
const perms = await getPermission(req.user_id, guild_id);
|
const perms = await getPermission(req.user_id, guild_id);
|
||||||
perms.hasThrow("MANAGE_GUILD");
|
perms.hasThrow("MANAGE_GUILD");
|
||||||
|
|
||||||
body.icon = await handleFile(`/icons/${guild_id}`, body.icon);
|
if (body.icon) body.icon = await handleFile(`/icons/${guild_id}`, body.icon);
|
||||||
body.banner = await handleFile(`/banners/${guild_id}`, body.banner);
|
if(body.banner) body.banner = await handleFile(`/banners/${guild_id}`, body.banner);
|
||||||
|
|
||||||
const guild = await GuildModel.findOneAndUpdate({ id: guild_id }, body)
|
const guild = await GuildModel.findOneAndUpdate({ id: guild_id }, body)
|
||||||
.populate({ path: "joined_at", match: { id: req.user_id } })
|
.populate({ path: "joined_at", match: { id: req.user_id } })
|
||||||
|
@ -17,6 +17,7 @@ router.get("/", async (req: Request, res: Response) => {
|
|||||||
public_flags: user.public_flags,
|
public_flags: user.public_flags,
|
||||||
avatar: user.avatar,
|
avatar: user.avatar,
|
||||||
accent_color: user.accent_color,
|
accent_color: user.accent_color,
|
||||||
|
banner: user.banner,
|
||||||
bio: req.user_bot ? null : user.bio,
|
bio: req.user_bot ? null : user.bio,
|
||||||
bot: user.bot,
|
bot: user.bot,
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import { UserModel, toObject, PublicUserProjection } from "@fosscord/server-util";
|
import { UserModel, toObject, PublicUserProjection } from "@fosscord/server-util";
|
||||||
import { HTTPError } from "lambert-server";
|
|
||||||
import { getPublicUser } from "../../../util/User";
|
import { getPublicUser } from "../../../util/User";
|
||||||
import { UserModifySchema } from "../../../schema/User";
|
import { UserModifySchema } from "../../../schema/User";
|
||||||
import { check } from "../../../util/instanceOf";
|
import { check } from "../../../util/instanceOf";
|
||||||
@ -14,7 +13,9 @@ router.get("/", async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
router.patch("/", check(UserModifySchema), async (req: Request, res: Response) => {
|
router.patch("/", check(UserModifySchema), async (req: Request, res: Response) => {
|
||||||
const body = req.body as UserModifySchema;
|
const body = req.body as UserModifySchema;
|
||||||
body.avatar = await handleFile(`/avatars/${req.user_id}`, body.avatar as string);
|
|
||||||
|
if(body.avatar) body.avatar = await handleFile(`/avatars/${req.user_id}`, body.avatar as string);
|
||||||
|
if (body.banner) body.banner = await handleFile(`/banners/${req.user_id}`, body.banner as string);
|
||||||
|
|
||||||
const user = await UserModel.findOneAndUpdate({ id: req.user_id }, body, { projection: PublicUserProjection }).exec();
|
const user = await UserModel.findOneAndUpdate({ id: req.user_id }, body, { projection: PublicUserProjection }).exec();
|
||||||
// TODO: dispatch user update event
|
// TODO: dispatch user update event
|
||||||
|
@ -17,6 +17,7 @@ router.get("/", async (req: Request, res: Response) => {
|
|||||||
public_flags: user.public_flags,
|
public_flags: user.public_flags,
|
||||||
avatar: user.avatar,
|
avatar: user.avatar,
|
||||||
accent_color: user.accent_color,
|
accent_color: user.accent_color,
|
||||||
|
banner: user.banner,
|
||||||
bio: user.bio,
|
bio: user.bio,
|
||||||
bot: user.bot,
|
bot: user.bot,
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@ export const UserModifySchema = {
|
|||||||
$username: new Length(String, 2, 32),
|
$username: new Length(String, 2, 32),
|
||||||
$avatar: String,
|
$avatar: String,
|
||||||
$bio: new Length(String, 0, 190),
|
$bio: new Length(String, 0, 190),
|
||||||
$accent_color: Number
|
$accent_color: Number,
|
||||||
|
$banner: String
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface UserModifySchema {
|
export interface UserModifySchema {
|
||||||
@ -12,4 +13,5 @@ export interface UserModifySchema {
|
|||||||
avatar?: string | null;
|
avatar?: string | null;
|
||||||
bio?: string;
|
bio?: string;
|
||||||
accent_color?: number | null;
|
accent_color?: number | null;
|
||||||
|
banner?: string | null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user