API fix default category (#7610)

fix https://github.com/FreshRSS/FreshRSS/issues/7368
This commit is contained in:
Alexandre Alapetite
2025-05-31 13:01:27 +02:00
committed by GitHub
parent 88de42085f
commit 80c9623f8f

View File

@@ -332,7 +332,6 @@ final class GReaderAPI {
self::internalServerError();
}
header('Content-Type: application/json; charset=UTF-8');
$salt = FreshRSS_Context::systemConf()->salt;
$faviconsUrl = Minz_Url::display('/f.php?', '', true);
$faviconsUrl = str_replace('/api/greader.php/reader/api/0/subscription', '', $faviconsUrl); //Security if base_url is not set properly
$subscriptions = [];
@@ -396,11 +395,15 @@ final class GReaderAPI {
}
}
$c_name = htmlspecialchars($c_name, ENT_COMPAT, 'UTF-8');
$categoryDAO = FreshRSS_Factory::createCategoryDao();
$cat = $categoryDAO->searchByName($c_name);
$addCatId = $cat === null ? 0 : $cat->id();
if ($addCatId === 0) {
$addCatId = $categoryDAO->addCategory(['name' => $c_name]) ?: FreshRSS_CategoryDAO::DEFAULTCATEGORYID;
if (in_array($c_name, ['', 'Uncategorized', _t('gen.short.default_category')], true)) {
$addCatId = FreshRSS_CategoryDAO::DEFAULTCATEGORYID;
} else {
$categoryDAO = FreshRSS_Factory::createCategoryDao();
$cat = $categoryDAO->searchByName($c_name);
$addCatId = $cat === null ? 0 : $cat->id();
if ($addCatId === 0) {
$addCatId = $categoryDAO->addCategory(['name' => $c_name]) ?: FreshRSS_CategoryDAO::DEFAULTCATEGORYID;
}
}
} elseif (str_starts_with($remove, 'user/-/label/')) {
$addCatId = FreshRSS_CategoryDAO::DEFAULTCATEGORYID;