2017-08-23 23:15:01 +02:00
/ *
2018-02-04 03:22:01 +01:00
// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
* /
2017-08-23 23:15:01 +02:00
'use strict' ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* MATRIX PROTOCOL
*
* /
mc . m = { }
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Matrix utilities
*
* /
/ * * l o c a l p a r t o f i d
* /
mc . m . local = ( mxid ) =>
typeif ( mxid , "string" , ( ) => mxid . split ( ':' ) [ 0 ] ) ;
/ * * d o m a i n p a r t o f i d - C h o p s o f f t h e d o m a i n a n d o t h e r n o n - n a m e c h a r a c t e r s f r o m a n m x i d
* /
mc . m . domid = ( mxid ) =>
typeif ( mxid , "string" , ( ) => mxid . split ( ':' ) [ 1 ] ) ;
/ * * s h o r t i d - C h o p s o f f t h e d o m a i n a n d o t h e r n o n - n a m e c h a r a c t e r s f r o m a n m x i d
* /
mc . m . sid = ( mxid ) =>
typeif ( mxid , "string" , ( ) => mc . m . local ( mxid ) . replace ( /^[\@\!\$]/ , '' ) ) ;
/ * * p r e t t y _ e r r c o d e
* /
mc . m . pretty _errcode = ( errcode ) =>
typeif ( errcode , "string" , ( ) => errcode . replace ( /^M_/ , "" ) . replace ( /_/g , " " ) ) ;
/ * * R a n d o m n e s s
*
* This is a library to generate various elements of the matrix protocol
* when they need to have random content .
* /
mc . m . random = { }
/** Generate a random mxid */
mc . m . random . mxid = ( prefix = "$" , domain = "localhost" ) =>
prefix + ( new Date ) . getTime ( ) + mc . random . string ( 5 ) + "@" + domain ;
/ * * S i g i l s p e c i f i c a t i o n
* /
mc . m . sigil =
{
'@' : "user_id" ,
'!' : "room_id" ,
'$' : "event_id" ,
'#' : "room_alias" ,
} ;
/ * * F i n d s i g i l r e v e r s e l o o k u p
* /
Object . defineProperty ( mc . m . sigil , 'find' , {
enumerable : false ,
valud : function ( what )
{
return Object . keys ( this ) . find ( ( key ) =>
{
return ( this ) [ key ] == what ;
} ) ;
} } ) ;
/ * * V a l i d a t o r s
*
* This is a library of various validator functions for the matrix protocol
* /
mc . m . valid = { } ;
mc . m . valid [ "user_id" ] = function ( mxid )
{
return mc . m . valid . mxid ( mxid , "@" ) ;
} ;
mc . m . valid [ "room_id" ] = function ( mxid )
{
return mc . m . valid . mxid ( mxid , "!" ) ;
} ;
mc . m . valid [ "event_id" ] = function ( mxid )
{
return mc . m . valid . mxid ( mxid , "!" ) ;
} ;
mc . m . valid [ "room_alias" ] = function ( mxid )
{
return mc . m . valid . mxid ( mxid , "#" ) ;
} ;
mc . m . valid . mxid = function ( mxid , sigil = undefined , opts = { } )
{
if ( ! this . sigil . valid ( mxid ) )
return false ;
let [ local , domain ] = mxid . split ( ':' ) ;
if ( local . length <= 1 )
return false ;
if ( sigil !== undefined )
if ( local [ 0 ] != sigil )
return false ;
if ( opts . valid _domain === true )
if ( ! valid _domain ( domain ) )
return false ;
return true ;
} ;
mc . m . valid . sigil = function ( string )
{
if ( typeof ( string ) != "string" )
return false ;
if ( ! this . expr . test ( string ) )
return false ;
return true ;
} ;
mc . m . valid . sigil . expr = /^(\@|\!|\$|\@)/ ;
/** Translates an mxc:/ / when the registered window protocol handler isn ' t relevant
* /
mc . m . xc = ( url ) =>
{
if ( typeof ( url ) != "string" )
return url ;
if ( ! url . startsWith ( "mxc://" ) )
return url ;
let mxc _protocol _path = mc . opts . base _url + "/_matrix/media/r0/download/" ;
return url . replace ( "mxc://" , mxc _protocol _path ) ;
} ;
/ * * ? ? ?
*
* /
mc . m . error = async function ( path )
{
let ret =
{
error : await path . error ,
} ;
if ( ! ret . error )
return false ;
ret . errcode = await path . errcode ;
return ret ;
} ;
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Matrix Protocol Specification / IO
*
* /
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 2 API Standards
*
* /
/ * * 2 . 1 V e r s i o n s
*
* Gets the versions of the specification supported by the server . Values will take
* the form rX . Y . Z . Only the latest Z value will be reported for each supported X . Y
* value . i . e . if the server implements r0 . 0.0 , r0 . 0.1 , and r1 . 2.0 , it will report
* r0 . 0.1 and r1 . 2.0 .
* /
mc . m . versions = { } ;
mc . m . versions . get = function ( opts = { } )
{
Object . update ( opts ,
{
method : "GET" ,
resource : "versions" ,
prefix : "/_matrix/client/" ,
version : null ,
} ) ;
return new mc . io . request ( opts , ( error , data ) =>
{
return callback ( arguments , error , data ) ;
} ) ;
} ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 3 Client Authentication
*
* /
/ * *
* 3.2 Login
* /
mc . m . login = { } ;
/ * * 3 . 2 L o g i n F l o w s
* /
mc . m . login . get = function ( opts = { } )
{
Object . update ( opts ,
{
method : "GET" ,
resource : "login" ,
prefix : "/_matrix/client/" ,
version : 0 ,
} ) ;
return new mc . io . request ( opts , ( error , data ) =>
{
return callback ( arguments , error , data ) ;
} ) ;
} ;
/ * * 3 . 2 . 1 L o g i n
* /
mc . m . login . post = function ( opts = { } )
{
Object . defaults ( opts ,
{
content :
{
type : "m.login.dummy"
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
resource : "login" ,
prefix : "/_matrix/client/" ,
version : 0 ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * * 3 . 1 . 2 . 1 P a s s w o r d - b a s e d
*
* /
mc . m . login . password = function ( username , password , opts = { } )
{
Object . defaults ( opts ,
{
content :
{
user : username ,
password : password ,
type : "m.login.password" ,
} ,
} ) ;
return mc . m . login . post ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * * 3 . 1 . 2 . 3 T o k e n - b a s e d
*
* /
mc . m . login . token = function ( username , token , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
content :
{
user : username ,
token : token ,
type : "m.login.token" ,
txn _id : mc . local . txnid ++ ,
} ,
} ) ;
return mc . m . login . post ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * * 3 . 2 . 2 t o k e n r e f r e s h
*
* /
mc . m . tokenrefresh = { } ;
mc . m . tokenrefresh . post = function ( opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
content :
{
refresh _token : mc . local . refresh _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
resource : "tokenrefresh" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * * 3 . 2 . 3 l o g o u t
*
* /
mc . m . logout = { } ;
mc . m . logout . post = function ( opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
resource : "logout" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * * 3 . 3 A c c o u n t r e g i s t r a t i o n a n d m a n a g e m e n t
*
* /
mc . m . register = { } ;
mc . m . account = { } ;
/ * * 3 . 3 . 1 r e g i s t e r
*
* /
mc . m . register . post = function ( opts = { } )
{
Object . defaults ( opts ,
{
query :
{
// The kind of account to register. Defaults to user. One of: ["guest", "user"]
kind : "guest" ,
} ,
content :
{
// The local part of the desired Matrix ID. If omitted, the homeserver MUST
// generate a Matrix ID local part.
username : undefined ,
// If true, the server binds the email used for authentication to the Matrix ID
// with the ID Server.
bind _email : undefined ,
// Required. The desired password for the account.
password : undefined ,
// Additional authentication information for the user-interactive authentication API.
auth :
{
// The value of the session key given by the homeserver.
session : undefined ,
// Required. The login type that the client is attempting to complete.
type : "m.login.dummy" ,
}
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
resource : "register" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * * 3 . 4 A c c o u n t A d m i n i s t r a t i v e c o n t a c t i n f o r m a t i o n
*
* /
mc . m . account [ '3pid' ] = { } ;
/ * * 3 . 4 . 1 P O S T 3 p i d
*
* /
/ * * 3 . 4 . 2 G E T 3 p i d
*
* /
mc . m . account [ '3pid' ] . get = function ( opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "GET" ,
resource : "account/3pid" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 5 Filtering
*
* Filters can be created on the server and can be passed as as a parameter to APIs
* which return events . These filters alter the data returned from those APIs . Not
* all APIs accept filters .
*
* /
// Protocol suite
mc . m . filter = { } ;
/ * * 5 . 1 G E T F i l t e r
*
* Download a filter
* /
mc . m . filter . get = function ( filter _id , opts = { } )
{
let user _id = mc . uri ( mc . session . user _id ) ;
let resource = "user/" + user _id + "/filter/" + mc . uri ( filter _id ) ;
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "GET" ,
resource : resource ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * * 5 . 2 P O S T F i l t e r
*
* Uploads a new filter definition to the homeserver . Returns a filter ID that may be used in
* future requests to restrict which events are returned to the mc .
* /
mc . m . filter . post = function ( content = { } , opts = { } )
{
if ( ! mc . instance . authentic )
throw new mc . error ( "Posting a filter requires authentication" ) ;
let filter =
{
// A list of event types to exclude. If this list is absent then no event types are
// excluded. A matching type will be excluded even if it is listed in the 'types'
// filter. A '*' can be used as a wildcard to match any sequence of characters.
not _types : [ ] ,
// The maximum number of events to return.
limit : undefined ,
// A list of senders IDs to include. If this list is absent then all senders are included.
senders : [ ] ,
// A list of event types to include. If this list is absent then all event types are
// included. A '*' can be used as a wildcard to match any sequence of characters.
types : [ ] ,
// A list of sender IDs to exclude. If this list is absent then no senders are excluded.
// A matching sender will be excluded even if it is listed in the 'senders' filter.
not _senders : [ ] ,
} ;
let room _event _filter =
{
// A list of event types to exclude. If this list is absent then no event types are
// excluded. A matching type will be excluded even if it is listed in the 'types'
// filter. A '*' can be used as a wildcard to match any sequence of characters.
not _types : [ ] ,
// A list of room IDs to exclude. If this list is absent then no rooms are excluded.
// A matching room will be excluded even if it is listed in the 'rooms' filter.
not _rooms : [ ] ,
// The maximum number of events to return.
limit : undefined ,
// A list of room IDs to include. If this list is absent then all rooms are included.
rooms : [ ] ,
// A list of sender IDs to exclude. If this list is absent then no senders are excluded.
// A matching sender will be excluded even if it is listed in the 'senders' filter.
not _senders : [ ] ,
// A list of senders IDs to include. If this list is absent then all senders are included.
senders : [ ] ,
// A list of event types to include. If this list is absent then all event types are
// included. A '*' can be used as a wildcard to match any sequence of characters.
types : [ ] ,
} ;
let room _filter =
{
// Include rooms that the user has left in the sync, default false
include _leave : undefined ,
// The per user account data to include for rooms.
account _data : undefined , //filter,
// The message and state update events to include for rooms.
timeline : undefined , //room_event_filter,
// The events that aren't recorded in the room history, e.g. typing and receipts,
// to include for rooms.
ephemeral : undefined , //room_event_filter,
// The state events to include for rooms.
state : undefined , //room_event_filter,
// A list of room IDs to exclude. If this list is absent then no rooms are
// excluded. A matching room will be excluded even if it is listed in the
// 'rooms' filter. This filter is applied before the filters in ephemeral,
// state, timeline or account_data
not _rooms : undefined , //[],
// A list of room IDs to include. If this list is absent then all rooms are
// included. This filter is applied before the filters in ephemeral, state,
// timeline or account_data
rooms : undefined , //[],
} ;
Object . defaults ( content ,
{
// List of event fields to include. If this list is absent then all fields are included.
// The entries may include '.' charaters to indicate sub-fields. So ['content.body'] will
// include the 'body' field of the 'content' object. A literal '.' character in a field
// name may be escaped using a '\'. A server may include more fields than were requested.
event _fields : undefined , //[],
// The format to use for events. 'client' will return the events in a format suitable for
// clients. 'federation' will return the raw event as receieved over federation. The default
// is 'client'. One of: ["client", "federation"]
event _format : undefined ,
// The user account data that isn't associated with rooms to include.
account _data : undefined , //filter,
// Filters to be applied to room data.
room : undefined , //room_filter,
// The presence updates to include.
presence : undefined , //filter,
} ) ;
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
content : content ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
resource : "user/" + mc . uri ( mc . my . mxid ) + "/filter" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 6 Events
*
* /
/ * * 6 . 2 S y n c i n g
*
* /
mc . m . sync = { } ;
/ * * 6 . 2 . 1 g e t s y n c
*
* /
mc . m . sync . get = function ( opts = { } )
{
Object . defaults ( opts , mc . m . sync . get . opts ) ;
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
}
} ) ;
Object . update ( opts ,
{
method : "GET" ,
resource : "sync" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
mc . m . sync . get . opts =
{
// This timeout is our XHR timeout, not the longpoll timeout sent to the server in the
// query string. This only fires if there's a real connection problem. Set this to
// something higher than the longpoll timeout.
timeout : 305 * 1000 ,
} ;
mc . m . sync . get . opts . query =
{
// The maximum time to poll in milliseconds before returning this request.
timeout : 300 * 1000 ,
// The ID of a filter created using the filter API or a filter JSON object
// encoded as a string. The server will detect whether it is an ID or a JSON
// object by whether the first character is a "{" open brace. Passing the JSON
// inline is best suited to one off requests. Creating a filter using the filter
// API is recommended for clients that reuse the same filter multiple times, for
// example in long poll requests.
filter : undefined ,
// Controls whether the client is automatically marked as online by polling this API.
// If this parameter is omitted then the client is automatically marked as online
// when it uses this API. Otherwise if the parameter is set to "offline" then the
// client is not marked as being online when it uses this API. One of: ["offline"]
set _presence : undefined , //"online",
// Controls whether to include the full state for all rooms the user is a member of.
// If this is set to true, then all state events will be returned, even if since is
// non-empty. The timeline will still be limited by the since parameter. In this case,
// the timeout parameter will be ignored and the query will return immediately,
// possibly with an empty timeline.
// If false, and since is non-empty, only state which has changed since the point
// indicated by since will be returned. By default, this is false.
full _state : false ,
} ;
/ * *
* 6.3 Getting events for a room
* 6.4 Sending events to a room
* 6.5 Redactions
* /
mc . m . rooms = { } ;
mc . m . rooms . state = { } ;
mc . m . rooms . members = { } ;
mc . m . rooms . messages = { } ;
mc . m . rooms . send = { } ;
mc . m . rooms . redact = { } ;
// abstract
mc . m . rooms . request = function ( room _id , resource , opts = { } )
{
Object . defaults ( opts ,
{
method : "GET" ,
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
let uri = mc . uri ( room _id ) ;
Object . update ( opts ,
{
resource : "rooms/" + uri + "/" + resource ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
// abstract
mc . m . rooms . state . request = function ( room _id , type = undefined , state _key = undefined , opts = { } )
{
let resource = "state" ;
if ( type !== undefined )
{
resource += "/" + type ;
if ( state _key !== undefined && state _key . length )
resource += "/" + state _key ;
}
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . request ( room _id , resource , opts , handler ) ;
} ;
/ * * 6 . 3 G e t t i n g e v e n t s f o r a r o o m
* /
/ * * 6 . 3 . 1 G E T s t a t e
* + 6.3 . 2 GET state eventType
* + 6.3 . 3 GET state eventType stateKey
* /
mc . m . rooms . state . get = function ( room _id , type = undefined , state _key = undefined , opts = { } )
{
Object . update ( opts ,
{
method : "GET" ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . state . request ( room _id , type , state _key , opts , handler ) ;
} ;
/ * * 6 . 3 . 4 G E T m e m b e r s
* /
mc . m . rooms . members . get = function ( room _id , opts = { } )
{
let resource = "members" ;
Object . update ( opts ,
{
method : "GET" ,
} ) ;
Object . defaults ( opts ,
{
query :
{
filter : mc . filter ( "members" ) ,
} ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . request ( room _id , resource , opts , handler ) ;
} ;
/ * * 6 . 3 . 5 G E T m e s s a g e s
* /
mc . m . rooms . messages . get = function ( room _id , opts = { } )
{
let resource = "messages" ;
Object . update ( opts ,
{
method : "GET" ,
} ) ;
Object . defaults ( opts ,
{
query :
{
//from: undefined,
//to: undefined,
//dir: "b",
limit : 128 ,
} ,
} ) ;
let handler = ( error , data ) =>
{
if ( error || ! data )
return callback ( arguments , error , data ) ;
switch ( opts . query . dir )
{
case 'b' :
opts . query . from = data . start ;
opts . query . to = undefined ;
break ;
case 'f' :
opts . query . from = data . end ;
opts . query . to = undefined ;
break ;
}
return callback ( arguments , error , data ) ;
} ;
return mc . m . rooms . request ( room _id , resource , opts , handler ) ;
} ;
/ * * 6 . 4 S e n d i n g e v e n t s t o a r o o m
* /
/ * * 6 . 4 . 1 P U T s t a t e e v e n t T y p e
* + 6.4 . 2 PUT state eventType stateKey
* /
mc . m . rooms . state . put = function ( room _id , type , state _key = "" , content = { } , opts = { } )
{
Object . defaults ( opts ,
{
content : content ,
} ) ;
Object . update ( opts ,
{
method : "PUT" ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . state . request ( room _id , type , state _key , opts , handler ) ;
}
/ * * 6 . 4 . 3 P U T s e n d e v e n t T y p e t x n I d
*
* Content of the event passed in opts . content
* /
mc . m . rooms . send . put = function ( room _id , type , opts = { } )
{
Object . update ( opts ,
{
method : "PUT" ,
txnid : mc . local . txnid ++ ,
} ) ;
let resource = "send/" + type + "/" + opts . txnid ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . request ( room _id , resource , opts , handler ) ;
} ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 7 Rooms
*
* /
/ * * 7 . 1 C r e a t i o n
*
* /
mc . m . createRoom = { } ;
mc . m . createRoom . post = function ( opts = { } )
{
Object . defaults ( opts , mc . m . createRoom . post . opts ) ;
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
resource : "createRoom" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
mc . m . createRoom . post . opts = { } ;
mc . m . createRoom . post . opts . content =
{
// A list of user IDs to invite to the room. This will tell the server to invite everyone in the list
// to the newly created room.
invite : undefined ,
// If this is included, an m.room.name event will be sent into the room to indicate the name of the
// room. See Room Events for more information on m.room.name.
name : undefined ,
// A public visibility indicates that the room will be shown in the published room list. A private
// visibility will hide the room from the published room list. Rooms default to private visibility if this key is not included. NB: This should not be confused with join_rules which also uses the word public.
// One of: ["public", "private"]
visibility : undefined ,
// A list of objects representing third party IDs to invite into the room.
invite _3pid : undefined ,
// If this is included, an m.room.topic event will be sent into the room to indicate the topic for
// the room. See Room Events for more information on m.room.topic.
topic : undefined ,
// Extra keys to be added to the content of the m.room.create. The server will clober the following
// keys: creator. Future versions of the specification may allow the server to clobber other keys.
creation _content : undefined ,
// A list of state events to set in the new room. This allows the user to override the default
// state events set in the new room. The expected format of the state events are an object with
// 'type', 'state_key' and 'content' keys set. Takes precedence over events set by presets, but gets
// overriden by name and topic keys.
initial _state : undefined ,
// The desired room alias local part. If this is included, a room alias will be created and mapped to
// the newly created room. The alias will belong on the same homeserver which created the room. For
// example, if this was set to "foo" and sent to the homeserver "example.com" the complete room alias
// would be #foo:example.com.
room _alias _name : undefined ,
} ;
/ * * 7 . 2 R o o m a l i a s e s
*
* /
mc . m . directory = { } ;
/ * * 7 . 2 . 1 P U T
*
* /
mc . m . directory . put = function ( alias , room _id , opts = { } )
{
Object . update ( opts ,
{
method : "PUT" ,
content :
{
room _id : room _id ,
} ,
} ) ;
return mc . m . directory . request ( alias , opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * * 7 . 2 . 2 D E L E T E
*
* /
mc . m . directory . del = function ( alias , opts = { } )
{
Object . update ( opts ,
{
method : "DELETE" ,
} ) ;
return mc . m . directory . request ( alias , opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * * 7 . 2 . 3 G E T
*
* /
mc . m . directory . get = function ( alias , opts = { } )
{
Object . update ( opts ,
{
method : "GET" ,
} ) ;
return mc . m . directory . request ( alias , opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * * A b s t r a c t
* /
mc . m . directory . request = function ( alias , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
resource : "directory/room/" + mc . uri ( alias ) ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * * 7 . 4 R o o m M e m b e r s h i p
*
* /
/ * * 7 . 4 . 1 J o i n i n g R o o m s
*
* /
/ * * 7 . 4 . 1 . 1 P O S T i n v i t e
* /
mc . m . rooms . invite = { } ;
mc . m . rooms . invite . post = function ( room _id , user _id , opts = { } )
{
let resource = "invite" ;
Object . defaults ( opts ,
{
content :
{
user _id : user _id ,
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . request ( room _id , resource , opts , handler ) ;
}
/ * * 7 . 4 . 1 . 2 P O S T j o i n
* /
mc . m . join = { } ;
mc . m . join . post = function ( room _id _or _alias , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
content :
{
third _party _signed : undefined ,
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
resource : "join/" + mc . uri ( room _id _or _alias ) ,
prefix : "/_matrix/client/" ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return new mc . io . request ( opts , handler ) ;
}
/ * * 7 . 4 . 1 . 3 P O S T j o i n
* /
mc . m . rooms . join = { } ;
mc . m . rooms . join . post = function ( room _id , opts = { } )
{
let resource = "join" ;
Object . defaults ( opts ,
{
content :
{
third _party _signed : undefined ,
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . request ( room _id , resource , opts , handler ) ;
}
/ * * 7 . 4 . 2 L e a v i n g r o o m s
*
* /
/ * * 7 . 4 . 2 . 1 P O S T f o r g e t
* /
mc . m . rooms . forget = { } ;
mc . m . rooms . forget . post = function ( room _id , opts = { } )
{
let resource = "forget" ;
Object . update ( opts ,
{
method : "POST" ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . request ( room _id , resource , opts , handler ) ;
}
/ * * 7 . 4 . 2 . 2 P O S T l e a v e
* /
mc . m . rooms . leave = { } ;
mc . m . rooms . leave . post = function ( room _id , opts = { } )
{
let resource = "leave" ;
Object . update ( opts ,
{
method : "POST" ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . request ( room _id , resource , opts , handler ) ;
}
/ * * 7 . 4 . 2 . 3 P O S T k i c k
* /
mc . m . rooms . kick = { } ;
mc . m . rooms . kick . post = function ( room _id , user _id , reason = undefined , opts = { } )
{
let resource = "kick" ;
Object . defaults ( opts ,
{
content :
{
user _id : user _id ,
reason : reason ,
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . request ( room _id , resource , opts , handler ) ;
}
/ * * 7 . 4 . 3 B a n n i n g u s e r s i n a r o o m
*
* /
/ * * 7 . 4 . 3 . 1 P O S T u n b a n
* /
mc . m . rooms . unban = { } ;
mc . m . rooms . unban . post = function ( room _id , user _id , opts = { } )
{
let resource = "unban" ;
Object . defaults ( opts ,
{
content :
{
user _id : user _id ,
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . request ( room _id , resource , opts , handler ) ;
}
/ * * 7 . 4 . 3 . 2 P O S T b a n
* /
mc . m . rooms . ban = { } ;
mc . m . rooms . ban . post = function ( room _id , user _id , reason = undefined , opts = { } )
{
let resource = "ban" ;
Object . defaults ( opts ,
{
content :
{
user _id : user _id ,
reason : reason ,
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . request ( room _id , resource , opts , handler ) ;
}
/ * * 7 . 5 L i s t i n g r o o m s
*
* /
mc . m . publicRooms = { } ;
/ * * 7 . 5 . 1
*
* /
mc . m . publicRooms . get = function ( opts = { } )
{
Object . update ( opts ,
{
method : "GET" ,
resource : "publicRooms" ,
prefix : "/_matrix/client/" ,
} ) ;
Object . defaults ( opts ,
{
query :
{
limit : 64 ,
access _token : mc . session . access _token ,
} ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * * E X P E R I M E N T A L
*
* /
mc . m . publicRooms . post = function ( opts = { } )
{
Object . defaults ( opts ,
{
query :
{
server : undefined ,
access _token : mc . session . access _token ,
} ,
content :
{
// limit param (content?)
limit : 128 ,
// since param (content?)
since : undefined ,
// filter_id (content?)
filter : undefined ,
// boolean
include _all _networks : undefined ,
third _party _instance _id : undefined ,
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
resource : "publicRooms" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 8 Profiles
*
* /
mc . m . profile = { } ;
mc . m . profile . displayname = { } ;
mc . m . profile . avatar _url = { } ;
/ * * 8 . 1 P U T d i s p l a y n a m e
* /
mc . m . profile . displayname . put = function ( user _id , displayname , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
content :
{
displayname : displayname ,
} ,
} ) ;
Object . update ( opts ,
{
method : "PUT" ,
resource : "profile/" + mc . uri ( user _id ) + "/displayname" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * * 8 . 2 G E T d i s p l a y n a m e
* /
mc . m . profile . displayname . get = function ( user _id , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "GET" ,
resource : "profile/" + mc . uri ( user _id ) + "/displayname" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * * 8 . 3 P U T a v a t a r _ u r l
* /
mc . m . profile . avatar _url . put = function ( user _id , avatar _url , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
content :
{
avatar _url : avatar _url ,
} ,
} ) ;
Object . update ( opts ,
{
method : "PUT" ,
resource : "profile/" + mc . uri ( user _id ) + "/avatar_url" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * * 8 . 4 G E T a v a t a r _ u r l
* /
mc . m . profile . avatar _url . get = function ( user _id , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "GET" ,
resource : "profile/" + mc . uri ( user _id ) + "/avatar_url" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * * 8 . 5 G E T p r o f i l e
*
* /
mc . m . profile . get = function ( user _id , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "GET" ,
resource : "profile/" + mc . uri ( user _id ) ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 11 Modules
*
* /
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 11.4 Typing notifications
*
* /
mc . m . rooms . typing = { } ;
/ * * 1 1 . 4 . 2 . 1 P U T t y p i n g
* /
mc . m . rooms . typing . put = function ( room _id , user _id , opts = { } )
{
Object . defaults ( opts ,
{
content :
{
timeout : 15 * 1000 ,
typing : true ,
} ,
} ) ;
Object . update ( opts ,
{
method : "PUT" ,
resource : "typing" + "/" + mc . uri ( user _id ) ,
prefix : "/_matrix/client/" ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . request ( room _id , opts . resource , opts , handler ) ;
}
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 11.5 Receipts
*
* /
mc . m . rooms . receipt = { } ;
/ * * 1 1 . 5 . 2 . 1 P O S T r e c e i p t
* /
mc . m . rooms . receipt . post = function ( room _id , event _id , type = "m.read" , opts = { } )
{
Object . update ( opts ,
{
method : "POST" ,
resource : "receipt/" + mc . uri ( type ) + "/" + mc . uri ( event _id ) ,
prefix : "/_matrix/client/" ,
} ) ;
return mc . m . rooms . request ( room _id , opts . resource , opts ) ;
}
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 11.6 Presence
*
* /
mc . m . presence = { } ;
mc . m . presence . list = { } ;
mc . m . presence . status = { } ;
/ * * 1 1 . 6 . 2
* /
/ * * 1 1 . 6 . 2 . 1 P U T s t a t u s
* /
mc . m . presence . status . put = function ( user _id , presence , status _msg = undefined , opts = { } )
{
if ( user _id === undefined )
user _id = mc . session . user _id ;
if ( presence === undefined )
presence = mc . instance . presence ;
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
content :
{
// The status message to attach to this state.
status _msg : status _msg ,
// Required. The new presence state. One of: ["online", "offline", "unavailable"]
presence : presence ,
} ,
} ) ;
let resource = "presence" ;
resource += "/" + mc . uri ( user _id ) ;
resource += "/" + "status" ;
Object . update ( opts ,
{
method : "PUT" ,
resource : resource ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * * 1 1 . 6 . 2 . 2 G E T s t a t u s
* /
mc . m . presence . status . get = function ( user _id , opts = { } )
{
if ( user _id === undefined )
user _id = mc . session . user _id ;
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "GET" ,
resource : "presence/" + mc . uri ( user _id ) + "/status" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * * 1 1 . 6 . 2 . 3 P O S T l i s t
*
* /
mc . m . presence . list . post = function ( user _id , delta = { drop : [ ] , invite : [ ] } , opts = { } )
{
if ( user _id === undefined )
user _id = mc . session . user _id ;
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
content :
{
drop : delta . drop ,
invite : delta . invite ,
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
resource : "presence/list/" + mc . uri ( user _id ) ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * * 1 1 . 6 . 2 . 4 G E T l i s t
* /
mc . m . presence . list . get = function ( user _id , opts = { } )
{
if ( user _id === undefined )
user _id = mc . session . user _id ;
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "GET" ,
resource : "presence/list/" + mc . uri ( user _id ) ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 11.7 Content Repository
*
* /
mc . m . media = { } ;
/ * *
* Register the mxc : // protocol with the browser for href's.
* /
//let mxc_protocol_path = mc.opts.base_url + "/_matrix/media/r0/download/%s";
//window.navigator.registerProtocolHandler("web+mxc", mxc_protocol_path, "Matrix Content");
/ * *
* 11.7 . 1 Client Behavior
*
* /
mc . m . media . download = { } ;
mc . m . media . upload = { } ;
/ * * 1 1 . 7 . 1 . 1 G E T m e d i a
*
* /
mc . m . media . download . get = function ( server _name , media _id , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
// This IO request is a corner-case. Setting these is required
// to override the mc.io.request()'s defaulting to JSON.
responseType : "arraybuffer" ,
} ) ;
//XXX: have to restore prefix clobber
let their _prefix = opts . prefix ;
Object . update ( opts ,
{
method : "GET" ,
prefix : "/_matrix/media/" ,
resource : "download/" + server _name + "/" + media _id ,
} ) ;
let handler = ( error , data , xhr ) =>
{
opts . prefix = their _prefix ;
if ( error )
return callback ( arguments , error , data , undefined ) ;
let type = xhr . getResponseHeader ( "content-type" ) ;
return callback ( arguments , error , data , type ) ;
} ;
return new mc . io . request ( opts , handler ) ;
}
/ * * 1 1 . 7 . 1 . 2 P O S T m e d i a
*
* All arguments in opts .
* opts . contentType
* opts . content - > xhr . send ( )
*
* /
mc . m . media . upload . post = function ( opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
//XXX: have to restore prefix clobber
let their _prefix = opts . prefix ;
Object . update ( opts ,
{
method : "POST" ,
resource : "upload" ,
prefix : "/_matrix/media/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) =>
{
opts . prefix = their _prefix ;
callback ( arguments , error , data ) ;
} ) ;
}
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 11.10 Push Notifications
*
* /
/ * * 1 1 . 1 0 . 1 p u s h e r s
*
* /
mc . m . pushers = { } ;
/ * * 1 1 . 1 0 . 1 . 2 G E T p u s h e r s
*
* /
mc . m . pushers . get = function ( opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "GET" ,
resource : "pushers" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts , ( error , data ) => callback ( arguments , error , data ) ) ;
} ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 11.12 Server Side Search
*
* /
mc . m . search = { } ;
/ * * 1 1 . 1 2 . 1 . 1 s e a r c h
*
* /
mc . m . search . post = function ( opts = { } )
{
Object . defaults ( opts , mc . m . search . post . opts ) ;
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "POST" ,
resource : "search" ,
prefix : "/_matrix/client/" ,
} ) ;
let remain = opts . query . limit ;
opts . query . limit = Math . min ( remain , opts . chunk _size ) ;
///TODO: XXX
// We continue to paginate automatically until finished or the user
// callback returns false.
let handler = ( error , data ) =>
{
if ( callback ( arguments , error , data ) === false )
return ;
if ( maybe ( ( ) => data . search _categories . room _events . next _batch ) === undefined )
return ;
//remain -= data.search_categories.room_events.
//opts.query.limit = Math.min(remain, opts.chunk_size);
opts . query . since = data . search _categories . room _events . next _batch ;
return new mc . io . request ( opts , handler ) ;
} ;
return new mc . io . request ( opts , handler ) ;
} ;
mc . m . search . post . opts =
{
chunk _size : 10 ,
query :
{
limit : 10 ,
} ,
} ;
mc . m . search . post . opts . content =
{
search _categories :
{
room _events :
{
// Required. The string to search events for.
search _term : "" ,
// Takes a section 5 filter
filter : undefined ,
// The keys to search. Defaults to all.
// One of: ["content.body", "content.name", "content.topic"]
keys : undefined ,
// Requests that the server partitions the result set based on the
// provided list of keys.
groupings :
{
// List of groups to request.
group _by : undefined ,
} ,
// The order in which to search for results. One of: ["recent", "rank"]
order _by : undefined ,
// Requests the server return the current state for each room returned.
include _state : undefined ,
// Configures whether any context for the events returned are included
// in the response.
event _context :
{
// How many events before the result are returned.
before _limit : undefined , // integer
// How many events after the result are returned.
after _limit : undefined , // integer
// Requests that the server returns the historic profile
// information for the users that sent the events that were
// returned.
include _profile : undefined , // boolean
} ,
} ,
} ,
} ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 11.14 Room Previews
*
* /
/ * * 1 1 . 1 4 . 1
*
* /
/ * * 1 1 . 1 4 . 1 . 1 G E T e v e n t s
*
* /
mc . m . events = { } ;
mc . m . events . get = function ( room _id , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
room _id : room _id ,
from : undefined ,
timeout : 60 * 1000 ,
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "GET" ,
resource : "events" ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 11.16 Client Config
*
* /
/ * * 1 1 . 1 6 . 2
*
* /
mc . m . user = { } ;
mc . m . user . account _data = { } ;
mc . m . user . rooms = { } ;
mc . m . user . rooms . account _data = { } ;
/ * * 1 1 . 1 6 . 2 . 1 P U T p e r r o o m a c c o u n t d a t a
*
* /
mc . m . user . rooms . account _data . put = function ( user _id , room _id , type , content , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
let resource ;
resource = "user/" + mc . uri ( user _id ) ;
resource += "/rooms/" + mc . uri ( room _id ) ;
resource += "/account_data/" + mc . uri ( type ) ;
Object . update ( opts ,
{
method : "PUT" ,
resource : resource ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
mc . m . user . rooms . account _data . del = function ( user _id , room _id , type , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
let resource ;
resource = "user/" + mc . uri ( user _id ) ;
resource += "/rooms/" + mc . uri ( room _id ) ;
resource += "/account_data/" + mc . uri ( type ) ;
Object . update ( opts ,
{
method : "DELETE" ,
resource : resource ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * * 1 1 . 1 6 . 2 . 2 P U T p e r r o o m a c c o u n t d a t a
*
* /
mc . m . user . account _data . put = function ( user _id , type , content , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
let resource ;
resource = "user/" + mc . uri ( user _id ) ;
resource += "/account_data/" + mc . uri ( type ) ;
Object . update ( opts ,
{
method : "PUT" ,
resource : resource ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
mc . m . user . account _data . del = function ( user _id , type , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
let resource ;
resource = "user/" + mc . uri ( user _id ) ;
resource += "/account_data/" + mc . uri ( type ) ;
Object . update ( opts ,
{
method : "DELETE" ,
resource : resource ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 11.17 Server Administration
*
* /
mc . m . admin = { } ;
mc . m . admin . whois = { } ;
/ * * 1 1 . 1 7 . 1
*
* /
/ * * 1 1 . 1 7 . 1 . 1 G E T w h o i s
*
* /
mc . m . admin . whois . get = function ( user _id , opts = { } )
{
Object . defaults ( opts ,
{
query :
{
access _token : mc . session . access _token ,
} ,
} ) ;
Object . update ( opts ,
{
method : "GET" ,
resource : "admin/whois/" + mc . uri ( user _id ) ,
prefix : "/_matrix/client/" ,
} ) ;
return new mc . io . request ( opts ) ;
} ;
/ * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 11.18 Event Context
*
* /
/ * * 1 1 . 1 8 . 1 G E T c o n t e x t
*
* /
mc . m . rooms . context = { } ;
mc . m . rooms . context . get = function ( room _id , event _id , opts = { } )
{
let resource = "context/" + event _id ;
Object . defaults ( opts ,
{
query :
{
//from: undefined,
//to: undefined,
limit : 0 ,
} ,
} ) ;
let handler = ( error , data ) => callback ( arguments , error , data ) ;
return mc . m . rooms . request ( room _id , resource , opts , handler ) ;
} ;