Update LazyRequest.ts
This commit is contained in:
parent
910dd9a22b
commit
b5bbc35905
@ -1,5 +1,13 @@
|
|||||||
// @ts-nocheck WIP
|
// @ts-nocheck WIP
|
||||||
import { db, getPermission, MemberModel, MongooseCache, PublicUserProjection, RoleModel, toObject } from "@fosscord/server-util";
|
import {
|
||||||
|
db,
|
||||||
|
getPermission,
|
||||||
|
MemberModel,
|
||||||
|
MongooseCache,
|
||||||
|
PublicUserProjection,
|
||||||
|
RoleModel,
|
||||||
|
toObject,
|
||||||
|
} from "@fosscord/server-util";
|
||||||
import { LazyRequest } from "../schema/LazyRequest";
|
import { LazyRequest } from "../schema/LazyRequest";
|
||||||
import { OPCODES, Payload } from "../util/Constants";
|
import { OPCODES, Payload } from "../util/Constants";
|
||||||
import { Send } from "../util/Send";
|
import { Send } from "../util/Send";
|
||||||
@ -23,10 +31,9 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
|||||||
.aggregate([
|
.aggregate([
|
||||||
{
|
{
|
||||||
$match: {
|
$match: {
|
||||||
guild_id
|
guild_id,
|
||||||
// id: { $ne: guild_id }
|
|
||||||
// hoist: true // TODO: also match @everyone role
|
// hoist: true // TODO: also match @everyone role
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{ $sort: { position: 1 } },
|
{ $sort: { position: 1 } },
|
||||||
{
|
{
|
||||||
@ -40,17 +47,20 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
|||||||
$lookup: {
|
$lookup: {
|
||||||
from: "users",
|
from: "users",
|
||||||
let: { user_id: "$id" },
|
let: { user_id: "$id" },
|
||||||
pipeline: [{ $match: { $expr: { $eq: ["$id", "$$user_id"] } } }, { $project: PublicUserProjection }],
|
pipeline: [
|
||||||
as: "user"
|
{ $match: { $expr: { $eq: ["$id", "$$user_id"] } } },
|
||||||
}
|
{ $project: PublicUserProjection },
|
||||||
|
],
|
||||||
|
as: "user",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$unwind: "$user"
|
$unwind: "$user",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
as: "members"
|
as: "members",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
])
|
])
|
||||||
.toArray()
|
.toArray()
|
||||||
);
|
);
|
||||||
@ -81,14 +91,14 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
|||||||
{
|
{
|
||||||
range: [0, 99],
|
range: [0, 99],
|
||||||
op: "SYNC",
|
op: "SYNC",
|
||||||
items
|
items,
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
online_count: member_count, // TODO count online count
|
online_count: member_count, // TODO count online count
|
||||||
member_count,
|
member_count,
|
||||||
id: "everyone",
|
id: "everyone",
|
||||||
guild_id,
|
guild_id,
|
||||||
groups
|
groups,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user