Fix privacy concern for remote videos

pull/4477/head
Chocobozzz 2021-10-21 09:24:22 +02:00
parent 97b6428af7
commit 5196817c5d
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 24 additions and 21 deletions

View File

@ -1,4 +1,4 @@
<div class="privacy-concerns" *ngIf="hasAlreadyAcceptedPrivacyConcern === false"> <div class="privacy-concerns" *ngIf="display">
<div class="privacy-concerns-text"> <div class="privacy-concerns-text">
<span class="mr-2"> <span class="mr-2">
<strong i18n>Friendly Reminder: </strong> <strong i18n>Friendly Reminder: </strong>

View File

@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core' import { Component, Input, OnInit } from '@angular/core'
import { ServerService } from '@app/core' import { ServerService } from '@app/core'
import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' 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 { getStoredP2PEnabled } from '../../../../../assets/player/peertube-player-local-storage'
import { isWebRTCDisabled } from '../../../../../assets/player/utils' import { isWebRTCDisabled } from '../../../../../assets/player/utils'
@ -13,7 +13,9 @@ import { isWebRTCDisabled } from '../../../../../assets/player/utils'
export class PrivacyConcernsComponent implements OnInit { export class PrivacyConcernsComponent implements OnInit {
private static LOCAL_STORAGE_PRIVACY_CONCERN_KEY = 'video-watch-privacy-concern' private static LOCAL_STORAGE_PRIVACY_CONCERN_KEY = 'video-watch-privacy-concern'
hasAlreadyAcceptedPrivacyConcern = false @Input() video: Video
display = true
private serverConfig: HTMLServerConfig private serverConfig: HTMLServerConfig
@ -24,23 +26,25 @@ export class PrivacyConcernsComponent implements OnInit {
ngOnInit () { ngOnInit () {
this.serverConfig = this.serverService.getHTMLConfig() this.serverConfig = this.serverService.getHTMLConfig()
if ( if (isWebRTCDisabled() || this.isTrackerDisabled() || this.isP2PDisabled() || this.alreadyAccepted()) {
isWebRTCDisabled() || this.display = false
this.serverConfig.tracker.enabled === false ||
getStoredP2PEnabled() === false ||
peertubeLocalStorage.getItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'
) {
this.hasAlreadyAcceptedPrivacyConcern = true
} }
} }
declinedPrivacyConcern () {
peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'false')
this.hasAlreadyAcceptedPrivacyConcern = false
}
acceptedPrivacyConcern () { acceptedPrivacyConcern () {
peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true') 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'
} }
} }

View File

@ -106,7 +106,7 @@
></my-recommended-videos> ></my-recommended-videos>
</div> </div>
<my-privacy-concerns></my-privacy-concerns> <my-privacy-concerns *ngIf="video" [video]="video"></my-privacy-concerns>
</div> </div>
<my-player-styles></my-player-styles> <my-player-styles></my-player-styles>

View File

@ -361,8 +361,7 @@ export class PeertubePlayerManager {
} }
let consumeOnly = false let consumeOnly = false
// FIXME: typings if ((navigator as any)?.connection?.type === 'cellular') {
if (navigator && (navigator as any).connection && (navigator as any).connection.type === 'cellular') {
console.log('We are on a cellular connection: disabling seeding.') console.log('We are on a cellular connection: disabling seeding.')
consumeOnly = true consumeOnly = true
} }

View File

@ -669,7 +669,7 @@ export class PeerTubeEmbed {
const title = this.title ? videoInfo.name : undefined 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>' ? '<span class="text">' + peertubeTranslate('Watching this video may reveal your IP address to others.') + '</span>'
: undefined : undefined