Class

Appservice

Appservice(options)

Represents an application service. This provides helper utilities such as tracking of user intents (clients that are aware of their membership in rooms).
Constructor

# new Appservice(options)

Creates a new application service.
Parameters:
Name Type Description
options IAppserviceOptions The options for the application service.

View Source appservice/Appservice.ts, line 23

Classes

Appservice
Appservice

Members

# apis

Appservice specific APIs.

View Source appservice/Appservice.ts, line 46

AppserviceApis

# apis

Appservice specific APIs.

View Source appservice/Appservice.ts, line 1083

# botClient

Get the application service's "bot" MatrixClient (the sender_localpart). Normally the botIntent should be used to ensure that the bot user is safely handled.

View Source appservice/Appservice.ts, line 156

# botIntent

Get the application service's "bot" Intent (the sender_localpart).

View Source appservice/Appservice.ts, line 147

# botUserId

Get the application service's "bot" user ID (the sender_localpart).

View Source appservice/Appservice.ts, line 140

# bridge

Gets the bridge-specific APIs for this application service.

View Source appservice/Appservice.ts, line 134

# cryptoClientForRoomId

A cache of intents for the purposes of decrypting rooms

View Source appservice/Appservice.ts, line 50

# expressAppInstance

Gets the express app instance which is serving requests. Not recommended for general usage, but may be used to append routes to the web server.

View Source appservice/Appservice.ts, line 128

# metrics

The metrics instance for this appservice. This will raise all metrics from this appservice instance as well as any intents/MatrixClients created by the appservice.

View Source appservice/Appservice.ts, line 30

Metrics

# metrics

The metrics instance for this appservice. This will raise all metrics from this appservice instance as well as any intents/MatrixClients created by the appservice.

View Source appservice/Appservice.ts, line 1077

Methods

# addPreprocessor(preprocessor) → {void}

Adds a preprocessor to the event pipeline. When this appservice encounters an event, it will try to run it through the preprocessors it can in the order they were added.
Parameters:
Name Type Description
preprocessor IPreprocessor the preprocessor to add

View Source appservice/Appservice.ts, line 1267

void

# begin() → {Promise.<void>}

Starts the application service, opening the bind address to begin processing requests.

View Source appservice/Appservice.ts, line 1140

resolves when started
Promise.<void>

# botClient() → {MatrixClient}

Get the application service's "bot" MatrixClient (the sender_localpart). Normally the botIntent should be used to ensure that the bot user is safely handled.

View Source appservice/Appservice.ts, line 1133

The client for the application service itself.
MatrixClient

# botIntent() → {Intent}

Get the application service's "bot" Intent (the sender_localpart).

View Source appservice/Appservice.ts, line 1124

The intent for the application service itself.
Intent

# botUserId() → {string}

Get the application service's "bot" user ID (the sender_localpart).

View Source appservice/Appservice.ts, line 1117

string

# bridge() → {MatrixBridge}

Gets the bridge-specific APIs for this application service.

View Source appservice/Appservice.ts, line 1110

MatrixBridge

# expressAppInstance()

Gets the express app instance which is serving requests. Not recommended for general usage, but may be used to append routes to the web server.

View Source appservice/Appservice.ts, line 1103

# getAlias(localpart) → {string}

Gets a full alias for a given localpart. The alias will be formed with the domain name given in the constructor.
Parameters:
Name Type Description
localpart The localpart to get an alias for.

View Source appservice/Appservice.ts, line 1220

The alias.
string

# getAliasForSuffix(suffix) → {string}

Gets a full alias for a given suffix. The prefix is automatically detected from the registration options. Note: If the registration file contains *multiple* prefixes then this will throw.
Parameters:
Name Type Description
suffix The alias's suffix

View Source appservice/Appservice.ts, line 1230

The alias.
string

# getAliasLocalpartForSuffix(suffix) → {string}

Gets the localpart of an alias for a given suffix. The prefix is automatically detected from the registration options. Useful for the createRoom endpoint. Note: If the registration file contains *multiple* prefixes then this will throw.
Parameters:
Name Type Description
suffix The alias's suffix

View Source appservice/Appservice.ts, line 1240

The alias localpart.
string

# getIntent(localpart) → {Intent}

Gets an intent for a given localpart. The user ID will be formed with the domain name given in the constructor.
Parameters:
Name Type Description
localpart The localpart to get an Intent for.

View Source appservice/Appservice.ts, line 1156

An Intent for the user.
Intent

# getIntentForSuffix(suffix) → {Intent}

Gets an Intent for a given user suffix. The prefix is automatically detected from the registration options. Note: If the registration file contains *multiple* prefixes then this will throw.
Parameters:
Name Type Description
suffix The user's suffix

View Source appservice/Appservice.ts, line 1175

An Intent for the user.
Intent

# getIntentForUserId(userId) → {Intent}

Gets an Intent for a given user ID.
Parameters:
Name Type Description
userId string The user ID to get an Intent for.

View Source appservice/Appservice.ts, line 1193

An Intent for the user.
Intent

# getSuffixForAlias(alias) → {string}

Gets the suffix for the provided alias. If the alias is not a namespaced alias, this will return a falsey value. Note: If the registration file contains *multiple* prefixes then this will throw.
Parameters:
Name Type Description
alias string The alias to parse

View Source appservice/Appservice.ts, line 1250

The suffix from the alias.
string

# getSuffixForUserId(userId) → {string}

Gets the suffix for the provided user ID. If the user ID is not a namespaced user, this will return a falsey value. Note: If the registration file contains *multiple* prefixes then this will throw.
Parameters:
Name Type Description
userId string The user ID to parse

View Source appservice/Appservice.ts, line 1203

The suffix from the user ID.
string

# getUserId(localpart) → {string}

Gets a full user ID for a given localpart. The user ID will be formed with the domain name given in the constructor.
Parameters:
Name Type Description
localpart The localpart to get a user ID for.

View Source appservice/Appservice.ts, line 1165

The user's ID.
string

# getUserIdForSuffix(suffix) → {string}

Gets a full user ID for a given suffix. The prefix is automatically detected from the registration options. Note: If the registration file contains *multiple* prefixes then this will throw.
Parameters:
Name Type Description
suffix The user's suffix

View Source appservice/Appservice.ts, line 1185

The user's ID.
string

# isNamespacedAlias(alias) → {boolean}

Determines if a given alias is namespaced by this application service.
Parameters:
Name Type Description
alias string The alias to check

View Source appservice/Appservice.ts, line 1258

true if the alias is namespaced, false otherwise
boolean

# isNamespacedUser(userId) → {boolean}

Determines if a given user ID is namespaced by this application service.
Parameters:
Name Type Description
userId string The user ID to check

View Source appservice/Appservice.ts, line 1211

true if the user is namespaced, false otherwise
boolean

# async pingHomeserver()

Ping the homeserver to check for connectivity and await the response.

View Source appservice/Appservice.ts, line 1285

Resolves if the ping succeded, otherwise rejects.

# setRoomDirectoryVisibility(networkId, roomId, visibility) → {Promise.<any>}

Sets the visibility of a room in the appservice's room directory.
Parameters:
Name Type Description
networkId string The network ID to group the room under.
roomId string The room ID to manipulate the visibility of.
visibility "public" | "private" The visibility to set for the room.

View Source appservice/Appservice.ts, line 1277

resolves when the visibility has been updated.
Promise.<any>

# stop() → {void}

Stops the application service, freeing the web server.

View Source appservice/Appservice.ts, line 1147

void