import { StateEvent } from "./RoomEvent" ; import { InvalidEventError } from "./InvalidEventError" ; category see MembershipEventContent export type Membership = "join" | "leave" | "ban" | "invite" ; category see MembershipEventContent export type EffectiveMembership = "join" | "leave" | "invite" ; category see MembershipEvent export interface MembershipEventContent { avatar_url ? : string ; displayname ? : string ; membership : Membership ; is_direct ? : boolean ; unsigned ? : any ; third_party_invite ? : { display_name : string ; signed : any ; } ; } category export class MembershipEvent extends StateEvent < MembershipEventContent > { constructor ( event ) { super ( event ) ; } /**
     * True if the membership event targets the sender. False otherwise.
     *
     * This will typically by false for kicks and bans.
     */ public get ownMembership ( ) : boolean { return this . membershipFor === this . sender ; } /**
     * The user ID the membership affects.
     */ public get membershipFor ( ) : string { return this . stateKey ; } /**
     * The user's membership.
     */ public get membership ( ) : Membership { const membership = this . content . membership ; if ( ! membership ) throw new InvalidEventError ( "no membership field in content" ) ; return membership ; } /**
     * The user's effective membership.
     */ public get effectiveMembership ( ) : EffectiveMembership { if ( this . membership === "join" ) return "join" ; if ( this . membership === "invite" ) return "invite" ; return "leave" ; } }