Skip to content

Commit 6046d31

Browse files
authored
Merge pull request #315 from matrix-org/hs/use_m.login.application_service
Use m.login.application_service when registering
2 parents 670f8d6 + 7714f3a commit 6046d31

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

changelog.d/315.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use `type=m.login.application` when registering appservice users, to comply with the spec.

src/components/intent.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const returnFirstNumber = (...args: unknown[]) => {
7979

8080
const DEFAULT_CACHE_TTL = 90000;
8181
const DEFAULT_CACHE_SIZE = 1024;
82+
export const APPSERVICE_REGISTER_TYPE = "m.login.application_service";
8283

8384
export type PowerLevelContent = {
8485
// eslint-disable-next-line camelcase
@@ -1046,9 +1047,12 @@ export class Intent {
10461047
}
10471048
let registerRes;
10481049
if (forceRegister || !this.opts.registered) {
1049-
const localpart = (new MatrixUser(userId)).localpart;
1050+
const username = (new MatrixUser(userId)).localpart;
10501051
try {
1051-
registerRes = await this.botClient.register(localpart);
1052+
registerRes = await this.botClient.registerRequest({
1053+
type: APPSERVICE_REGISTER_TYPE,
1054+
username,
1055+
});
10521056
this.opts.registered = true;
10531057
}
10541058
catch (err) {

0 commit comments

Comments
 (0)