File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
packages/federation-sdk/src/services Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ export class EventService {
175175 Array . from ( eventsByRoomId . entries ( ) ) . map ( async ( [ roomId , events ] ) => {
176176 for await ( const event of events ) {
177177 try {
178- await this . validateEvent ( origin , event ) ;
178+ await this . validateEvent ( event ) ;
179179 } catch ( err ) {
180180 this . logger . error ( {
181181 msg : 'Event validation failed' ,
@@ -221,12 +221,25 @@ export class EventService {
221221 ) ;
222222 }
223223
224- private async validateEvent ( origin : string , event : Pdu ) : Promise < void > {
224+ private async validateEvent ( event : Pdu ) : Promise < void > {
225225 const roomVersion = await this . getRoomVersion ( event ) ;
226226 if ( ! roomVersion ) {
227227 throw new Error ( 'M_UNKNOWN_ROOM_VERSION' ) ;
228228 }
229229
230+ if (
231+ event . type === 'm.room.member' &&
232+ event . content . membership === 'invite' &&
233+ 'third_party_invite' in event . content
234+ ) {
235+ throw new Error ( 'Third party invites are not supported' ) ;
236+ }
237+
238+ const origin = event . sender . split ( ':' ) . pop ( ) ;
239+ if ( ! origin ) {
240+ throw new Error ( 'Event sender is missing domain' ) ;
241+ }
242+
230243 const eventSchema = this . getEventSchema ( roomVersion , event . type ) ;
231244
232245 const validationResult = eventSchema . safeParse ( event ) ;
You can’t perform that action at this time.
0 commit comments