add push events support

This commit is contained in:
ghost 2023-09-15 01:43:20 +03:00
parent 7c054557f3
commit 64693f7774
5 changed files with 151 additions and 24 deletions

View file

@ -62,8 +62,31 @@ else if (is_null($user->public))
// Request valid
else
{
// Update download stats
$db->addMagnetDownload($magnet->magnetId, $userId, time());
// Register magnet download
$magnetDownloadId = $db->addMagnetDownload($magnet->magnetId, $user->userId, time());
// Push event to other nodes
if (API_EXPORT_ENABLED &&
API_EXPORT_PUSH_ENABLED &&
API_EXPORT_USERS_ENABLED &&
API_EXPORT_MAGNETS_ENABLED &&
API_EXPORT_MAGNET_DOWNLOADS_ENABLED)
{
if (!$memoryApiExportPush = $memory->get('api.export.push'))
{
$memoryApiExportPush = [];
}
$memoryApiExportPush[] = (object)
[
'time' => time(),
'userId' => $user->userId,
'magnetId' => $magnet->magnetId,
'magnetDownloadId' => $magnetDownloadId
];
$memory->set('api.export.push', $memoryApiExportPush, 3600);
}
// Build magnet link
$link = (object)