From afff310e50f2fa8419bb4242470cbde46ab54463 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 13 Aug 2020 15:07:23 +0200 Subject: allow private syndication feeds via a user feedToken --- .../my-account-applications.component.html | 35 +++++++++++++ .../my-account-applications.component.scss | 28 +++++++++++ .../my-account-applications.component.ts | 57 ++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 client/src/app/+my-account/my-account-applications/my-account-applications.component.html create mode 100644 client/src/app/+my-account/my-account-applications/my-account-applications.component.scss create mode 100644 client/src/app/+my-account/my-account-applications/my-account-applications.component.ts (limited to 'client/src/app/+my-account/my-account-applications') diff --git a/client/src/app/+my-account/my-account-applications/my-account-applications.component.html b/client/src/app/+my-account/my-account-applications/my-account-applications.component.html new file mode 100644 index 000000000..62e2cb59b --- /dev/null +++ b/client/src/app/+my-account/my-account-applications/my-account-applications.component.html @@ -0,0 +1,35 @@ +

+ + Applications +

+ +
+
+

SUBSCRIPTION FEED

+
+ Used to retrieve the list of videos of the creators + you subscribed to from outside PeerTube +
+
+ +
+ +
+ + +
+ +
+ + +
+ +
+
+ +
+
+
+ +
+
diff --git a/client/src/app/+my-account/my-account-applications/my-account-applications.component.scss b/client/src/app/+my-account/my-account-applications/my-account-applications.component.scss new file mode 100644 index 000000000..704132c03 --- /dev/null +++ b/client/src/app/+my-account/my-account-applications/my-account-applications.component.scss @@ -0,0 +1,28 @@ +@import '_variables'; +@import '_mixins'; + +label { + font-weight: $font-regular; + font-size: 100%; +} + +.applications-title { + @include settings-big-title; +} + +.form-group { + max-width: 500px; +} + +input[type=submit] { + @include peertube-button; + @include orange-button; + + display: flex; + margin-left: auto; + + & + .form-error { + display: inline; + margin-left: 5px; + } +} diff --git a/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts b/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts new file mode 100644 index 000000000..c3f09dfe3 --- /dev/null +++ b/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts @@ -0,0 +1,57 @@ + +import { Component, OnInit } from '@angular/core' +import { AuthService, Notifier, ConfirmService } from '@app/core' +import { VideoService } from '@app/shared/shared-main' +import { FeedFormat } from '@shared/models' +import { Subject, merge } from 'rxjs' +import { debounceTime } from 'rxjs/operators' + +@Component({ + selector: 'my-account-applications', + templateUrl: './my-account-applications.component.html', + styleUrls: [ './my-account-applications.component.scss' ] +}) +export class MyAccountApplicationsComponent implements OnInit { + feedUrl: string + feedToken: string + + private baseURL = window.location.protocol + '//' + window.location.host + private tokenStream = new Subject() + + constructor ( + private authService: AuthService, + private videoService: VideoService, + private notifier: Notifier, + private confirmService: ConfirmService + ) {} + + ngOnInit () { + this.feedUrl = this.baseURL + + merge( + this.tokenStream, + this.authService.userInformationLoaded + ).pipe(debounceTime(400)) + .subscribe( + _ => { + const user = this.authService.getUser() + this.videoService.getVideoSubscriptionFeedUrls(user.account.id) + .then(feeds => this.feedUrl = this.baseURL + feeds.find(f => f.format === FeedFormat.RSS).url) + .then(_ => this.authService.getScopedTokens().then(tokens => this.feedToken = tokens.feedToken)) + }, + + err => { + this.notifier.error(err.message) + } + ) + } + + async renewToken () { + const res = await this.confirmService.confirm('Renewing the token will disallow previously configured clients from retrieving the feed until they use the new token. Proceed?', 'Renew token') + if (res === false) return + + await this.authService.renewScopedTokens() + this.notifier.success('Token renewed. Update your client configuration accordingly.') + this.tokenStream.next() + } +} -- cgit v1.2.3