Browse Source

fix protocol compatibility

main
ghost 1 year ago
parent
commit
b74be8a1bf
  1. 29
      src/crontab/export/push.php

29
src/crontab/export/push.php

@ -76,8 +76,10 @@ if (API_EXPORT_PUSH_ENABLED)
// Get magnet info // Get magnet info
if ($magnet = $db->getMagnet($push->magnetId)) if ($magnet = $db->getMagnet($push->magnetId))
{ {
// Dump public data only if ($magnet->public &&
if ($magnet->public === '1') $public['user'][$magnet->userId]) // After upgrade, some users have not updated their public status.
// Remote node have warning on import, because user info still hidden to init new profile there.
// Stop magnets export without public profile available, even magnet is public.
{ {
// Info Hash // Info Hash
$xt = []; $xt = [];
@ -200,7 +202,12 @@ if (API_EXPORT_PUSH_ENABLED)
} }
// Cache public status // Cache public status
$public['magnet'][$magnet->magnetId] = $magnet->public; if (!empty($public['user'][$magnet->userId]))
{
$public['magnet'][$magnet->magnetId] = (bool) $magnet->public;
} else {
$public['magnet'][$magnet->magnetId] = false;
}
} }
} }
@ -211,8 +218,8 @@ if (API_EXPORT_PUSH_ENABLED)
if ($magnetDownload = $db->getMagnetDownload($push->magnetDownloadId)) if ($magnetDownload = $db->getMagnetDownload($push->magnetDownloadId))
{ {
// Dump public data only // Dump public data only
if (isset($public['magnet'][$magnetDownload->magnetId]) && $public['magnet'][$magnetDownload->magnetId] === '1' && if (!empty($public['magnet'][$magnetDownload->magnetId]) &&
isset($public['user'][$magnetDownload->userId] ) && $public['user'][$magnetDownload->userId] === '1') !empty($public['user'][$magnetDownload->userId]))
{ {
$request['magnetDownload'] = (object) $request['magnetDownload'] = (object)
[ [
@ -232,8 +239,8 @@ if (API_EXPORT_PUSH_ENABLED)
if ($magnetComment = $db->getMagnetComment($push->magnetCommentId)) if ($magnetComment = $db->getMagnetComment($push->magnetCommentId))
{ {
// Dump public data only // Dump public data only
if (isset($public['magnet'][$magnetComment->magnetId]) && $public['magnet'][$magnetComment->magnetId] === '1' && if (!empty($public['magnet'][$magnetComment->magnetId]) &&
isset($public['user'][$magnetComment->userId] ) && $public['user'][$magnetComment->userId] === '1') !empty($public['user'][$magnetComment->userId]))
{ {
$request['magnetComment'] = (object) $request['magnetComment'] = (object)
[ [
@ -256,8 +263,8 @@ if (API_EXPORT_PUSH_ENABLED)
if ($magnetStar = $db->getMagnetStar($push->magnetStarId)) if ($magnetStar = $db->getMagnetStar($push->magnetStarId))
{ {
// Dump public data only // Dump public data only
if (isset($public['magnet'][$magnetStar->magnetId]) && $public['magnet'][$magnetStar->magnetId] === '1' && if (!empty($public['magnet'][$magnetStar->magnetId]) &&
isset($public['user'][$magnetStar->userId] ) && $public['user'][$magnetStar->userId] === '1') !empty($public['user'][$magnetStar->userId]))
{ {
$request['magnetStar'] = (object) $request['magnetStar'] = (object)
[ [
@ -278,8 +285,8 @@ if (API_EXPORT_PUSH_ENABLED)
if ($magnetView = $db->getMagnetView($push->magnetViewId)) if ($magnetView = $db->getMagnetView($push->magnetViewId))
{ {
// Dump public data only // Dump public data only
if (isset($public['magnet'][$magnetView->magnetId]) && $public['magnet'][$magnetView->magnetId] === '1' && if (!empty($public['magnet'][$magnetView->magnetId]) &&
isset($public['user'][$magnetView->userId] ) && $public['user'][$magnetView->userId] === '1') !empty($public['user'][$magnetView->userId]))
{ {
$request['magnetView'] = (object) $request['magnetView'] = (object)
[ [

Loading…
Cancel
Save