mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix: Avoid triggering several activities for Range request on the same file
Avoids flooding activities when someone browse a video in the web player. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
a39bee57d9
commit
a3c531c31e
1 changed files with 10 additions and 2 deletions
|
|
@ -22,7 +22,7 @@ use OCP\Files\Storage\ISharedStorage;
|
|||
use OCP\ICache;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUserSession;
|
||||
use OCP\ISession;
|
||||
use OCP\Share\IShare;
|
||||
|
||||
/**
|
||||
|
|
@ -32,7 +32,7 @@ class BeforeNodeReadListener implements IEventListener {
|
|||
private ICache $cache;
|
||||
|
||||
public function __construct(
|
||||
private IUserSession $userSession,
|
||||
private ISession $session,
|
||||
private IRootFolder $rootFolder,
|
||||
private \OCP\Activity\IManager $activityManager,
|
||||
private IRequest $request,
|
||||
|
|
@ -113,6 +113,14 @@ class BeforeNodeReadListener implements IEventListener {
|
|||
return;
|
||||
}
|
||||
|
||||
/* Avoid publishing several activities for one video playing */
|
||||
$cacheKey = $node->getId() . $node->getPath();
|
||||
if (($this->request->getHeader('range') !== '') && ($this->cache->get($cacheKey) == $this->session->getId())) {
|
||||
/* This is a range request and an activity for the same file was published in the same session */
|
||||
return;
|
||||
}
|
||||
$this->cache->set($cacheKey, $this->session->getId(), 3600);
|
||||
|
||||
$this->singleFileDownloaded($share, $node);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue