import { MatrixClient } from "./MatrixClient" ; import { MSC2380MediaInfo } from "./models/unstable/MediaInfo" ; category export interface GroupProfile { /**
     * The name of the group
     */ name : string ; /**
     * The avatar for the group. Must be a MSC URI.
     */ avatar_url : string ; /**
     * The short description for the group. Equivalent to a room's topic.
     */ short_description : string ; /**
     * The long description for the group. Most clients will support HTML
     * in this.
     */ long_description : string ; } category export class UnstableApis { constructor ( private client ) { } param { string } roomId returns { Promise < string [ ] > } deprecated public async getRoomAliases ( roomId ) { const r = await this . client . doRequest ( "GET" , "/_matrix/client/unstable/org.matrix.msc2432/rooms/" + encodeURIComponent ( roomId ) + "/aliases" ) ; return r [ 'aliases' ] || [ ] ; } param { string } localpart return { Promise < string > } public async createGroup ( localpart ) { const response = await this . client . doRequest ( "POST" , "/_matrix/client/unstable/create_group" , null , { "localpart" : localpart } ) ; return response [ "group_id" ] ; } param { string } groupId param { string } userId return { Promise < "join" | "invite" | "reject" > } public async inviteUserToGroup ( groupId , userId ) { const response = await this . client . doRequest ( "PUT" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/admin/users/invite/${ encodeURIComponent ( userId ) }` , null , { } ) ; return response [ "state" ] ; } param { string } groupId param { string } userId return { Promise < any > } public async kickUserFromGroup ( groupId , userId ) { return this . client . doRequest ( "PUT" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/admin/users/remove/${ encodeURIComponent ( userId ) }` , null , { } ) ; } param { string } groupId param { GroupProfile } profile return { Promise < any > } public async setGroupProfile ( groupId , profile ) { return this . client . doRequest ( "POST" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/profile` , null , profile ) ; } param { string } groupId param { "open" | "invite" } policy return { Promise < any > } public async setGroupJoinPolicy ( groupId , policy ) { return this . client . doRequest ( "PUT" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/settings/m.join_policy` , null , { "m.join_policy" : { "type" : policy , } , } ) ; } param { string } groupId param { string } roomId param { boolean } isPublic return { Promise < any > } public async addRoomToGroup ( groupId , roomId , isPublic = true ) { return this . client . doRequest ( "PUT" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/admin/rooms/${ encodeURIComponent ( roomId ) }` , null , { "m.visibility" : { type : isPublic ? "public" : "private" } , } ) ; } param { string } groupId param { string } roomId param { boolean } isPublic return { Promise < any > } public async updateGroupRoomVisibility ( groupId , roomId , isPublic ) { return this . client . doRequest ( "PUT" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/admin/rooms/${ encodeURIComponent ( roomId ) }/config/m.visibility` , null , { type : isPublic ? "public" : "private" , } ) ; } param { string } groupId param { string } roomId return { Promise < any > } public async removeRoomFromGroup ( groupId , roomId ) { return this . client . doRequest ( "DELETE" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/admin/rooms/${ encodeURIComponent ( roomId ) }` ) ; } param { string } groupId return { Promise < GroupProfile > } public async getGroupProfile ( groupId ) { return this . client . doRequest ( "GET" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/profile` ) ; } param { string } groupId return { Promise < any [ ] > } public async getGroupUsers ( groupId ) { const response = await this . client . doRequest ( "GET" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/users` ) ; return response [ "chunk" ] ; } param { string } groupId return { Promise < any [ ] > } public async getGroupInvitedUsers ( groupId ) { const response = await this . client . doRequest ( "GET" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/invited_users` ) ; return response [ "chunk" ] ; } param { string } groupId return { Promise < any [ ] > } public async getGroupRooms ( groupId ) { const response = await this . client . doRequest ( "GET" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/rooms` ) ; return response [ "chunk" ] ; } param { string } groupId return { Promise < any > } public async acceptGroupInvite ( groupId ) { return this . client . doRequest ( "PUT" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/self/accept_invite` , null , { } ) ; } param { string } groupId return { Promise < any > } public async joinGroup ( groupId ) { return this . client . doRequest ( "PUT" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/self/join` , null , { } ) ; } param { string } groupId return { Promise < any > } public async leaveGroup ( groupId ) { return this . client . doRequest ( "PUT" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/self/leave` , null , { } ) ; } param { string } groupId param { boolean } publicise return { Promise < any > } public async setGroupPublicity ( groupId , publicise ) { return this . client . doRequest ( "PUT" , `/_matrix/client/unstable/groups/${ encodeURIComponent ( groupId ) }/self/update_publicity` , null , { publicise , } ) ; } return { Promise < string [ ] > } public async getJoinedGroups ( ) { const response = await this . client . doRequest ( "GET" , "/_matrix/client/unstable/joined_groups" ) ; return response [ "groups" ] ; } param { string } userId return { Promise < string [ ] > } public async getPublicisedGroups ( userId ) { const response = await this . client . doRequest ( "GET" , `/_matrix/client/unstable/publicised_groups/${ encodeURIComponent ( userId ) }` ) ; return response [ "groups" ] ; } param { string } roomId param { string } eventId param { string } emoji returns { Promise < string > } public async addReactionToEvent ( roomId , eventId , emoji ) { return this . client . sendEvent ( roomId , "m.reaction" , { "m.relates_to" : { event_id : eventId , key : emoji , rel_type : "m.annotation" , } , } ) ; } param { string } roomId param { string } eventId param { string ? } relationType param { string ? } eventType returns { Promise < { original_event : any , chunk : any [ ] } > } public async getRelationsForEvent ( roomId , eventId , relationType ? , eventType ? ) { let url = `/_matrix/client/unstable/rooms/${ roomId }/relations/${ eventId }` ; if ( relationType ) { url += `/${ relationType }` ; } if ( eventType ) { url += `/${ eventType }` ; } return this . client . doRequest ( "GET" , url ) ; } param { string } mxc returns { Promise < MSC2380MediaInfo > } public async getMediaInfo ( mxcUrl ) { if ( ! mxcUrl . toLowerCase ( ) . startsWith ( "mxc://" ) ) { throw Error ( "'mxcUrl' does not begin with mxc://" ) ; } const [ domain , mediaId ] = mxcUrl . substr ( "mxc://" . length ) . split ( "/" ) ; if ( ! domain || ! mediaId ) { throw Error ( 'Missing domain' ) ; } if ( ! mediaId ) { throw Error ( 'Missing mediaId' ) ; } return this . client . doRequest ( "GET" , `/_matrix/media/unstable/info/${ encodeURIComponent ( domain ) }/${ encodeURIComponent ( mediaId ) }` ) ; } }