Skip to content

Commit fc49fcf

Browse files
committed
x
1 parent c5de34d commit fc49fcf

File tree

2 files changed

+48
-36
lines changed

2 files changed

+48
-36
lines changed

packages/homeserver/src/homeserver.module.ts

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import { DatabaseConnection } from './database/database.connection';
1111
import { MissingEventListener } from './listeners/missing-event.listener';
1212
import { StagingAreaListener } from './listeners/staging-area.listener';
1313
import { HttpLoggerMiddleware } from './middleware/http-logger.middleware';
14+
import { MissingEventsQueue } from './queues/missing-event.queue';
1415
import { QueueModule } from './queues/queue.module';
16+
import { StagingAreaQueue } from './queues/staging-area.queue';
1517
import { EventRepository } from './repositories/event.repository';
1618
import { KeyRepository } from './repositories/key.repository';
1719
import { RoomRepository } from './repositories/room.repository';
@@ -28,6 +30,11 @@ import { ProfilesService } from './services/profiles.service';
2830
import { RoomService } from './services/room.service';
2931
import { ServerService } from './services/server.service';
3032
import { StagingAreaService } from './services/staging-area.service';
33+
import { DownloadedEventValidationPipeline } from './validation/pipelines/DownloadedEventValidationPipeline';
34+
import { SynchronousEventReceptionPipeline } from './validation/pipelines/synchronousEventReceptionPipeline';
35+
import { EventFormatValidator } from './validation/validators/EventFormatValidator';
36+
import { EventHashesAndSignaturesValidator } from './validation/validators/EventHashesAndSignaturesValidator';
37+
import { EventTypeSpecificValidator } from './validation/validators/EventTypeSpecificValidator';
3138

3239
const CONFIG_PROVIDER = {
3340
provide: ConfigService,
@@ -39,25 +46,45 @@ const CONFIG_PROVIDER = {
3946
QueueModule
4047
],
4148
providers: [
49+
// Core services
4250
CONFIG_PROVIDER,
4351
DatabaseConnection,
44-
EventRepository,
4552
EventService,
46-
InviteService,
4753
MissingEventService,
48-
ProfilesService,
4954
StagingAreaService,
50-
MissingEventListener,
51-
StagingAreaListener,
52-
ServerRepository,
53-
ServerService,
54-
RoomRepository,
55-
RoomService,
56-
EventStateService,
55+
56+
// Event processing services
5757
EventAuthorizationService,
58-
NotificationService,
58+
EventStateService,
5959
FederationService,
60+
NotificationService,
61+
InviteService,
62+
ProfilesService,
63+
ServerService,
64+
RoomService,
65+
66+
// Repositories
67+
EventRepository,
68+
RoomRepository,
6069
KeyRepository,
70+
ServerRepository,
71+
72+
// Queues
73+
MissingEventsQueue,
74+
StagingAreaQueue,
75+
76+
// Listeners
77+
MissingEventListener,
78+
StagingAreaListener,
79+
80+
// Validation pipelines
81+
DownloadedEventValidationPipeline,
82+
SynchronousEventReceptionPipeline,
83+
84+
// Validators
85+
EventFormatValidator,
86+
EventHashesAndSignaturesValidator,
87+
EventTypeSpecificValidator,
6188
],
6289
controllers: [
6390
PingController,

packages/homeserver/src/listeners/missing-event.listener.ts

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,27 @@ import { ConfigService } from '../services/config.service';
66
import { EventService } from '../services/event.service';
77
import { StagingAreaService } from '../services/staging-area.service';
88
import { Logger } from '../utils/logger';
9-
import { DownloadedEventValidationPipeline } from '../validation/pipelines/DownloadedEventValidationPipeline';
109

1110
@Injectable()
1211
export class MissingEventListener {
1312
private readonly logger = new Logger('MissingEventListener');
1413
private readonly eventFetcher: EventFetcher;
15-
private readonly seenEvents = new Set<string>(); // Track events we've already tried to fetch
14+
private readonly seenEvents = new Set<string>();
1615

1716
constructor(
1817
@Inject(forwardRef(() => MissingEventsQueue)) private readonly missingEventsQueue: MissingEventsQueue,
1918
@Inject(forwardRef(() => StagingAreaQueue)) private readonly stagingAreaQueue: StagingAreaQueue,
2019
@Inject(forwardRef(() => StagingAreaService)) private readonly stagingAreaService: StagingAreaService,
2120
@Inject(EventService) private readonly eventService: EventService,
22-
@Inject(ConfigService) private readonly configService: ConfigService,
23-
@Inject(DownloadedEventValidationPipeline) private readonly eventValidationPipeline: DownloadedEventValidationPipeline,
21+
@Inject(ConfigService) private readonly configService: ConfigService
2422
) {
2523
this.missingEventsQueue.registerHandler(this.handleQueueItem.bind(this));
2624

2725
this.eventFetcher = new EventFetcher({
2826
config: {
2927
name: this.configService.getServerName(),
3028
signingKey: this.configService.getSigningKey(),
31-
debug: this.configService.isDebugEnabled()
29+
debug: true
3230
}
3331
});
3432
}
@@ -66,29 +64,16 @@ export class MissingEventListener {
6664
return;
6765
}
6866

69-
const validationContext = {
70-
config: {
71-
name: this.configService.getServerName(),
72-
signingKey: this.configService.getSigningKey()
73-
}
74-
};
75-
76-
const validatedEvents = await this.eventValidationPipeline.validate(
77-
fetchedEvents.events.map(e => e.event),
78-
validationContext
79-
);
80-
67+
// Process fetched events directly without validation pipeline
68+
// We'll use the standard event processing flow instead
8169
let addedCount = 0;
82-
for (const validatedEvent of validatedEvents.pdus) {
83-
if ('errcode' in validatedEvent) {
84-
this.logger.warn(`Validation failed for event: ${validatedEvent.error}`);
85-
continue;
86-
}
87-
88-
const event = validatedEvent.event;
70+
for (const eventData of fetchedEvents.events) {
71+
const event = eventData.event;
8972

73+
// Add the event to the staging area for processing
74+
// It will go through normal validation there
9075
this.stagingAreaService.addEventToQueue({
91-
eventId: event.event_id || event.eventId,
76+
eventId: event.event_id || eventData.eventId,
9277
roomId: event.room_id,
9378
origin: event.origin || origin,
9479
event

0 commit comments

Comments
 (0)