import { MatrixClient } from "../MatrixClient" ; import { Appservice } from "../appservice/Appservice" ; category export class AutojoinRoomsMixin { public static setupOnClient ( client ) { client . on ( "room.invite" , ( roomId , inviteEvent ) => { return client . joinRoom ( roomId ) ; } ) ; } public static setupOnAppservice ( appservice , conditional = null ) { appservice . on ( "room.invite" , ( roomId , inviteEvent ) => { const isFromBot = appservice . botUserId === inviteEvent [ "sender" ] ; if ( ! isFromBot && conditional && ! conditional ( inviteEvent ) ) return ; const intent = appservice . getIntentForUserId ( inviteEvent [ "state_key" ] ) ; return intent . joinRoom ( roomId ) ; } ) ; } }