refactor: migrate to ES modules
package.json type=module, tsconfig module/moduleResolution=NodeNext, target es2022, explicit .js on all relative imports. Center: jsonwebtoken & bcryptjs switched to default imports (ESM/CJS interop). Verified: builds, boots, full auth + plugin round-trip work under ESM. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
"name": "fabric-backend-guild",
|
"name": "fabric-backend-guild",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
"description": "Fabric Guild Node service",
|
"description": "Fabric Guild Node service",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -p tsconfig.build.json",
|
"build": "tsc -p tsconfig.build.json",
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { APP_GUARD } from '@nestjs/core';
|
import { APP_GUARD } from '@nestjs/core';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { buildTypeOrmConfig } from './database.config';
|
import { buildTypeOrmConfig } from './database.config.js';
|
||||||
import { HealthController } from './common/health.controller';
|
import { HealthController } from './common/health.controller.js';
|
||||||
import { MetricsController } from './common/metrics.controller';
|
import { MetricsController } from './common/metrics.controller.js';
|
||||||
import { MetricsService } from './common/metrics.service';
|
import { MetricsService } from './common/metrics.service.js';
|
||||||
import { ApiKeyGuard } from './common/api-key.guard';
|
import { ApiKeyGuard } from './common/api-key.guard.js';
|
||||||
import { GuildsModule } from './guilds/guilds.module';
|
import { GuildsModule } from './guilds/guilds.module.js';
|
||||||
import { ChannelsModule } from './channels/channels.module';
|
import { ChannelsModule } from './channels/channels.module.js';
|
||||||
import { TurnModule } from './channels/turn.module';
|
import { TurnModule } from './channels/turn.module.js';
|
||||||
import { MessagingModule } from './messaging/messaging.module';
|
import { MessagingModule } from './messaging/messaging.module.js';
|
||||||
import { EventsModule } from './events/events.module';
|
import { EventsModule } from './events/events.module.js';
|
||||||
import { RealtimeModule } from './realtime/realtime.module';
|
import { RealtimeModule } from './realtime/realtime.module.js';
|
||||||
import { MembersModule } from './members/members.module';
|
import { MembersModule } from './members/members.module.js';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Body, Controller, Get, Param, Post, Query, Req, UnauthorizedException } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Post, Query, Req, UnauthorizedException } from '@nestjs/common';
|
||||||
import { ChannelsService } from './channels.service';
|
import { ChannelsService } from './channels.service.js';
|
||||||
|
|
||||||
// ApiKeyGuard attaches the introspected Center user id onto the request.
|
// ApiKeyGuard attaches the introspected Center user id onto the request.
|
||||||
type AuthedRequest = { userId?: string };
|
type AuthedRequest = { userId?: string };
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { ChannelsController } from './channels.controller';
|
import { ChannelsController } from './channels.controller.js';
|
||||||
import { Channel } from '../entities/channel.entity';
|
import { Channel } from '../entities/channel.entity.js';
|
||||||
import { ChannelMember } from '../entities/channel-member.entity';
|
import { ChannelMember } from '../entities/channel-member.entity.js';
|
||||||
import { WakeMapping } from '../entities/wake-mapping.entity';
|
import { WakeMapping } from '../entities/wake-mapping.entity.js';
|
||||||
import { ChannelsService } from './channels.service';
|
import { ChannelsService } from './channels.service.js';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([Channel, ChannelMember, WakeMapping])],
|
imports: [TypeOrmModule.forFeature([Channel, ChannelMember, WakeMapping])],
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { BadRequestException, ForbiddenException, Injectable, NotFoundException } from '@nestjs/common';
|
import { BadRequestException, ForbiddenException, Injectable, NotFoundException } from '@nestjs/common';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { In, Repository } from 'typeorm';
|
import { In, Repository } from 'typeorm';
|
||||||
import { Channel } from '../entities/channel.entity';
|
import { Channel } from '../entities/channel.entity.js';
|
||||||
import { ChannelMember } from '../entities/channel-member.entity';
|
import { ChannelMember } from '../entities/channel-member.entity.js';
|
||||||
import { WakeMapping } from '../entities/wake-mapping.entity';
|
import { WakeMapping } from '../entities/wake-mapping.entity.js';
|
||||||
import { TurnService } from './turn.service';
|
import { TurnService } from './turn.service.js';
|
||||||
|
|
||||||
const X_TYPES = ['general', 'work', 'report', 'discuss', 'triage', 'custom'] as const;
|
const X_TYPES = ['general', 'work', 'report', 'discuss', 'triage', 'custom'] as const;
|
||||||
type XType = (typeof X_TYPES)[number];
|
type XType = (typeof X_TYPES)[number];
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { RoundEvent } from '../entities/channel-turn-state.entity';
|
import { RoundEvent } from '../entities/channel-turn-state.entity.js';
|
||||||
|
|
||||||
export type ShuffleResult = { paused: true } | { paused: false; newOrder: string[] };
|
export type ShuffleResult = { paused: true } | { paused: false; newOrder: string[] };
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Global, Module } from '@nestjs/common';
|
import { Global, Module } from '@nestjs/common';
|
||||||
import { TurnService } from './turn.service';
|
import { TurnService } from './turn.service.js';
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { DataSource, EntityManager } from 'typeorm';
|
import { DataSource, EntityManager } from 'typeorm';
|
||||||
import { ChannelTurnState, TurnFrame } from '../entities/channel-turn-state.entity';
|
import { ChannelTurnState, TurnFrame } from '../entities/channel-turn-state.entity.js';
|
||||||
import { ChannelMember } from '../entities/channel-member.entity';
|
import { ChannelMember } from '../entities/channel-member.entity.js';
|
||||||
import { computeShuffle } from './turn-shuffle';
|
import { computeShuffle } from './turn-shuffle.js';
|
||||||
|
|
||||||
// wakeupUserId: the single user who should receive wakeup=true on the
|
// wakeupUserId: the single user who should receive wakeup=true on the
|
||||||
// resulting push (null = nobody / paused). For commands, `ack` present means
|
// resulting push (null = nobody / paused). For commands, `ack` present means
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
Injectable,
|
Injectable,
|
||||||
UnauthorizedException,
|
UnauthorizedException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { introspectGuildToken } from './center-auth';
|
import { introspectGuildToken } from './center-auth.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ApiKeyGuard implements CanActivate {
|
export class ApiKeyGuard implements CanActivate {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Controller, Get } from '@nestjs/common';
|
import { Controller, Get } from '@nestjs/common';
|
||||||
import { MetricsService } from './metrics.service';
|
import { MetricsService } from './metrics.service.js';
|
||||||
|
|
||||||
@Controller('metrics')
|
@Controller('metrics')
|
||||||
export class MetricsController {
|
export class MetricsController {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
import { NextFunction, Request, Response } from 'express';
|
import { NextFunction, Request, Response } from 'express';
|
||||||
import { MetricsService } from './metrics.service';
|
import { MetricsService } from './metrics.service.js';
|
||||||
|
|
||||||
type ReqWithId = Request & { requestId?: string };
|
type ReqWithId = Request & { requestId?: string };
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
import { DataSource, DataSourceOptions } from 'typeorm';
|
import { DataSource, DataSourceOptions } from 'typeorm';
|
||||||
import { buildTypeOrmConfig } from './database.config';
|
import { buildTypeOrmConfig } from './database.config.js';
|
||||||
|
|
||||||
const cfg = buildTypeOrmConfig();
|
const cfg = buildTypeOrmConfig();
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||||
import { Guild } from './entities/guild.entity';
|
import { Guild } from './entities/guild.entity.js';
|
||||||
import { Channel } from './entities/channel.entity';
|
import { Channel } from './entities/channel.entity.js';
|
||||||
import { ChannelMember } from './entities/channel-member.entity';
|
import { ChannelMember } from './entities/channel-member.entity.js';
|
||||||
import { WakeMapping } from './entities/wake-mapping.entity';
|
import { WakeMapping } from './entities/wake-mapping.entity.js';
|
||||||
import { ChannelTurnState } from './entities/channel-turn-state.entity';
|
import { ChannelTurnState } from './entities/channel-turn-state.entity.js';
|
||||||
import { Message } from './entities/message.entity';
|
import { Message } from './entities/message.entity.js';
|
||||||
import { DmConversation } from './entities/dm-conversation.entity';
|
import { DmConversation } from './entities/dm-conversation.entity.js';
|
||||||
import { DmParticipant } from './entities/dm-participant.entity';
|
import { DmParticipant } from './entities/dm-participant.entity.js';
|
||||||
import { GuildRole } from './entities/guild-role.entity';
|
import { GuildRole } from './entities/guild-role.entity.js';
|
||||||
import { GuildMember } from './entities/guild-member.entity';
|
import { GuildMember } from './entities/guild-member.entity.js';
|
||||||
import { GuildMemberRole } from './entities/guild-member-role.entity';
|
import { GuildMemberRole } from './entities/guild-member-role.entity.js';
|
||||||
import { IdempotencyRecord } from './entities/idempotency-record.entity';
|
import { IdempotencyRecord } from './entities/idempotency-record.entity.js';
|
||||||
|
|
||||||
export const buildTypeOrmConfig = (): TypeOrmModuleOptions => ({
|
export const buildTypeOrmConfig = (): TypeOrmModuleOptions => ({
|
||||||
type: 'mysql',
|
type: 'mysql',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Global, Module } from '@nestjs/common';
|
import { Global, Module } from '@nestjs/common';
|
||||||
import { EventsService } from './events.service';
|
import { EventsService } from './events.service.js';
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
import { createHmac, randomUUID } from 'crypto';
|
import { createHmac, randomUUID } from 'crypto';
|
||||||
import { FabricEventEnvelope } from './event-envelope';
|
import { FabricEventEnvelope } from './event-envelope.js';
|
||||||
|
|
||||||
type RetryTask = {
|
type RetryTask = {
|
||||||
envelope: FabricEventEnvelope;
|
envelope: FabricEventEnvelope;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Body, Controller, Get, Post } from '@nestjs/common';
|
import { Body, Controller, Get, Post } from '@nestjs/common';
|
||||||
import { GuildsService } from './guilds.service';
|
import { GuildsService } from './guilds.service.js';
|
||||||
|
|
||||||
@Controller('guilds')
|
@Controller('guilds')
|
||||||
export class GuildsController {
|
export class GuildsController {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { GuildsController } from './guilds.controller';
|
import { GuildsController } from './guilds.controller.js';
|
||||||
import { Guild } from '../entities/guild.entity';
|
import { Guild } from '../entities/guild.entity.js';
|
||||||
import { GuildsService } from './guilds.service';
|
import { GuildsService } from './guilds.service.js';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([Guild])],
|
imports: [TypeOrmModule.forFeature([Guild])],
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { Guild } from '../entities/guild.entity';
|
import { Guild } from '../entities/guild.entity.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GuildsService {
|
export class GuildsService {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Test } from '@nestjs/testing';
|
|||||||
import request from 'supertest';
|
import request from 'supertest';
|
||||||
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
import { Channel } from './entities/channel.entity';
|
import { Channel } from './entities/channel.entity.js';
|
||||||
|
|
||||||
process.env.DB_HOST = '127.0.0.1';
|
process.env.DB_HOST = '127.0.0.1';
|
||||||
process.env.DB_PORT = '3308';
|
process.env.DB_PORT = '3308';
|
||||||
@@ -18,7 +18,7 @@ describe('guild integration (mysql + api)', () => {
|
|||||||
let dataSource: DataSource;
|
let dataSource: DataSource;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const { AppModule } = await import('./app.module');
|
const { AppModule } = await import('./app.module.js');
|
||||||
const moduleRef = await Test.createTestingModule({
|
const moduleRef = await Test.createTestingModule({
|
||||||
imports: [AppModule],
|
imports: [AppModule],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import 'reflect-metadata';
|
|||||||
import { ValidationPipe } from '@nestjs/common';
|
import { ValidationPipe } from '@nestjs/common';
|
||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module.js';
|
||||||
import { createRequestContextMiddleware } from './common/request-context.middleware';
|
import { createRequestContextMiddleware } from './common/request-context.middleware.js';
|
||||||
import { MetricsService } from './common/metrics.service';
|
import { MetricsService } from './common/metrics.service.js';
|
||||||
|
|
||||||
function requireEnv(name: string): string {
|
function requireEnv(name: string): string {
|
||||||
const value = process.env[name];
|
const value = process.env[name];
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Controller, Get, Query } from '@nestjs/common';
|
import { Controller, Get, Query } from '@nestjs/common';
|
||||||
import { MembersService } from './members.service';
|
import { MembersService } from './members.service.js';
|
||||||
|
|
||||||
@Controller('members')
|
@Controller('members')
|
||||||
export class MembersController {
|
export class MembersController {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { GuildMember } from '../entities/guild-member.entity';
|
import { GuildMember } from '../entities/guild-member.entity.js';
|
||||||
import { MembersController } from './members.controller';
|
import { MembersController } from './members.controller.js';
|
||||||
import { MembersService } from './members.service';
|
import { MembersService } from './members.service.js';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([GuildMember])],
|
imports: [TypeOrmModule.forFeature([GuildMember])],
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { GuildMember } from '../entities/guild-member.entity';
|
import { GuildMember } from '../entities/guild-member.entity.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MembersService {
|
export class MembersService {
|
||||||
|
|||||||
@@ -13,18 +13,18 @@ import {
|
|||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { DataSource, Repository } from 'typeorm';
|
import { DataSource, Repository } from 'typeorm';
|
||||||
import { CreateMessageDto } from './dto.create-message.dto';
|
import { CreateMessageDto } from './dto.create-message.dto.js';
|
||||||
import { Channel } from '../entities/channel.entity';
|
import { Channel } from '../entities/channel.entity.js';
|
||||||
import { Message } from '../entities/message.entity';
|
import { Message } from '../entities/message.entity.js';
|
||||||
import { IdempotencyRecord } from '../entities/idempotency-record.entity';
|
import { IdempotencyRecord } from '../entities/idempotency-record.entity.js';
|
||||||
import { WakeMapping } from '../entities/wake-mapping.entity';
|
import { WakeMapping } from '../entities/wake-mapping.entity.js';
|
||||||
import { parseSlashCommand } from '../channels/slash-commands';
|
import { parseSlashCommand } from '../channels/slash-commands.js';
|
||||||
import { parseMentions, extractNameMentions, replaceNameMentions } from '../channels/mentions';
|
import { parseMentions, extractNameMentions, replaceNameMentions } from '../channels/mentions.js';
|
||||||
import { resolveUserNames } from '../common/center-auth';
|
import { resolveUserNames } from '../common/center-auth.js';
|
||||||
import { TurnService } from '../channels/turn.service';
|
import { TurnService } from '../channels/turn.service.js';
|
||||||
import { EventsService } from '../events/events.service';
|
import { EventsService } from '../events/events.service.js';
|
||||||
import { clampLimit, computeNextExpectedSeq } from './pagination.util';
|
import { clampLimit, computeNextExpectedSeq } from './pagination.util.js';
|
||||||
import { RealtimeGateway } from '../realtime/realtime.gateway';
|
import { RealtimeGateway } from '../realtime/realtime.gateway.js';
|
||||||
|
|
||||||
const EDIT_WINDOW_MS = 15 * 60 * 1000;
|
const EDIT_WINDOW_MS = 15 * 60 * 1000;
|
||||||
const DEFAULT_PAGE_LIMIT = 50;
|
const DEFAULT_PAGE_LIMIT = 50;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { MessagingController } from './messaging.controller';
|
import { MessagingController } from './messaging.controller.js';
|
||||||
import { Channel } from '../entities/channel.entity';
|
import { Channel } from '../entities/channel.entity.js';
|
||||||
import { Message } from '../entities/message.entity';
|
import { Message } from '../entities/message.entity.js';
|
||||||
import { IdempotencyRecord } from '../entities/idempotency-record.entity';
|
import { IdempotencyRecord } from '../entities/idempotency-record.entity.js';
|
||||||
import { WakeMapping } from '../entities/wake-mapping.entity';
|
import { WakeMapping } from '../entities/wake-mapping.entity.js';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([Channel, Message, IdempotencyRecord, WakeMapping])],
|
imports: [TypeOrmModule.forFeature([Channel, Message, IdempotencyRecord, WakeMapping])],
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import { clampLimit, computeNextExpectedSeq } from './pagination.util';
|
import { clampLimit, computeNextExpectedSeq } from './pagination.util.js';
|
||||||
|
|
||||||
describe('pagination utils', () => {
|
describe('pagination utils', () => {
|
||||||
it('clamps limit safely', () => {
|
it('clamps limit safely', () => {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
} from '@nestjs/websockets';
|
} from '@nestjs/websockets';
|
||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
import { Server, Socket } from 'socket.io';
|
import { Server, Socket } from 'socket.io';
|
||||||
import { introspectGuildToken } from '../common/center-auth';
|
import { introspectGuildToken } from '../common/center-auth.js';
|
||||||
|
|
||||||
type XType = 'general' | 'work' | 'report' | 'discuss' | 'triage' | 'custom';
|
type XType = 'general' | 'work' | 'report' | 'discuss' | 'triage' | 'custom';
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ export class RealtimeGateway implements OnGatewayConnection, OnGatewayDisconnect
|
|||||||
wakeUserIds: ctx.wakeUserIds,
|
wakeUserIds: ctx.wakeUserIds,
|
||||||
mentionUserIds: ctx.mentionUserIds,
|
mentionUserIds: ctx.mentionUserIds,
|
||||||
});
|
});
|
||||||
s.emit('message.created', { ...data, wakeup });
|
s.emit('message.created', { ...data, channelId, wakeup });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ export class RealtimeGateway implements OnGatewayConnection, OnGatewayDisconnect
|
|||||||
for (const s of sockets) {
|
for (const s of sockets) {
|
||||||
const recipientUserId = typeof s.data.userId === 'string' ? s.data.userId : `anon:${s.id}`;
|
const recipientUserId = typeof s.data.userId === 'string' ? s.data.userId : `anon:${s.id}`;
|
||||||
const wakeup = wakeupUserId !== null && recipientUserId === wakeupUserId;
|
const wakeup = wakeupUserId !== null && recipientUserId === wakeupUserId;
|
||||||
s.emit('message.created', { ...data, wakeup });
|
s.emit('message.created', { ...data, channelId, wakeup });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Global, Module } from '@nestjs/common';
|
import { Global, Module } from '@nestjs/common';
|
||||||
import { RealtimeGateway } from './realtime.gateway';
|
import { RealtimeGateway } from './realtime.gateway.js';
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "commonjs",
|
"module": "NodeNext",
|
||||||
"target": "es2020",
|
"moduleResolution": "NodeNext",
|
||||||
|
"target": "es2022",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user