Skip to content

Commit

Permalink
specify auth_events
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Dec 24, 2024
1 parent 5b31621 commit af24e8a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
12 changes: 10 additions & 2 deletions packages/core/src/events/m.room.member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand All @@ -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: {
Expand Down
11 changes: 10 additions & 1 deletion packages/homeserver/src/procedures/makeJoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit af24e8a

Please sign in to comment.