diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-15 15:58:10 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-16 10:08:55 +0100 |
commit | a9bfa85d2cdf13670aaced740da5b493fbeddfce (patch) | |
tree | 3781c9218d4cc7786b6589365c0efbed2151703d /client/src/app/+videos/+video-watch/shared/information | |
parent | c77fdc605b3ccc1ab6890f889d8200fbe9372949 (diff) | |
download | PeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.tar.gz PeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.tar.zst PeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.zip |
Add ability for admins to set default p2p policy
Diffstat (limited to 'client/src/app/+videos/+video-watch/shared/information')
-rw-r--r-- | client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts b/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts index bbc81d46d..24030df3e 100644 --- a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts +++ b/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts | |||
@@ -1,9 +1,8 @@ | |||
1 | import { Component, Input, OnInit } from '@angular/core' | 1 | import { Component, Input, OnInit } from '@angular/core' |
2 | import { ServerService } from '@app/core' | 2 | import { ServerService, User, UserService } from '@app/core' |
3 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' | 3 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' |
4 | import { HTMLServerConfig, Video } from '@shared/models' | 4 | import { HTMLServerConfig, Video } from '@shared/models' |
5 | import { getStoredP2PEnabled } from '../../../../../assets/player/peertube-player-local-storage' | 5 | import { isP2PEnabled } from '../../../../../assets/player/utils' |
6 | import { isWebRTCDisabled } from '../../../../../assets/player/utils' | ||
7 | 6 | ||
8 | @Component({ | 7 | @Component({ |
9 | selector: 'my-privacy-concerns', | 8 | selector: 'my-privacy-concerns', |
@@ -15,33 +14,32 @@ export class PrivacyConcernsComponent implements OnInit { | |||
15 | 14 | ||
16 | @Input() video: Video | 15 | @Input() video: Video |
17 | 16 | ||
18 | display = true | 17 | display = false |
19 | 18 | ||
20 | private serverConfig: HTMLServerConfig | 19 | private serverConfig: HTMLServerConfig |
21 | 20 | ||
22 | constructor ( | 21 | constructor ( |
23 | private serverService: ServerService | 22 | private serverService: ServerService, |
23 | private userService: UserService | ||
24 | ) { } | 24 | ) { } |
25 | 25 | ||
26 | ngOnInit () { | 26 | ngOnInit () { |
27 | this.serverConfig = this.serverService.getHTMLConfig() | 27 | this.serverConfig = this.serverService.getHTMLConfig() |
28 | 28 | ||
29 | if (isWebRTCDisabled() || this.isTrackerDisabled() || this.isP2PDisabled() || this.alreadyAccepted()) { | 29 | this.userService.getAnonymousOrLoggedUser() |
30 | this.display = false | 30 | .subscribe(user => this.updateDisplay(user)) |
31 | } | ||
32 | } | 31 | } |
33 | 32 | ||
34 | acceptedPrivacyConcern () { | 33 | acceptedPrivacyConcern () { |
35 | peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true') | 34 | peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true') |
36 | this.display = false | ||
37 | } | ||
38 | 35 | ||
39 | private isTrackerDisabled () { | 36 | this.display = false |
40 | return this.video.isLocal && this.serverConfig.tracker.enabled === false | ||
41 | } | 37 | } |
42 | 38 | ||
43 | private isP2PDisabled () { | 39 | private updateDisplay (user: User) { |
44 | return getStoredP2PEnabled() === false | 40 | if (isP2PEnabled(this.video, this.serverConfig, user.p2pEnabled) && !this.alreadyAccepted()) { |
41 | this.display = true | ||
42 | } | ||
45 | } | 43 | } |
46 | 44 | ||
47 | private alreadyAccepted () { | 45 | private alreadyAccepted () { |