diff options
Diffstat (limited to 'client/src/app/shared/user-subscription')
-rw-r--r-- | client/src/app/shared/user-subscription/remote-subscribe.component.ts | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/client/src/app/shared/user-subscription/remote-subscribe.component.ts b/client/src/app/shared/user-subscription/remote-subscribe.component.ts index 7a81108cd..49722ce40 100644 --- a/client/src/app/shared/user-subscription/remote-subscribe.component.ts +++ b/client/src/app/shared/user-subscription/remote-subscribe.component.ts | |||
@@ -37,7 +37,24 @@ export class RemoteSubscribeComponent extends FormReactive implements OnInit { | |||
37 | 37 | ||
38 | formValidated () { | 38 | formValidated () { |
39 | const address = this.form.value['text'] | 39 | const address = this.form.value['text'] |
40 | const [ , hostname ] = address.split('@') | 40 | const [ username, hostname ] = address.split('@') |
41 | window.open(`https://${hostname}/authorize_interaction?acct=${this.account}`) | 41 | |
42 | fetch(`https://${hostname}/.well-known/webfinger?resource=acct:${username}@${hostname}`) | ||
43 | .then(response => response.json()) | ||
44 | .then(data => new Promise((resolve, reject) => { | ||
45 | if (data && Array.isArray(data.links)) { | ||
46 | const link: { | ||
47 | template: string | ||
48 | } = data.links.find((link: any) => | ||
49 | link && typeof link.template === 'string' && link.rel === 'http://ostatus.org/schema/1.0/subscribe') | ||
50 | |||
51 | if (link && link.template.includes('{uri}')) { | ||
52 | resolve(link.template.replace('{uri}', `acct:${this.account}`)) | ||
53 | } | ||
54 | } | ||
55 | reject() | ||
56 | })) | ||
57 | .then(window.open) | ||
58 | .catch(() => window.open(`https://${hostname}/authorize_interaction?acct=${this.account}`)) | ||
42 | } | 59 | } |
43 | } | 60 | } |