diff options
Diffstat (limited to 'client/src/app/shared/user-subscription/remote-subscribe.component.ts')
-rw-r--r-- | client/src/app/shared/user-subscription/remote-subscribe.component.ts | 15 |
1 files changed, 8 insertions, 7 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 ba2a45df1..63e7cd5d9 100644 --- a/client/src/app/shared/user-subscription/remote-subscribe.component.ts +++ b/client/src/app/shared/user-subscription/remote-subscribe.component.ts | |||
@@ -11,7 +11,7 @@ import { | |||
11 | styleUrls: ['./remote-subscribe.component.scss'] | 11 | styleUrls: ['./remote-subscribe.component.scss'] |
12 | }) | 12 | }) |
13 | export class RemoteSubscribeComponent extends FormReactive implements OnInit { | 13 | export class RemoteSubscribeComponent extends FormReactive implements OnInit { |
14 | @Input() account: string | 14 | @Input() uri: string |
15 | @Input() interact = false | 15 | @Input() interact = false |
16 | @Input() showHelp = false | 16 | @Input() showHelp = false |
17 | 17 | ||
@@ -42,19 +42,20 @@ export class RemoteSubscribeComponent extends FormReactive implements OnInit { | |||
42 | fetch(`https://${hostname}/.well-known/webfinger?resource=acct:${username}@${hostname}`) | 42 | fetch(`https://${hostname}/.well-known/webfinger?resource=acct:${username}@${hostname}`) |
43 | .then(response => response.json()) | 43 | .then(response => response.json()) |
44 | .then(data => new Promise((resolve, reject) => { | 44 | .then(data => new Promise((resolve, reject) => { |
45 | console.log(data) | ||
46 | |||
45 | if (data && Array.isArray(data.links)) { | 47 | if (data && Array.isArray(data.links)) { |
46 | const link: { | 48 | const link: { template: string } = data.links.find((link: any) => { |
47 | template: string | 49 | return link && typeof link.template === 'string' && link.rel === 'http://ostatus.org/schema/1.0/subscribe' |
48 | } = data.links.find((link: any) => | 50 | }) |
49 | link && typeof link.template === 'string' && link.rel === 'http://ostatus.org/schema/1.0/subscribe') | ||
50 | 51 | ||
51 | if (link && link.template.includes('{uri}')) { | 52 | if (link && link.template.includes('{uri}')) { |
52 | resolve(link.template.replace('{uri}', `acct:${this.account}`)) | 53 | resolve(link.template.replace('{uri}', encodeURIComponent(this.uri))) |
53 | } | 54 | } |
54 | } | 55 | } |
55 | reject() | 56 | reject() |
56 | })) | 57 | })) |
57 | .then(window.open) | 58 | .then(window.open) |
58 | .catch(() => window.open(`https://${hostname}/authorize_interaction?acct=${this.account}`)) | 59 | .catch(err => console.error(err)) |
59 | } | 60 | } |
60 | } | 61 | } |