Fix current video time saving for anonymous users
This commit is contained in:
parent
43ae5745c3
commit
626b76dcf5
|
@ -207,26 +207,20 @@ class PeerTubePlugin extends Plugin {
|
||||||
.catch(err => logger.error('Cannot notify user is watching.', err))
|
.catch(err => logger.error('Cannot notify user is watching.', err))
|
||||||
|
|
||||||
lastViewEvent = undefined
|
lastViewEvent = undefined
|
||||||
|
|
||||||
// Server won't save history, so save the video position in local storage
|
|
||||||
if (!this.authorizationHeader()) {
|
|
||||||
saveVideoWatchHistory(this.videoUUID, currentTime)
|
|
||||||
}
|
|
||||||
}, this.videoViewIntervalMs)
|
}, this.videoViewIntervalMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
private notifyUserIsWatching (currentTime: number, viewEvent: VideoViewEvent) {
|
private notifyUserIsWatching (currentTime: number, viewEvent: VideoViewEvent) {
|
||||||
if (!this.videoViewUrl) return Promise.resolve(undefined)
|
// Server won't save history, so save the video position in local storage
|
||||||
|
if (!this.authorizationHeader()) {
|
||||||
const body: VideoView = {
|
saveVideoWatchHistory(this.videoUUID, currentTime)
|
||||||
currentTime,
|
|
||||||
viewEvent
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const headers = new Headers({
|
if (!this.videoViewUrl) return
|
||||||
'Content-type': 'application/json; charset=UTF-8'
|
|
||||||
})
|
|
||||||
|
|
||||||
|
const body: VideoView = { currentTime, viewEvent }
|
||||||
|
|
||||||
|
const headers = new Headers({ 'Content-type': 'application/json; charset=UTF-8' })
|
||||||
if (this.authorizationHeader()) headers.set('Authorization', this.authorizationHeader())
|
if (this.authorizationHeader()) headers.set('Authorization', this.authorizationHeader())
|
||||||
|
|
||||||
return fetch(this.videoViewUrl, { method: 'POST', body: JSON.stringify(body), headers })
|
return fetch(this.videoViewUrl, { method: 'POST', body: JSON.stringify(body), headers })
|
||||||
|
|
Loading…
Reference in New Issue
Block a user