From 3ddb1ec5553167b0b1cb852e906a691ea65522a4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 7 Jun 2019 10:56:59 +0200 Subject: Try to fix remote mastodon interactions --- .../user-subscription/remote-subscribe.component.ts | 15 ++++++++------- .../user-subscription/subscribe-button.component.html | 4 ++-- .../user-subscription/subscribe-button.component.ts | 14 +++++++------- 3 files changed, 17 insertions(+), 16 deletions(-) (limited to 'client/src/app/shared') 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 { styleUrls: ['./remote-subscribe.component.scss'] }) export class RemoteSubscribeComponent extends FormReactive implements OnInit { - @Input() account: string + @Input() uri: string @Input() interact = false @Input() showHelp = false @@ -42,19 +42,20 @@ export class RemoteSubscribeComponent extends FormReactive implements OnInit { fetch(`https://${hostname}/.well-known/webfinger?resource=acct:${username}@${hostname}`) .then(response => response.json()) .then(data => new Promise((resolve, reject) => { + console.log(data) + if (data && Array.isArray(data.links)) { - const link: { - template: string - } = data.links.find((link: any) => - link && typeof link.template === 'string' && link.rel === 'http://ostatus.org/schema/1.0/subscribe') + const link: { template: string } = data.links.find((link: any) => { + return link && typeof link.template === 'string' && link.rel === 'http://ostatus.org/schema/1.0/subscribe' + }) if (link && link.template.includes('{uri}')) { - resolve(link.template.replace('{uri}', `acct:${this.account}`)) + resolve(link.template.replace('{uri}', encodeURIComponent(this.uri))) } } reject() })) .then(window.open) - .catch(() => window.open(`https://${hostname}/authorize_interaction?acct=${this.account}`)) + .catch(err => console.error(err)) } } diff --git a/client/src/app/shared/user-subscription/subscribe-button.component.html b/client/src/app/shared/user-subscription/subscribe-button.component.html index dbf6a34f0..d32647b42 100644 --- a/client/src/app/shared/user-subscription/subscribe-button.component.html +++ b/client/src/app/shared/user-subscription/subscribe-button.component.html @@ -41,7 +41,7 @@ - + @@ -50,4 +50,4 @@ - \ No newline at end of file + diff --git a/client/src/app/shared/user-subscription/subscribe-button.component.ts b/client/src/app/shared/user-subscription/subscribe-button.component.ts index ef470ee44..25515f6ea 100644 --- a/client/src/app/shared/user-subscription/subscribe-button.component.ts +++ b/client/src/app/shared/user-subscription/subscribe-button.component.ts @@ -28,19 +28,19 @@ export class SubscribeButtonComponent implements OnInit { private videoService: VideoService ) { } - get uri () { + get channelHandle () { return this.videoChannel.name + '@' + this.videoChannel.host } - get uriAccount () { - return this.videoChannel.ownerAccount.name + '@' + this.videoChannel.host + get channelUri () { + return this.videoChannel.url } ngOnInit () { if (this.isUserLoggedIn()) { - this.userSubscriptionService.doesSubscriptionExist(this.uri) + this.userSubscriptionService.doesSubscriptionExist(this.channelHandle) .subscribe( - res => this.subscribed = res[this.uri], + res => this.subscribed = res[this.channelHandle], err => this.notifier.error(err.message) ) @@ -56,7 +56,7 @@ export class SubscribeButtonComponent implements OnInit { } localSubscribe () { - this.userSubscriptionService.addSubscription(this.uri) + this.userSubscriptionService.addSubscription(this.channelHandle) .subscribe( () => { this.subscribed = true @@ -78,7 +78,7 @@ export class SubscribeButtonComponent implements OnInit { } localUnsubscribe () { - this.userSubscriptionService.deleteSubscription(this.uri) + this.userSubscriptionService.deleteSubscription(this.channelHandle) .subscribe( () => { this.subscribed = false -- cgit v1.2.3