Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions packages/federation-sdk/src/services/room.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,9 +846,7 @@ export class RoomService {
// ^ have the template for the join event now

const joinEvent = PersistentEventFactory.createFromRawEvent(
makeJoinResponse.event as unknown as Parameters<
typeof PersistentEventFactory.createFromRawEvent
>[0], // TODO: using room package types will take care of this
makeJoinResponse.event, // TODO: using room package types will take care of this
makeJoinResponse.room_version,
);

Expand All @@ -866,9 +864,7 @@ export class RoomService {

for (const stateEvent_ of sendJoinResponse.state) {
const stateEvent = PersistentEventFactory.createFromRawEvent(
stateEvent_ as unknown as Parameters<
typeof PersistentEventFactory.createFromRawEvent
>[0],
stateEvent_,
makeJoinResponse.room_version,
);

Expand All @@ -877,9 +873,7 @@ export class RoomService {

for (const authEvent_ of sendJoinResponse.auth_chain) {
const authEvent = PersistentEventFactory.createFromRawEvent(
authEvent_ as unknown as Parameters<
typeof PersistentEventFactory.createFromRawEvent
>[0],
authEvent_,
makeJoinResponse.room_version,
);
eventMap.set(authEvent.eventId, authEvent);
Expand Down Expand Up @@ -907,9 +901,7 @@ export class RoomService {
}

const joinEventFinal = PersistentEventFactory.createFromRawEvent(
sendJoinResponse.event as unknown as Parameters<
typeof PersistentEventFactory.createFromRawEvent
>[0],
sendJoinResponse.event,
makeJoinResponse.room_version,
);

Expand Down
13 changes: 8 additions & 5 deletions packages/federation-sdk/src/specs/federation-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
* See: https://spec.matrix.org/v1.7/server-server-api/
*/

import {
EventPduTypeRoomMember,
PduSchema,
} from '@rocket.chat/federation-room';
import { z } from 'zod';

// Common types
Expand Down Expand Up @@ -111,7 +115,7 @@ export const MakeJoinEventSchema = z.object({

export const MakeJoinResponseSchema = z.object({
room_version: RoomVersionSchema,
event: MakeJoinEventSchema,
event: PduSchema,
});

export const SendJoinEventSchema = z.object({
Expand Down Expand Up @@ -139,10 +143,9 @@ export const SendJoinEventSchema = z.object({
});

export const SendJoinResponseSchema = z.object({
state: z.array(z.any()),
auth_chain: z.array(z.any()),
event_id: EventIdSchema.optional(),
event: SendJoinEventSchema.optional(),
state: z.array(PduSchema),
auth_chain: z.array(PduSchema),
event: EventPduTypeRoomMember,
members_omitted: z.boolean().optional(),
servers_in_room: z.array(z.string()).optional(),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/room/src/types/v3-11.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ const EventPduTypeRoomCreate = z.object({
content: PduCreateEventContentSchema,
});

const EventPduTypeRoomMember = z.object({
export const EventPduTypeRoomMember = z.object({
...PduNoContentStateEventSchema,
type: z.literal('m.room.member'),
content: PduMembershipEventContentSchema,
Expand Down