diff options
| author | 2022-08-08 12:04:02 +0200 | |
|---|---|---|
| committer | 2022-08-08 12:04:02 +0200 | |
| commit | 82ac1d1e676f93b1567eba608c00c6edaf401a9e (patch) | |
| tree | 1b3609df25f3eb1892aa7d359f52b82d680830a7 /app/Models/FeedDAO.php | |
| parent | 240afa7d4dcf33de4575a1531e2db3c9f4400c1f (diff) | |
Refactor entry-to-GReader API format (#4490)
* Refactor entry to GReader API format
Some code was copied in two locations and not completely uniform.
Cleaning of related variables and functions (e.g. better types for entries and categories as objects vs. as IDs).
Usecase: I need to call the same GReader-compatible serialization from an extension
* Fixed some edge cases
* Keep summary instead of content
`summary` and `content` seems to be used interchangeably in the Google Reader API. We have been using `summary` for our client API and `content` in our export/import, so stick to that.
Diffstat (limited to 'app/Models/FeedDAO.php')
| -rw-r--r-- | app/Models/FeedDAO.php | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 8d54e7be2..233d2a715 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -82,7 +82,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { 'id' => $feed->id(), 'url' => $feed->url(), 'kind' => $feed->kind(), - 'category' => $feed->category(), + 'category' => $feed->categoryId(), 'name' => $feed->name(), 'website' => $feed->website(), 'description' => $feed->description(), @@ -341,26 +341,6 @@ SQL; } /** - * For API - */ - public function arrayFeedCategoryNames(): array { - $sql = <<<'SQL' -SELECT f.id, f.name, c.name as c_name FROM `_feed` f -INNER JOIN `_category` c ON c.id = f.category -SQL; - $stm = $this->pdo->query($sql); - $res = $stm->fetchAll(PDO::FETCH_ASSOC); - $feedCategoryNames = array(); - foreach ($res as $line) { - $feedCategoryNames[$line['id']] = array( - 'name' => $line['name'], - 'c_name' => $line['c_name'], - ); - } - return $feedCategoryNames; - } - - /** * Use $defaultCacheDuration == -1 to return all feeds, without filtering them by TTL. * @return array<FreshRSS_Feed> */ @@ -596,7 +576,7 @@ SQL; $myFeed = new FreshRSS_Feed($dao['url'] ?? '', false); $myFeed->_kind($dao['kind'] ?? FreshRSS_Feed::KIND_RSS); - $myFeed->_category($category); + $myFeed->_categoryId($category); $myFeed->_name($dao['name']); $myFeed->_website($dao['website'] ?? '', false); $myFeed->_description($dao['description'] ?? ''); |
