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 21

Classes

Appservice
Appservice

Members

# 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 151

# botIntent

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

View Source appservice/Appservice.ts, line 142

# botUserId

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

View Source appservice/Appservice.ts, line 135

# bridge

Gets the bridge-specific APIs for this application service.

View Source appservice/Appservice.ts, line 129

# 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 123

# 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 28

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 964

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 1136

void

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

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

View Source appservice/Appservice.ts, line 1015

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 1008

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 999

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 992

string

# bridge() → {MatrixBridge}

Gets the bridge-specific APIs for this application service.

View Source appservice/Appservice.ts, line 985

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 978

# 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 1092

The alias.
string

# getAliasForSuffix(suffix) → {string}

Gets a full alias for a given suffix. The prefix is automatically detected from the registration options.
Parameters:
Name Type Description
suffix The alias's suffix

View Source appservice/Appservice.ts, line 1101

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.
Parameters:
Name Type Description
suffix The alias's suffix

View Source appservice/Appservice.ts, line 1110

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 1031

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.
Parameters:
Name Type Description
suffix The user's suffix

View Source appservice/Appservice.ts, line 1049

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 1066

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.
Parameters:
Name Type Description
alias string The alias to parse

View Source appservice/Appservice.ts, line 1119

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.
Parameters:
Name Type Description
userId string The user ID to parse

View Source appservice/Appservice.ts, line 1075

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 1040

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.
Parameters:
Name Type Description
suffix The user's suffix

View Source appservice/Appservice.ts, line 1058

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 1127

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 1083

true if the user is namespaced, false otherwise
boolean

# 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 1146

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 1022

void