mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-13 14:12:41 +01:00
Update LazyRequest.ts
This commit is contained in:
parent
910dd9a22b
commit
b5bbc35905
@ -1,5 +1,13 @@
|
||||
// @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 { OPCODES, Payload } from "../util/Constants";
|
||||
import { Send } from "../util/Send";
|
||||
@ -23,10 +31,9 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
||||
.aggregate([
|
||||
{
|
||||
$match: {
|
||||
guild_id
|
||||
// id: { $ne: guild_id }
|
||||
guild_id,
|
||||
// hoist: true // TODO: also match @everyone role
|
||||
}
|
||||
},
|
||||
},
|
||||
{ $sort: { position: 1 } },
|
||||
{
|
||||
@ -40,17 +47,20 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
||||
$lookup: {
|
||||
from: "users",
|
||||
let: { user_id: "$id" },
|
||||
pipeline: [{ $match: { $expr: { $eq: ["$id", "$$user_id"] } } }, { $project: PublicUserProjection }],
|
||||
as: "user"
|
||||
}
|
||||
pipeline: [
|
||||
{ $match: { $expr: { $eq: ["$id", "$$user_id"] } } },
|
||||
{ $project: PublicUserProjection },
|
||||
],
|
||||
as: "user",
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: "$user"
|
||||
}
|
||||
$unwind: "$user",
|
||||
},
|
||||
],
|
||||
as: "members"
|
||||
}
|
||||
}
|
||||
as: "members",
|
||||
},
|
||||
},
|
||||
])
|
||||
.toArray()
|
||||
);
|
||||
@ -81,14 +91,14 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
||||
{
|
||||
range: [0, 99],
|
||||
op: "SYNC",
|
||||
items
|
||||
}
|
||||
items,
|
||||
},
|
||||
],
|
||||
online_count: member_count, // TODO count online count
|
||||
member_count,
|
||||
id: "everyone",
|
||||
guild_id,
|
||||
groups
|
||||
}
|
||||
groups,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user