Browse Source

allow custom title, preview, description fields import match conditions

main
ghost 1 year ago
parent
commit
9f3ed45a7c
  1. 35
      src/crontab/import/feed.php

35
src/crontab/import/feed.php

@ -140,19 +140,14 @@ try
foreach (@json_decode(@file_get_contents($manifest->feeds->magnets)) as $remoteMagnet) foreach (@json_decode(@file_get_contents($manifest->feeds->magnets)) as $remoteMagnet)
{ {
// Validate required fields // Validate required fields by protocol
if (!isset($remoteMagnet->userId) || !is_int($remoteMagnet->userId) || if (!isset($remoteMagnet->userId) || !is_int($remoteMagnet->userId) ||
!isset($aliasUserId[$remoteMagnet->userId]) || !isset($aliasUserId[$remoteMagnet->userId]) ||
!$db->getUser($aliasUserId[$remoteMagnet->userId]) || !$db->getUser($aliasUserId[$remoteMagnet->userId]) ||
!isset($remoteMagnet->title) || mb_strlen($remoteMagnet->title) < MAGNET_TITLE_MIN_LENGTH || !isset($remoteMagnet->title) || !is_string($remoteMagnet->title) ||
mb_strlen($remoteMagnet->title) > MAGNET_TITLE_MAX_LENGTH || !isset($remoteMagnet->preview) || !is_string($remoteMagnet->preview) ||
!isset($remoteMagnet->description) || !is_string($remoteMagnet->description) ||
!isset($remoteMagnet->preview) || mb_strlen($remoteMagnet->preview) < MAGNET_PREVIEW_MIN_LENGTH ||
mb_strlen($remoteMagnet->preview) > MAGNET_PREVIEW_MAX_LENGTH ||
!isset($remoteMagnet->description) || mb_strlen($remoteMagnet->description) < MAGNET_DESCRIPTION_MIN_LENGTH ||
mb_strlen($remoteMagnet->description) > MAGNET_DESCRIPTION_MAX_LENGTH ||
!isset($remoteMagnet->comments) || !is_bool($remoteMagnet->comments) || !isset($remoteMagnet->comments) || !is_bool($remoteMagnet->comments) ||
!isset($remoteMagnet->sensitive) || !is_bool($remoteMagnet->sensitive) || !isset($remoteMagnet->sensitive) || !is_bool($remoteMagnet->sensitive) ||
@ -211,9 +206,25 @@ try
// Magnet fields // Magnet fields
$db->updateMagnetXl($localMagnet->magnetId, $remoteMagnet->xl, $remoteMagnet->timeUpdated); $db->updateMagnetXl($localMagnet->magnetId, $remoteMagnet->xl, $remoteMagnet->timeUpdated);
$db->updateMagnetDn($localMagnet->magnetId, $remoteMagnet->dn, $remoteMagnet->timeUpdated); $db->updateMagnetDn($localMagnet->magnetId, $remoteMagnet->dn, $remoteMagnet->timeUpdated);
$db->updateMagnetTitle($localMagnet->magnetId, $remoteMagnet->title, $remoteMagnet->timeUpdated);
$db->updateMagnetPreview($localMagnet->magnetId, $remoteMagnet->preview, $remoteMagnet->timeUpdated); if (mb_strlen($remoteMagnet->title) >= MAGNET_TITLE_MIN_LENGTH &&
$db->updateMagnetDescription($localMagnet->magnetId, $remoteMagnet->description, $remoteMagnet->timeUpdated); mb_strlen($remoteMagnet->title) <= MAGNET_TITLE_MAX_LENGTH)
{
$db->updateMagnetTitle($localMagnet->magnetId, $remoteMagnet->title, $remoteMagnet->timeUpdated);
}
if (mb_strlen($remoteMagnet->preview) >= MAGNET_PREVIEW_MIN_LENGTH &&
mb_strlen($remoteMagnet->preview) <= MAGNET_PREVIEW_MAX_LENGTH)
{
$db->updateMagnetPreview($localMagnet->magnetId, $remoteMagnet->preview, $remoteMagnet->timeUpdated);
}
if (mb_strlen($remoteMagnet->description) >= MAGNET_DESCRIPTION_MIN_LENGTH &&
mb_strlen($remoteMagnet->description) <= MAGNET_DESCRIPTION_MAX_LENGTH)
{
$db->updateMagnetDescription($localMagnet->magnetId, $remoteMagnet->description, $remoteMagnet->timeUpdated);
}
$db->updateMagnetComments($localMagnet->magnetId, $remoteMagnet->comments, $remoteMagnet->timeUpdated); $db->updateMagnetComments($localMagnet->magnetId, $remoteMagnet->comments, $remoteMagnet->timeUpdated);
$db->updateMagnetSensitive($localMagnet->magnetId, $remoteMagnet->sensitive, $remoteMagnet->timeUpdated); $db->updateMagnetSensitive($localMagnet->magnetId, $remoteMagnet->sensitive, $remoteMagnet->timeUpdated);

Loading…
Cancel
Save