aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorAcid Chicken (硫酸鶏) <root@acid-chicken.com>2018-12-18 18:42:39 +0900
committerChocobozzz <me@florianbigard.com>2018-12-18 10:42:39 +0100
commit583cd0d2129dc855e599f981d70e537feade1632 (patch)
tree62f0601cb4d0458581fe26d40f880ed0fe44aee0 /client/src/app/shared
parent1b04f19c48616f8f93e45451bb992711627bbdfc (diff)
downloadPeerTube-583cd0d2129dc855e599f981d70e537feade1632.tar.gz
PeerTube-583cd0d2129dc855e599f981d70e537feade1632.tar.zst
PeerTube-583cd0d2129dc855e599f981d70e537feade1632.zip
Add WebFinger support (#1498)
* Add WebFinger support * Fix TS7006 * Follow lint * Fix TS7006
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/user-subscription/remote-subscribe.component.ts21
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}