diff --git a/html/account-linking-discord.html b/html/account-linking-discord.html
new file mode 100644
index 0000000..4d25dd6
--- /dev/null
+++ b/html/account-linking-discord.html
@@ -0,0 +1,16 @@
+{{ if .discordEnabled }}
+
+
+
{{ .strings.linkDiscord }}
+
{{ .discordSendPINMessage }}
+
+
+
{{ .strings.success }}
+
+
+{{ end }}
diff --git a/html/account-linking-matrix.html b/html/account-linking-matrix.html
new file mode 100644
index 0000000..02865ff
--- /dev/null
+++ b/html/account-linking-matrix.html
@@ -0,0 +1,18 @@
+{{ if .matrixEnabled }}
+
+
+
{{ .strings.linkMatrix }}
+
{{ .strings.matrixEnterUser }}
+
+
+
+
+
+
+
+ {{ .matrixUser }}
+
+
{{ .strings.submit }}
+
+
+{{ end }}
diff --git a/html/account-linking-telegram.html b/html/account-linking-telegram.html
new file mode 100644
index 0000000..7c8fae7
--- /dev/null
+++ b/html/account-linking-telegram.html
@@ -0,0 +1,18 @@
+{{ if .telegramEnabled }}
+
+{{ end }}
diff --git a/html/account-linking.html b/html/account-linking.html
index e38f013..2ff6525 100644
--- a/html/account-linking.html
+++ b/html/account-linking.html
@@ -1,52 +1,3 @@
-{{ if .discordEnabled }}
-
-
-
{{ .strings.linkDiscord }}
-
{{ .discordSendPINMessage }}
-
-
-
{{ .strings.success }}
-
-
-{{ end }}
-{{ if .telegramEnabled }}
-
-{{ end }}
-{{ if .matrixEnabled }}
-
-
-
{{ .strings.linkMatrix }}
-
{{ .strings.matrixEnterUser }}
-
-
-
-
-
-
-
- {{ .matrixUser }}
-
-
{{ .strings.submit }}
-
-
-{{ end }}
+{{ template "account-linking-discord.html" . }}
+{{ template "account-linking-telegram.html" . }}
+{{ template "account-linking-matrix.html" . }}
diff --git a/html/admin.html b/html/admin.html
index 580963b..2be07c1 100644
--- a/html/admin.html
+++ b/html/admin.html
@@ -491,24 +491,7 @@
{{ .strings.update }}
- {{ if .telegramEnabled }}
-
-
-
{{ .strings.linkTelegram }}
-
{{ .strings.sendPIN }}
-
-
-
-
-
-
-
- @
-
-
{{ .strings.success }}
-
-
- {{ end }}
+ {{ template "account-linking-telegram.html" . }}
{{ if .discordEnabled }}
diff --git a/ts/modules/accounts.ts b/ts/modules/accounts.ts
index 8e9523d..a677c3a 100644
--- a/ts/modules/accounts.ts
+++ b/ts/modules/accounts.ts
@@ -750,9 +750,10 @@ class user implements User, SearchableItem {
private _addTelegram = () => _get("/telegram/pin", null, (req: XMLHttpRequest) => {
if (req.readyState == 4 && req.status == 200) {
- const pin = document.getElementById("telegram-pin");
- const link = document.getElementById("telegram-link") as HTMLAnchorElement;
- const username = document.getElementById("telegram-username") as HTMLSpanElement;
+ const modal = window.modals.telegram.modal;
+ const pin = modal.getElementsByClassName("pin")[0] as HTMLElement;
+ const link = modal.getElementsByClassName("link")[0] as HTMLAnchorElement;
+ const username = modal.getElementsByClassName("username")[0] as HTMLElement;
const waiting = document.getElementById("telegram-waiting") as HTMLSpanElement;
let resp = req.response as getPinResponse;
pin.textContent = resp.token;