From e4a0aa615d971e0870119ea001a6c9ccdca13b0e Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 4 Mar 2021 15:47:04 +0000 Subject: [PATCH 1/2] Use APPSERVICE_REGISTER_TYPE when registering --- src/components/intent.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/intent.ts b/src/components/intent.ts index 09e230b3..ad7ec07b 100644 --- a/src/components/intent.ts +++ b/src/components/intent.ts @@ -79,6 +79,7 @@ const returnFirstNumber = (...args: unknown[]) => { const DEFAULT_CACHE_TTL = 90000; const DEFAULT_CACHE_SIZE = 1024; +export const APPSERVICE_REGISTER_TYPE = "m.login.application_service"; export type PowerLevelContent = { // eslint-disable-next-line camelcase @@ -1046,9 +1047,12 @@ export class Intent { } let registerRes; if (forceRegister || !this.opts.registered) { - const localpart = (new MatrixUser(userId)).localpart; + const username = (new MatrixUser(userId)).localpart; try { - registerRes = await this.botClient.register(localpart); + registerRes = await this.botClient.registerRequest({ + type: "APPSERVICE_REGISTER_TYPE", + username, + }); this.opts.registered = true; } catch (err) { From 7714f3a4ff70c0ab1cd0153a5c8dbebb206a53c7 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 4 Mar 2021 16:04:14 +0000 Subject: [PATCH 2/2] changelog --- changelog.d/315.bugfix | 1 + src/components/intent.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/315.bugfix diff --git a/changelog.d/315.bugfix b/changelog.d/315.bugfix new file mode 100644 index 00000000..8f6ff16a --- /dev/null +++ b/changelog.d/315.bugfix @@ -0,0 +1 @@ +Use `type=m.login.application` when registering appservice users, to comply with the spec. \ No newline at end of file diff --git a/src/components/intent.ts b/src/components/intent.ts index ad7ec07b..07ac3a52 100644 --- a/src/components/intent.ts +++ b/src/components/intent.ts @@ -1050,7 +1050,7 @@ export class Intent { const username = (new MatrixUser(userId)).localpart; try { registerRes = await this.botClient.registerRequest({ - type: "APPSERVICE_REGISTER_TYPE", + type: APPSERVICE_REGISTER_TYPE, username, }); this.opts.registered = true;