aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-user-subscription
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-user-subscription')
-rw-r--r--client/src/app/shared/shared-user-subscription/remote-subscribe.component.html6
-rw-r--r--client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts37
-rw-r--r--client/src/app/shared/shared-user-subscription/subscribe-button.component.html2
3 files changed, 25 insertions, 20 deletions
diff --git a/client/src/app/shared/shared-user-subscription/remote-subscribe.component.html b/client/src/app/shared/shared-user-subscription/remote-subscribe.component.html
index acfec0a8e..a00c3d1c7 100644
--- a/client/src/app/shared/shared-user-subscription/remote-subscribe.component.html
+++ b/client/src/app/shared/shared-user-subscription/remote-subscribe.component.html
@@ -15,8 +15,7 @@
15 <my-help *ngIf="!interact && showHelp"> 15 <my-help *ngIf="!interact && showHelp">
16 <ng-template ptTemplate="customHtml"> 16 <ng-template ptTemplate="customHtml">
17 <ng-container i18n> 17 <ng-container i18n>
18 You can subscribe to the channel via any ActivityPub-capable fediverse instance.<br /><br /> 18 You can subscribe to the channel via any ActivityPub-capable fediverse instance (PeerTube, Mastodon or Pleroma for example).
19 For instance with Mastodon or Pleroma you can type the channel URL in the search box and subscribe there.
20 </ng-container> 19 </ng-container>
21 </ng-template> 20 </ng-template>
22 </my-help> 21 </my-help>
@@ -24,8 +23,7 @@
24 <my-help *ngIf="showHelp && interact"> 23 <my-help *ngIf="showHelp && interact">
25 <ng-template ptTemplate="customHtml"> 24 <ng-template ptTemplate="customHtml">
26 <ng-container i18n> 25 <ng-container i18n>
27 You can interact with this via any ActivityPub-capable fediverse instance.<br /><br /> 26 You can interact with this via any ActivityPub-capable fediverse instance (PeerTube, Mastodon or Pleroma for example).
28 For instance with Mastodon or Pleroma you can type the current URL in the search box and interact with it there.
29 </ng-container> 27 </ng-container>
30 </ng-template> 28 </ng-template>
31 </my-help> 29 </my-help>
diff --git a/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts b/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts
index b46c91bf8..666199523 100644
--- a/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts
+++ b/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts
@@ -1,6 +1,7 @@
1import { Component, Input, OnInit } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2import { Notifier } from '@app/core'
2import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' 3import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
3import { USER_EMAIL_VALIDATOR } from '../form-validators/user-validators' 4import { USER_HANDLE_VALIDATOR } from '../form-validators/user-validators'
4 5
5@Component({ 6@Component({
6 selector: 'my-remote-subscribe', 7 selector: 'my-remote-subscribe',
@@ -13,14 +14,15 @@ export class RemoteSubscribeComponent extends FormReactive implements OnInit {
13 @Input() showHelp = false 14 @Input() showHelp = false
14 15
15 constructor ( 16 constructor (
16 protected formValidatorService: FormValidatorService 17 protected formValidatorService: FormValidatorService,
18 private notifier: Notifier
17 ) { 19 ) {
18 super() 20 super()
19 } 21 }
20 22
21 ngOnInit () { 23 ngOnInit () {
22 this.buildForm({ 24 this.buildForm({
23 text: USER_EMAIL_VALIDATOR 25 text: USER_HANDLE_VALIDATOR
24 }) 26 })
25 } 27 }
26 28
@@ -35,22 +37,27 @@ export class RemoteSubscribeComponent extends FormReactive implements OnInit {
35 const address = this.form.value['text'] 37 const address = this.form.value['text']
36 const [ username, hostname ] = address.split('@') 38 const [ username, hostname ] = address.split('@')
37 39
40 const protocol = window.location.protocol
41
38 // Should not have CORS error because https://tools.ietf.org/html/rfc7033#section-5 42 // Should not have CORS error because https://tools.ietf.org/html/rfc7033#section-5
39 fetch(`https://${hostname}/.well-known/webfinger?resource=acct:${username}@${hostname}`) 43 fetch(`${protocol}//${hostname}/.well-known/webfinger?resource=acct:${username}@${hostname}`)
40 .then(response => response.json()) 44 .then(response => response.json())
41 .then(data => new Promise((resolve, reject) => { 45 .then(data => new Promise((res, rej) => {
42 if (data && Array.isArray(data.links)) { 46 if (!data || Array.isArray(data.links) === false) return rej()
43 const link: { template: string } = data.links.find((link: any) => { 47
44 return link && typeof link.template === 'string' && link.rel === 'http://ostatus.org/schema/1.0/subscribe' 48 const link: { template: string } = data.links.find((link: any) => {
45 }) 49 return link && typeof link.template === 'string' && link.rel === 'http://ostatus.org/schema/1.0/subscribe'
46 50 })
47 if (link && link.template.includes('{uri}')) { 51
48 resolve(link.template.replace('{uri}', encodeURIComponent(this.uri))) 52 if (link && link.template.includes('{uri}')) {
49 } 53 res(link.template.replace('{uri}', encodeURIComponent(this.uri)))
50 } 54 }
51 reject()
52 })) 55 }))
53 .then(window.open) 56 .then(window.open)
54 .catch(err => console.error(err)) 57 .catch(err => {
58 console.error(err)
59
60 this.notifier.error($localize`Cannot fetch information of this remote account`)
61 })
55 } 62 }
56} 63}
diff --git a/client/src/app/shared/shared-user-subscription/subscribe-button.component.html b/client/src/app/shared/shared-user-subscription/subscribe-button.component.html
index 607a7e113..75cfc918b 100644
--- a/client/src/app/shared/shared-user-subscription/subscribe-button.component.html
+++ b/client/src/app/shared/shared-user-subscription/subscribe-button.component.html
@@ -59,7 +59,7 @@
59 </button> 59 </button>
60 60
61 <button class="dropdown-item dropdown-item-neutral"> 61 <button class="dropdown-item dropdown-item-neutral">
62 <div class="mb-1" i18n>Subscribe with a Mastodon account:</div> 62 <div class="mb-1" i18n>Subscribe with a remote account:</div>
63 <my-remote-subscribe [showHelp]="true" [uri]="uri"></my-remote-subscribe> 63 <my-remote-subscribe [showHelp]="true" [uri]="uri"></my-remote-subscribe>
64 </button> 64 </button>
65 65