From 53b079188805b443fbb844aa9791aca86fd992ea Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 24 Dec 2024 00:38:52 -0300 Subject: [PATCH] specify auth_events --- packages/core/src/events/m.room.member.ts | 12 ++++++++++-- packages/homeserver/src/procedures/makeJoin.ts | 11 ++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/core/src/events/m.room.member.ts b/packages/core/src/events/m.room.member.ts index 3295e3e3..181a41bb 100644 --- a/packages/core/src/events/m.room.member.ts +++ b/packages/core/src/events/m.room.member.ts @@ -86,7 +86,11 @@ export const roomMemberEvent = ({ roomId: string; sender: string; state_key: string; - auth_events: string[]; + auth_events: { + create: string; + power_levels: string; + join_rules: string; + }; prev_events: string[]; depth: number; unsigned?: RoomMemberEvent["unsigned"]; @@ -97,7 +101,11 @@ export const roomMemberEvent = ({ return createEventBase("m.room.member", { roomId, sender, - auth_events, + auth_events: [ + auth_events.create, + auth_events.power_levels, + auth_events.join_rules, + ], prev_events, depth, content: { diff --git a/packages/homeserver/src/procedures/makeJoin.ts b/packages/homeserver/src/procedures/makeJoin.ts index 17314a3b..b4249962 100644 --- a/packages/homeserver/src/procedures/makeJoin.ts +++ b/packages/homeserver/src/procedures/makeJoin.ts @@ -31,12 +31,21 @@ export const makeJoinEventBuilder = } const authEvents = await getAuthEvents(roomId); + + const authEventsMap = new Map( + authEvents.map((event) => [event.event.type, event]), + ); + const event = roomMemberEvent({ membership: "join", roomId, sender: userId, state_key: userId, - auth_events: authEvents.map((event) => event._id), + auth_events: { + create: authEventsMap.get("m.room.create")!._id, + power_levels: authEventsMap.get("m.room.power_levels")!._id, + join_rules: authEventsMap.get("m.room.join_rules")!._id, + }, prev_events: [lastEvent._id], depth: lastEvent.event.depth + 1, origin,