]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix privacy concern for remote videos
authorChocobozzz <me@florianbigard.com>
Thu, 21 Oct 2021 07:24:22 +0000 (09:24 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 21 Oct 2021 07:24:22 +0000 (09:24 +0200)
client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.html
client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts
client/src/app/+videos/+video-watch/video-watch.component.html
client/src/assets/player/peertube-player-manager.ts
client/src/standalone/videos/embed.ts

index efad5a2b83cb098e833a19909126c7dd3d8d6a1b..d579aaddb74c3209ec5f8d83f307a4df83fa8e2a 100644 (file)
@@ -1,4 +1,4 @@
-<div class="privacy-concerns" *ngIf="hasAlreadyAcceptedPrivacyConcern === false">
+<div class="privacy-concerns" *ngIf="display">
   <div class="privacy-concerns-text">
     <span class="mr-2">
       <strong i18n>Friendly Reminder: </strong>
index b1e8bf989e1c3476af8e9d6867dff2ae331fa5ef..bbc81d46d8f4a3b2890c067c62426c05a423c0b5 100644 (file)
@@ -1,7 +1,7 @@
-import { Component, OnInit } from '@angular/core'
+import { Component, Input, OnInit } from '@angular/core'
 import { ServerService } from '@app/core'
 import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
-import { HTMLServerConfig } from '@shared/models'
+import { HTMLServerConfig, Video } from '@shared/models'
 import { getStoredP2PEnabled } from '../../../../../assets/player/peertube-player-local-storage'
 import { isWebRTCDisabled } from '../../../../../assets/player/utils'
 
@@ -13,7 +13,9 @@ import { isWebRTCDisabled } from '../../../../../assets/player/utils'
 export class PrivacyConcernsComponent implements OnInit {
   private static LOCAL_STORAGE_PRIVACY_CONCERN_KEY = 'video-watch-privacy-concern'
 
-  hasAlreadyAcceptedPrivacyConcern = false
+  @Input() video: Video
+
+  display = true
 
   private serverConfig: HTMLServerConfig
 
@@ -24,23 +26,25 @@ export class PrivacyConcernsComponent implements OnInit {
   ngOnInit () {
     this.serverConfig = this.serverService.getHTMLConfig()
 
-    if (
-      isWebRTCDisabled() ||
-      this.serverConfig.tracker.enabled === false ||
-      getStoredP2PEnabled() === false ||
-      peertubeLocalStorage.getItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'
-    ) {
-      this.hasAlreadyAcceptedPrivacyConcern = true
+    if (isWebRTCDisabled() || this.isTrackerDisabled() || this.isP2PDisabled() || this.alreadyAccepted()) {
+      this.display = false
     }
   }
 
-  declinedPrivacyConcern () {
-    peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'false')
-    this.hasAlreadyAcceptedPrivacyConcern = false
-  }
-
   acceptedPrivacyConcern () {
     peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true')
-    this.hasAlreadyAcceptedPrivacyConcern = true
+    this.display = false
+  }
+
+  private isTrackerDisabled () {
+    return this.video.isLocal && this.serverConfig.tracker.enabled === false
+  }
+
+  private isP2PDisabled () {
+    return getStoredP2PEnabled() === false
+  }
+
+  private alreadyAccepted () {
+    return peertubeLocalStorage.getItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'
   }
 }
index df74a818b662c0874f87d33248cf923d9f4ea594..83021522581c8d764b85a65da2170dd6f743f2ad 100644 (file)
     ></my-recommended-videos>
   </div>
 
-  <my-privacy-concerns></my-privacy-concerns>
+  <my-privacy-concerns *ngIf="video" [video]="video"></my-privacy-concerns>
 </div>
 
 <my-player-styles></my-player-styles>
index 73b5bc01c5eec745a01653daa58480785cfa762d..b63d693d4f111693685a096fe3eafa4e86c442ef 100644 (file)
@@ -361,8 +361,7 @@ export class PeertubePlayerManager {
     }
 
     let consumeOnly = false
-    // FIXME: typings
-    if (navigator && (navigator as any).connection && (navigator as any).connection.type === 'cellular') {
+    if ((navigator as any)?.connection?.type === 'cellular') {
       console.log('We are on a cellular connection: disabling seeding.')
       consumeOnly = true
     }
index a6f0b2ed9eee0798234e6004bef6c153a18243ae..9d1c6c443bad92e490e7c04fcc8eda398aaf838b 100644 (file)
@@ -669,7 +669,7 @@ export class PeerTubeEmbed {
 
     const title = this.title ? videoInfo.name : undefined
 
-    const description = this.config.tracker.enabled && this.warningTitle
+    const description = this.warningTitle && (!videoInfo.isLocal || this.config.tracker.enabled)
       ? '<span class="text">' + peertubeTranslate('Watching this video may reveal your IP address to others.') + '</span>'
       : undefined