feat: add in-game social test lab

This commit is contained in:
ANG-Server
2026-07-22 12:16:31 +08:00
parent fe52ab1696
commit a3341b6a3b
19 changed files with 827 additions and 14 deletions

View File

@@ -74,5 +74,16 @@ export class SocialMemoryStore implements SocialStore {
async markNotificationRead(userId: bigint, id: bigint): Promise<SocialNotification | null> { const item = this.notifications.find((entry) => entry.user_id === userId && entry.id === id); if (item) { item.read_at = new Date(); item.updated_at = new Date(); } return item || null; }
async markAllNotificationsRead(userId: bigint): Promise<number> { let affected = 0; for (const item of this.notifications) if (item.user_id === userId && !item.read_at) { item.read_at = new Date(); item.updated_at = new Date(); affected++; } return affected; }
async countUnreadNotifications(userId: bigint): Promise<number> { return this.notifications.filter((item) => item.user_id === userId && !item.read_at && item.expires_at > new Date()).length; }
async purgeUsers(userIds: bigint[]): Promise<void> {
const ids = new Set(userIds.map((id) => id.toString()));
const has = (id: bigint) => ids.has(id.toString());
this.friendships = this.friendships.filter((item) => !has(item.user_low_id) && !has(item.user_high_id));
this.requests = this.requests.filter((item) => !has(item.requester_id) && !has(item.recipient_id));
this.blocks = this.blocks.filter((item) => !has(item.user_id) && !has(item.blocked_user_id));
this.messages = this.messages.filter((item) => !has(item.sender_id) && !has(item.recipient_id));
this.reports = this.reports.filter((item) => !has(item.reporter_id) && !has(item.reported_user_id));
this.unlocks = this.unlocks.filter((item) => !has(item.user_id));
this.notifications = this.notifications.filter((item) => !has(item.user_id) && !(item.action_metadata as Record<string, unknown> | null)?.testLab);
}
async cleanupExpired(now: Date): Promise<void> { this.requests = this.requests.filter((item) => item.status !== FriendRequestStatus.PENDING || item.expires_at > now); this.messages = this.messages.filter((item) => item.expires_at > now); this.notifications = this.notifications.filter((item) => item.expires_at > now); }
}