aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-21 09:24:22 +0200
committerChocobozzz <me@florianbigard.com>2021-10-21 09:24:22 +0200
commit5196817c5d7cf86b35f3fa2cfe108ba283944482 (patch)
treee8d669b5c0e740ab7578b74984359177eb7b47de
parent97b6428af78d7b00d9b57e1a317d1355f5e76939 (diff)
downloadPeerTube-5196817c5d7cf86b35f3fa2cfe108ba283944482.tar.gz
PeerTube-5196817c5d7cf86b35f3fa2cfe108ba283944482.tar.zst
PeerTube-5196817c5d7cf86b35f3fa2cfe108ba283944482.zip
Fix privacy concern for remote videos
-rw-r--r--client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.html2
-rw-r--r--client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts36
-rw-r--r--client/src/app/+videos/+video-watch/video-watch.component.html2
-rw-r--r--client/src/assets/player/peertube-player-manager.ts3
-rw-r--r--client/src/standalone/videos/embed.ts2
5 files changed, 24 insertions, 21 deletions
diff --git a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.html b/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.html
index efad5a2b8..d579aaddb 100644
--- a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.html
+++ b/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.html
@@ -1,4 +1,4 @@
1<div class="privacy-concerns" *ngIf="hasAlreadyAcceptedPrivacyConcern === false"> 1<div class="privacy-concerns" *ngIf="display">
2 <div class="privacy-concerns-text"> 2 <div class="privacy-concerns-text">
3 <span class="mr-2"> 3 <span class="mr-2">
4 <strong i18n>Friendly Reminder: </strong> 4 <strong i18n>Friendly Reminder: </strong>
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 b1e8bf989..bbc81d46d 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,7 +1,7 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2import { ServerService } from '@app/core' 2import { ServerService } from '@app/core'
3import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' 3import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
4import { HTMLServerConfig } from '@shared/models' 4import { HTMLServerConfig, Video } from '@shared/models'
5import { getStoredP2PEnabled } from '../../../../../assets/player/peertube-player-local-storage' 5import { getStoredP2PEnabled } from '../../../../../assets/player/peertube-player-local-storage'
6import { isWebRTCDisabled } from '../../../../../assets/player/utils' 6import { isWebRTCDisabled } from '../../../../../assets/player/utils'
7 7
@@ -13,7 +13,9 @@ import { isWebRTCDisabled } from '../../../../../assets/player/utils'
13export class PrivacyConcernsComponent implements OnInit { 13export class PrivacyConcernsComponent implements OnInit {
14 private static LOCAL_STORAGE_PRIVACY_CONCERN_KEY = 'video-watch-privacy-concern' 14 private static LOCAL_STORAGE_PRIVACY_CONCERN_KEY = 'video-watch-privacy-concern'
15 15
16 hasAlreadyAcceptedPrivacyConcern = false 16 @Input() video: Video
17
18 display = true
17 19
18 private serverConfig: HTMLServerConfig 20 private serverConfig: HTMLServerConfig
19 21
@@ -24,23 +26,25 @@ export class PrivacyConcernsComponent implements OnInit {
24 ngOnInit () { 26 ngOnInit () {
25 this.serverConfig = this.serverService.getHTMLConfig() 27 this.serverConfig = this.serverService.getHTMLConfig()
26 28
27 if ( 29 if (isWebRTCDisabled() || this.isTrackerDisabled() || this.isP2PDisabled() || this.alreadyAccepted()) {
28 isWebRTCDisabled() || 30 this.display = false
29 this.serverConfig.tracker.enabled === false ||
30 getStoredP2PEnabled() === false ||
31 peertubeLocalStorage.getItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'
32 ) {
33 this.hasAlreadyAcceptedPrivacyConcern = true
34 } 31 }
35 } 32 }
36 33
37 declinedPrivacyConcern () {
38 peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'false')
39 this.hasAlreadyAcceptedPrivacyConcern = false
40 }
41
42 acceptedPrivacyConcern () { 34 acceptedPrivacyConcern () {
43 peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true') 35 peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true')
44 this.hasAlreadyAcceptedPrivacyConcern = true 36 this.display = false
37 }
38
39 private isTrackerDisabled () {
40 return this.video.isLocal && this.serverConfig.tracker.enabled === false
41 }
42
43 private isP2PDisabled () {
44 return getStoredP2PEnabled() === false
45 }
46
47 private alreadyAccepted () {
48 return peertubeLocalStorage.getItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'
45 } 49 }
46} 50}
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.html b/client/src/app/+videos/+video-watch/video-watch.component.html
index df74a818b..830215225 100644
--- a/client/src/app/+videos/+video-watch/video-watch.component.html
+++ b/client/src/app/+videos/+video-watch/video-watch.component.html
@@ -106,7 +106,7 @@
106 ></my-recommended-videos> 106 ></my-recommended-videos>
107 </div> 107 </div>
108 108
109 <my-privacy-concerns></my-privacy-concerns> 109 <my-privacy-concerns *ngIf="video" [video]="video"></my-privacy-concerns>
110</div> 110</div>
111 111
112<my-player-styles></my-player-styles> 112<my-player-styles></my-player-styles>
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index 73b5bc01c..b63d693d4 100644
--- a/client/src/assets/player/peertube-player-manager.ts
+++ b/client/src/assets/player/peertube-player-manager.ts
@@ -361,8 +361,7 @@ export class PeertubePlayerManager {
361 } 361 }
362 362
363 let consumeOnly = false 363 let consumeOnly = false
364 // FIXME: typings 364 if ((navigator as any)?.connection?.type === 'cellular') {
365 if (navigator && (navigator as any).connection && (navigator as any).connection.type === 'cellular') {
366 console.log('We are on a cellular connection: disabling seeding.') 365 console.log('We are on a cellular connection: disabling seeding.')
367 consumeOnly = true 366 consumeOnly = true
368 } 367 }
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index a6f0b2ed9..9d1c6c443 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -669,7 +669,7 @@ export class PeerTubeEmbed {
669 669
670 const title = this.title ? videoInfo.name : undefined 670 const title = this.title ? videoInfo.name : undefined
671 671
672 const description = this.config.tracker.enabled && this.warningTitle 672 const description = this.warningTitle && (!videoInfo.isLocal || this.config.tracker.enabled)
673 ? '<span class="text">' + peertubeTranslate('Watching this video may reveal your IP address to others.') + '</span>' 673 ? '<span class="text">' + peertubeTranslate('Watching this video may reveal your IP address to others.') + '</span>'
674 : undefined 674 : undefined
675 675