From dae5ca24b173aebd16de2a202ccd4088568b8dfb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Dec 2018 15:27:46 +0100 Subject: Redirect to the last url on login --- .../src/app/shared/user-subscription/subscribe-button.component.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'client/src/app/shared/user-subscription') 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 315ea5037..9c8a15023 100644 --- a/client/src/app/shared/user-subscription/subscribe-button.component.ts +++ b/client/src/app/shared/user-subscription/subscribe-button.component.ts @@ -50,11 +50,10 @@ export class SubscribeButtonComponent implements OnInit { subscribe () { if (this.isUserLoggedIn()) { - this.localSubscribe() - } else { - this.authService.redirectUrl = this.router.url - this.gotoLogin() + return this.localSubscribe() } + + return this.gotoLogin() } localSubscribe () { -- cgit v1.2.3 From 583cd0d2129dc855e599f981d70e537feade1632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Tue, 18 Dec 2018 18:42:39 +0900 Subject: Add WebFinger support (#1498) * Add WebFinger support * Fix TS7006 * Follow lint * Fix TS7006 --- .../user-subscription/remote-subscribe.component.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'client/src/app/shared/user-subscription') 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 { formValidated () { const address = this.form.value['text'] - const [ , hostname ] = address.split('@') - window.open(`https://${hostname}/authorize_interaction?acct=${this.account}`) + const [ username, hostname ] = address.split('@') + + fetch(`https://${hostname}/.well-known/webfinger?resource=acct:${username}@${hostname}`) + .then(response => response.json()) + .then(data => new Promise((resolve, reject) => { + 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') + + if (link && link.template.includes('{uri}')) { + resolve(link.template.replace('{uri}', `acct:${this.account}`)) + } + } + reject() + })) + .then(window.open) + .catch(() => window.open(`https://${hostname}/authorize_interaction?acct=${this.account}`)) } } -- cgit v1.2.3 From f8b2c1b4f509c037b9650cca2c5befd21f056df3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 19 Dec 2018 16:04:34 +0100 Subject: Refractor notification service Shorter name and use primeng component --- .../subscribe-button.component.ts | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'client/src/app/shared/user-subscription') 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 9c8a15023..8f1754c7f 100644 --- a/client/src/app/shared/user-subscription/subscribe-button.component.ts +++ b/client/src/app/shared/user-subscription/subscribe-button.component.ts @@ -1,9 +1,8 @@ import { Component, Input, OnInit } from '@angular/core' import { Router } from '@angular/router' -import { AuthService } from '@app/core' +import { AuthService, Notifier } from '@app/core' import { UserSubscriptionService } from '@app/shared/user-subscription/user-subscription.service' import { VideoChannel } from '@app/shared/video-channel/video-channel.model' -import { NotificationsService } from 'angular2-notifications' import { I18n } from '@ngx-translate/i18n-polyfill' import { VideoService } from '@app/shared/video/video.service' import { FeedFormat } from '../../../../../shared/models/feeds' @@ -23,7 +22,7 @@ export class SubscribeButtonComponent implements OnInit { constructor ( private authService: AuthService, private router: Router, - private notificationsService: NotificationsService, + private notifier: Notifier, private userSubscriptionService: UserSubscriptionService, private i18n: I18n, private videoService: VideoService @@ -43,7 +42,7 @@ export class SubscribeButtonComponent implements OnInit { .subscribe( res => this.subscribed = res[this.uri], - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } } @@ -62,13 +61,13 @@ export class SubscribeButtonComponent implements OnInit { () => { this.subscribed = true - this.notificationsService.success( - this.i18n('Subscribed'), - this.i18n('Subscribed to {{nameWithHost}}', { nameWithHost: this.videoChannel.displayName }) + this.notifier.success( + this.i18n('Subscribed to {{nameWithHost}}', { nameWithHost: this.videoChannel.displayName }), + this.i18n('Subscribed') ) }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -84,13 +83,13 @@ export class SubscribeButtonComponent implements OnInit { () => { this.subscribed = false - this.notificationsService.success( - this.i18n('Unsubscribed'), - this.i18n('Unsubscribed from {{nameWithHost}}', { nameWithHost: this.videoChannel.displayName }) + this.notifier.success( + this.i18n('Unsubscribed from {{nameWithHost}}', { nameWithHost: this.videoChannel.displayName }), + this.i18n('Unsubscribed') ) }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } -- cgit v1.2.3 From 3866f1a02f73665541468fbadcc3cd2cc459aef2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 10 Jan 2019 09:58:08 +0100 Subject: Add contact form checkbox in admin form --- client/src/app/shared/user-subscription/remote-subscribe.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client/src/app/shared/user-subscription') 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 49722ce40..ba2a45df1 100644 --- a/client/src/app/shared/user-subscription/remote-subscribe.component.ts +++ b/client/src/app/shared/user-subscription/remote-subscribe.component.ts @@ -29,7 +29,7 @@ export class RemoteSubscribeComponent extends FormReactive implements OnInit { } onValidKey () { - this.onValueChanged() + this.check() if (!this.form.valid) return this.formValidated() -- cgit v1.2.3