feat: Add pm

This commit is contained in:
2026-04-27 00:45:16 +02:00
parent bc2fa7de22
commit 11c2588e45
65 changed files with 3653 additions and 214 deletions

View File

@@ -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
};
}

View File

@@ -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();