mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-11 15:37:57 +00:00
update manifest api
This commit is contained in:
parent
19b721d441
commit
b4ad54513b
@ -52,40 +52,63 @@ try
|
||||
|
||||
'settings' => (object)
|
||||
[
|
||||
'YGGDRASIL_HOST_REGEX' => YGGDRASIL_HOST_REGEX,
|
||||
'YGGDRASIL_HOST_REGEX' => (string) YGGDRASIL_HOST_REGEX,
|
||||
|
||||
'NODE_RULE_SUBJECT' => NODE_RULE_SUBJECT,
|
||||
'NODE_RULE_LANGUAGES' => NODE_RULE_LANGUAGES,
|
||||
'NODE_RULE_SUBJECT' => (string) NODE_RULE_SUBJECT,
|
||||
'NODE_RULE_LANGUAGES' => (string) NODE_RULE_LANGUAGES,
|
||||
|
||||
'USER_DEFAULT_APPROVED' => USER_DEFAULT_APPROVED,
|
||||
'USER_AUTO_APPROVE_ON_MAGNET_APPROVE' => USER_AUTO_APPROVE_ON_MAGNET_APPROVE,
|
||||
'USER_AUTO_APPROVE_ON_COMMENT_APPROVE' => USER_AUTO_APPROVE_ON_COMMENT_APPROVE,
|
||||
'USER_DEFAULT_IDENTICON' => USER_DEFAULT_IDENTICON,
|
||||
'USER_IDENTICON_FIELD' => USER_IDENTICON_FIELD,
|
||||
'USER_DEFAULT_APPROVED' => (bool) USER_DEFAULT_APPROVED,
|
||||
'USER_AUTO_APPROVE_ON_MAGNET_APPROVE' => (bool) USER_AUTO_APPROVE_ON_MAGNET_APPROVE,
|
||||
'USER_AUTO_APPROVE_ON_COMMENT_APPROVE' => (bool) USER_AUTO_APPROVE_ON_COMMENT_APPROVE,
|
||||
'USER_DEFAULT_IDENTICON' => (string) USER_DEFAULT_IDENTICON,
|
||||
'USER_IDENTICON_FIELD' => (string) USER_IDENTICON_FIELD,
|
||||
|
||||
'MAGNET_DEFAULT_APPROVED' => MAGNET_DEFAULT_APPROVED,
|
||||
'MAGNET_DEFAULT_PUBLIC' => MAGNET_DEFAULT_PUBLIC,
|
||||
'MAGNET_DEFAULT_COMMENTS' => MAGNET_DEFAULT_COMMENTS,
|
||||
'MAGNET_DEFAULT_SENSITIVE' => MAGNET_DEFAULT_SENSITIVE,
|
||||
'MAGNET_DEFAULT_APPROVED' => (bool) MAGNET_DEFAULT_APPROVED,
|
||||
'MAGNET_DEFAULT_PUBLIC' => (bool) MAGNET_DEFAULT_PUBLIC,
|
||||
'MAGNET_DEFAULT_COMMENTS' => (bool) MAGNET_DEFAULT_COMMENTS,
|
||||
'MAGNET_DEFAULT_SENSITIVE' => (bool) MAGNET_DEFAULT_SENSITIVE,
|
||||
|
||||
'MAGNET_EDITOR_LOCK_TIMEOUT' => MAGNET_EDITOR_LOCK_TIMEOUT,
|
||||
'MAGNET_EDITOR_LOCK_TIMEOUT' => (int) MAGNET_EDITOR_LOCK_TIMEOUT,
|
||||
|
||||
'MAGNET_TITLE_MIN_LENGTH' => MAGNET_TITLE_MIN_LENGTH,
|
||||
'MAGNET_TITLE_MAX_LENGTH' => MAGNET_TITLE_MAX_LENGTH,
|
||||
'MAGNET_TITLE_MIN_LENGTH' => (int) MAGNET_TITLE_MIN_LENGTH,
|
||||
'MAGNET_TITLE_MAX_LENGTH' => (int) MAGNET_TITLE_MAX_LENGTH,
|
||||
|
||||
'MAGNET_PREVIEW_MIN_LENGTH' => MAGNET_PREVIEW_MIN_LENGTH,
|
||||
'MAGNET_PREVIEW_MAX_LENGTH' => MAGNET_PREVIEW_MAX_LENGTH,
|
||||
'MAGNET_PREVIEW_MIN_LENGTH' => (int) MAGNET_PREVIEW_MIN_LENGTH,
|
||||
'MAGNET_PREVIEW_MAX_LENGTH' => (int) MAGNET_PREVIEW_MAX_LENGTH,
|
||||
|
||||
'MAGNET_DESCRIPTION_MIN_LENGTH' => MAGNET_DESCRIPTION_MIN_LENGTH,
|
||||
'MAGNET_DESCRIPTION_MAX_LENGTH' => MAGNET_DESCRIPTION_MAX_LENGTH,
|
||||
'MAGNET_DESCRIPTION_MIN_LENGTH' => (int) MAGNET_DESCRIPTION_MIN_LENGTH,
|
||||
'MAGNET_DESCRIPTION_MAX_LENGTH' => (int) MAGNET_DESCRIPTION_MAX_LENGTH,
|
||||
|
||||
'MAGNET_COMMENT_DEFAULT_APPROVED' => MAGNET_COMMENT_DEFAULT_APPROVED,
|
||||
'MAGNET_COMMENT_DEFAULT_PUBLIC' => MAGNET_COMMENT_DEFAULT_PUBLIC,
|
||||
'MAGNET_COMMENT_DEFAULT_PUBLIC' => MAGNET_COMMENT_DEFAULT_PUBLIC,
|
||||
'MAGNET_COMMENT_MIN_LENGTH' => MAGNET_COMMENT_MIN_LENGTH,
|
||||
'MAGNET_COMMENT_MAX_LENGTH' => MAGNET_COMMENT_MAX_LENGTH,
|
||||
'MAGNET_COMMENT_DEFAULT_APPROVED' => (bool) MAGNET_COMMENT_DEFAULT_APPROVED,
|
||||
'MAGNET_COMMENT_DEFAULT_PUBLIC' => (bool) MAGNET_COMMENT_DEFAULT_PUBLIC,
|
||||
'MAGNET_COMMENT_DEFAULT_PUBLIC' => (bool) MAGNET_COMMENT_DEFAULT_PUBLIC,
|
||||
'MAGNET_COMMENT_MIN_LENGTH' => (int) MAGNET_COMMENT_MIN_LENGTH,
|
||||
'MAGNET_COMMENT_MAX_LENGTH' => (int) MAGNET_COMMENT_MAX_LENGTH,
|
||||
|
||||
'MAGNET_STOP_WORDS_SIMILAR' => (object) MAGNET_STOP_WORDS_SIMILAR,
|
||||
|
||||
'API_EXPORT_ENABLED' => (bool) API_EXPORT_ENABLED,
|
||||
'API_EXPORT_PUSH_ENABLED' => (bool) API_EXPORT_PUSH_ENABLED,
|
||||
'API_EXPORT_USERS_ENABLED' => (bool) API_EXPORT_USERS_ENABLED,
|
||||
'API_EXPORT_MAGNETS_ENABLED' => (bool) API_EXPORT_MAGNETS_ENABLED,
|
||||
'API_EXPORT_MAGNET_DOWNLOADS_ENABLED' => (bool) API_EXPORT_MAGNET_DOWNLOADS_ENABLED,
|
||||
'API_EXPORT_MAGNET_COMMENTS_ENABLED' => (bool) API_EXPORT_MAGNET_COMMENTS_ENABLED,
|
||||
'API_EXPORT_MAGNET_STARS_ENABLED' => (bool) API_EXPORT_MAGNET_STARS_ENABLED,
|
||||
'API_EXPORT_MAGNET_STARS_ENABLED' => (bool) API_EXPORT_MAGNET_STARS_ENABLED,
|
||||
'API_EXPORT_MAGNET_VIEWS_ENABLED' => (bool) API_EXPORT_MAGNET_VIEWS_ENABLED,
|
||||
|
||||
'API_IMPORT_ENABLED' => (bool) API_IMPORT_ENABLED,
|
||||
'API_IMPORT_PUSH_ENABLED' => (bool) API_IMPORT_PUSH_ENABLED,
|
||||
'API_IMPORT_USERS_ENABLED' => (bool) API_IMPORT_USERS_ENABLED,
|
||||
|
||||
'API_IMPORT_USERS_APPROVED_ONLY' => (bool) API_IMPORT_USERS_APPROVED_ONLY,
|
||||
'API_IMPORT_MAGNETS_ENABLED' => (bool) API_IMPORT_MAGNETS_ENABLED,
|
||||
'API_IMPORT_MAGNETS_APPROVED_ONLY' => (bool) API_IMPORT_MAGNETS_APPROVED_ONLY,
|
||||
'API_IMPORT_MAGNET_DOWNLOADS_ENABLED' => (bool) API_IMPORT_MAGNET_DOWNLOADS_ENABLED,
|
||||
'API_IMPORT_MAGNET_COMMENTS_ENABLED' => (bool) API_IMPORT_MAGNET_COMMENTS_ENABLED,
|
||||
'API_IMPORT_MAGNET_COMMENTS_APPROVED_ONLY' => (bool) API_IMPORT_MAGNET_COMMENTS_APPROVED_ONLY,
|
||||
'API_IMPORT_MAGNET_STARS_ENABLED' => (bool) API_IMPORT_MAGNET_STARS_ENABLED,
|
||||
'API_IMPORT_MAGNET_VIEWS_ENABLED' => (bool) API_IMPORT_MAGNET_VIEWS_ENABLED,
|
||||
],
|
||||
'totals' => (object)
|
||||
[
|
||||
@ -120,7 +143,11 @@ try
|
||||
'local' => $db->findMagnetViewsTotalByUsersPublic(false),
|
||||
],
|
||||
],
|
||||
'feeds' => (object)
|
||||
'import' => (object)
|
||||
[
|
||||
'push' => API_IMPORT_PUSH_ENABLED ? sprintf('%s/api/push.php', WEBSITE_URL) : false,
|
||||
],
|
||||
'export' => (object)
|
||||
[
|
||||
'users' => API_EXPORT_USERS_ENABLED ? sprintf('%s/api/users.json', WEBSITE_URL) : false,
|
||||
'magnets' => API_EXPORT_MAGNETS_ENABLED ? sprintf('%s/api/magnets.json', WEBSITE_URL) : false,
|
||||
|
@ -39,7 +39,7 @@ try
|
||||
if ($manifest = @json_decode(@file_get_contents($node->manifest)))
|
||||
{
|
||||
// Feed channel exists
|
||||
if (empty($manifest->feeds))
|
||||
if (empty($manifest->export))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -47,7 +47,7 @@ try
|
||||
// Users
|
||||
if (API_IMPORT_USERS_ENABLED)
|
||||
{
|
||||
if (empty($manifest->feeds->users))
|
||||
if (empty($manifest->export->users))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -55,7 +55,7 @@ try
|
||||
// Init alias registry for this host
|
||||
$aliasUserId = [];
|
||||
|
||||
foreach (@json_decode(@file_get_contents($manifest->feeds->users)) as $remoteUser)
|
||||
foreach (@json_decode(@file_get_contents($manifest->export->users)) as $remoteUser)
|
||||
{
|
||||
// Validate required fields
|
||||
if (!isset($remoteUser->address) || !preg_match(YGGDRASIL_HOST_REGEX, $remoteUser->address) ||
|
||||
@ -133,7 +133,7 @@ try
|
||||
// Magnets
|
||||
if (API_IMPORT_MAGNETS_ENABLED)
|
||||
{
|
||||
if (empty($manifest->feeds->magnets))
|
||||
if (empty($manifest->export->magnets))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -141,7 +141,7 @@ try
|
||||
// Init alias registry for this host
|
||||
$aliasMagnetId = [];
|
||||
|
||||
foreach (@json_decode(@file_get_contents($manifest->feeds->magnets)) as $remoteMagnet)
|
||||
foreach (@json_decode(@file_get_contents($manifest->export->magnets)) as $remoteMagnet)
|
||||
{
|
||||
// Validate required fields by protocol
|
||||
if (!isset($remoteMagnet->userId) || !is_int($remoteMagnet->userId) ||
|
||||
@ -383,12 +383,12 @@ try
|
||||
// Magnet comments
|
||||
if (API_IMPORT_MAGNET_COMMENTS_ENABLED)
|
||||
{
|
||||
if (empty($manifest->feeds->magnetComments))
|
||||
if (empty($manifest->export->magnetComments))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (@json_decode(@file_get_contents($manifest->feeds->magnetComments)) as $remoteMagnetComment)
|
||||
foreach (@json_decode(@file_get_contents($manifest->export->magnetComments)) as $remoteMagnetComment)
|
||||
{
|
||||
// Validate
|
||||
if (
|
||||
@ -442,12 +442,12 @@ try
|
||||
// Magnet downloads
|
||||
if (API_IMPORT_MAGNET_DOWNLOADS_ENABLED)
|
||||
{
|
||||
if (empty($manifest->feeds->magnetDownloads))
|
||||
if (empty($manifest->export->magnetDownloads))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (@json_decode(@file_get_contents($manifest->feeds->magnetDownloads)) as $remoteMagnetDownload)
|
||||
foreach (@json_decode(@file_get_contents($manifest->export->magnetDownloads)) as $remoteMagnetDownload)
|
||||
{
|
||||
// Validate
|
||||
if (
|
||||
@ -476,12 +476,12 @@ try
|
||||
// Magnet views
|
||||
if (API_IMPORT_MAGNET_VIEWS_ENABLED)
|
||||
{
|
||||
if (empty($manifest->feeds->magnetViews))
|
||||
if (empty($manifest->export->magnetViews))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (@json_decode(@file_get_contents($manifest->feeds->magnetViews)) as $remoteMagnetView)
|
||||
foreach (@json_decode(@file_get_contents($manifest->export->magnetViews)) as $remoteMagnetView)
|
||||
{
|
||||
// Validate
|
||||
if (
|
||||
@ -510,12 +510,12 @@ try
|
||||
// Magnet stars
|
||||
if (API_IMPORT_MAGNET_STARS_ENABLED)
|
||||
{
|
||||
if (empty($manifest->feeds->magnetStars))
|
||||
if (empty($manifest->export->magnetStars))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (@json_decode(@file_get_contents($manifest->feeds->magnetStars)) as $remoteMagnetStar)
|
||||
foreach (@json_decode(@file_get_contents($manifest->export->magnetStars)) as $remoteMagnetStar)
|
||||
{
|
||||
// Validate
|
||||
if (
|
||||
|
Loading…
Reference in New Issue
Block a user