diff options
-rw-r--r-- | .vscode/launch.json | 1 | ||||
-rw-r--r-- | package-lock.json | 4 | ||||
-rw-r--r-- | src/routes/api/v8/channels/#channel_id/invites.ts | 2 | ||||
-rw-r--r-- | src/routes/api/v8/guilds/#id/bans.ts | 9 | ||||
-rw-r--r-- | src/routes/api/v8/guilds/#id/members/index.ts | 4 | ||||
-rw-r--r-- | src/test/mongo_test.ts | 33 |
6 files changed, 40 insertions, 13 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json index 570e485a..557fb6d7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -19,6 +19,7 @@ "request": "launch", "skipFiles": ["<node_internals>/**"], "runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"], + "preLaunchTask": "tsc: build - tsconfig.json", "type": "node", "resolveSourceMapLocations": ["${workspaceFolder}/**", "!**/node_modules/**"] } diff --git a/package-lock.json b/package-lock.json index dff1862c..72f21935 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1363,7 +1363,7 @@ }, "node_modules/fosscord-server-util": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#371a56859695321bfa862a1c66d27279018cc864", + "resolved": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#3bdbd9340edf4f3edd728624499dbcaaf08a25ed", "license": "ISC", "dependencies": { "jsonwebtoken": "^8.5.1", @@ -5077,7 +5077,7 @@ "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" }, "fosscord-server-util": { - "version": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#371a56859695321bfa862a1c66d27279018cc864", + "version": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#3bdbd9340edf4f3edd728624499dbcaaf08a25ed", "from": "fosscord-server-util@github:fosscord/fosscord-server-util", "requires": { "jsonwebtoken": "^8.5.1", diff --git a/src/routes/api/v8/channels/#channel_id/invites.ts b/src/routes/api/v8/channels/#channel_id/invites.ts index 2bf8664f..60ff4bb7 100644 --- a/src/routes/api/v8/channels/#channel_id/invites.ts +++ b/src/routes/api/v8/channels/#channel_id/invites.ts @@ -39,7 +39,7 @@ router.post("/", check(InviteCreateSchema), async (req: Request, res: Response) inviter_id: usID, }; - await new InviteModel(invite).save(); // ! samuel ist ein hurensohn + await new InviteModel(invite).save(); await emitEvent({ event: "INVITE_CREATE", data: invite } as InviteCreateEvent); res.status(201).send(invite); diff --git a/src/routes/api/v8/guilds/#id/bans.ts b/src/routes/api/v8/guilds/#id/bans.ts index e18a1137..8e6e35de 100644 --- a/src/routes/api/v8/guilds/#id/bans.ts +++ b/src/routes/api/v8/guilds/#id/bans.ts @@ -20,6 +20,15 @@ router.get("/", async (req: Request, res: Response) => { return res.json(bans); }); +router.get("/:user", async (req: Request, res: Response) => { + const guild_id = BigInt(req.params.id); + const user_id = BigInt(req.params.ban); + + var ban = await BanModel.findOne({ guild_id: guild_id, user_id: user_id }).exec(); + if (!ban) throw new HTTPError("Ban not found", 404); + return res.json(ban); +}); + router.post("/:userid", check(BanCreateSchema), async (req: Request, res: Response) => { const guild_id = BigInt(req.params.id); const banned_user_id = BigInt(req.params.userid); diff --git a/src/routes/api/v8/guilds/#id/members/index.ts b/src/routes/api/v8/guilds/#id/members/index.ts index 9446e2da..3b422dd0 100644 --- a/src/routes/api/v8/guilds/#id/members/index.ts +++ b/src/routes/api/v8/guilds/#id/members/index.ts @@ -49,4 +49,8 @@ router.get("/:member", async (req: Request, res: Response) => { return res.json(member); }); +router.put("/:member", async (req: Request, res: Response) => { + // https://discord.com/developers/docs/resources/guild#add-guild-member +}); + export default router; diff --git a/src/test/mongo_test.ts b/src/test/mongo_test.ts index 5c973429..f1a7f3f6 100644 --- a/src/test/mongo_test.ts +++ b/src/test/mongo_test.ts @@ -2,13 +2,26 @@ import mongoose, { Schema, Types } from "mongoose"; import { Long as MongoTypeLong } from "mongodb"; require("mongoose-long")(mongoose); -const partSchema = new Schema({ - long: { - type: mongoose.Types.Long, - }, +const userSchema = new Schema({ + id: MongoTypeLong, }); -const Part = mongoose.model("Part", partSchema, "test"); +const messageSchema = new Schema({ + id: MongoTypeLong, + content: String, +}); +const message = mongoose.model("message", messageSchema, "messages"); +const user = mongoose.model("user", userSchema, "users"); + +messageSchema.virtual("u", { + ref: user, + localField: "id", + foreignField: "id", + justOne: true, +}); + +messageSchema.set("toObject", { virtuals: true }); +messageSchema.set("toJSON", { virtuals: true }); async function main() { const conn = await mongoose.connect("mongodb://localhost:27017/lambert?readPreference=secondaryPreferred", { @@ -17,12 +30,12 @@ async function main() { }); console.log("connected"); - const part = new Part({ long: 390810485244821505n }); + // const u = await new user({ name: "test" }).save(); + // await new message({ user: u._id, content: "test" }).save(); - // await part.save(); - console.log("saved"); - const test = await Part.find({}); - console.log(test); + const test = await message.findOne({}).populate("u").exec(); + // @ts-ignore + console.log(test?.toJSON()); } main(); |