feat: Add pm
This commit is contained in:
@@ -19,7 +19,8 @@ import {
|
||||
ServerAccessError,
|
||||
kickServerUser,
|
||||
ensureServerMembership,
|
||||
unbanServerUser
|
||||
unbanServerUser,
|
||||
countServerMemberships
|
||||
} from '../services/server-access.service';
|
||||
import {
|
||||
buildAppInviteUrl,
|
||||
@@ -78,6 +79,7 @@ function normalizeServerChannels(value: unknown): ServerChannelPayload[] {
|
||||
|
||||
async function enrichServer(server: ServerPayload, sourceUrl?: string) {
|
||||
const owner = await getUserById(server.ownerId);
|
||||
const userCount = await countServerMemberships(server.id);
|
||||
const { passwordHash, ...publicServer } = server;
|
||||
|
||||
return {
|
||||
@@ -85,7 +87,8 @@ async function enrichServer(server: ServerPayload, sourceUrl?: string) {
|
||||
hasPassword: server.hasPassword ?? !!passwordHash,
|
||||
ownerName: owner?.displayName,
|
||||
sourceUrl,
|
||||
userCount: server.currentUsers
|
||||
currentUsers: userCount,
|
||||
userCount
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -130,6 +130,10 @@ export async function findServerMembership(serverId: string, userId: string): Pr
|
||||
return await getMembershipRepository().findOne({ where: { serverId, userId } });
|
||||
}
|
||||
|
||||
export async function countServerMemberships(serverId: string): Promise<number> {
|
||||
return await getMembershipRepository().count({ where: { serverId } });
|
||||
}
|
||||
|
||||
export async function ensureServerMembership(serverId: string, userId: string): Promise<ServerMembershipEntity> {
|
||||
const repo = getMembershipRepository();
|
||||
const now = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user