2013-04-02 11:09:33 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-23 21:32:42 +02:00
|
|
|
* Nextcloud - News
|
2014-04-19 18:16:55 +02:00
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later. See the COPYING file.
|
|
|
|
*
|
2018-03-27 15:35:06 +02:00
|
|
|
* @author Alessandro Cosentino <cosenal@gmail.com>
|
|
|
|
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
|
|
|
* @copyright 2012 Alessandro Cosentino
|
|
|
|
* @copyright 2012-2014 Bernhard Posselt
|
2014-04-19 18:16:55 +02:00
|
|
|
*/
|
2013-04-02 11:09:33 +02:00
|
|
|
|
2013-09-27 20:03:00 +02:00
|
|
|
namespace OCA\News\Fetcher;
|
2013-04-02 11:09:33 +02:00
|
|
|
|
2019-03-11 22:36:00 +01:00
|
|
|
use FeedIo\Reader\ReadErrorException;
|
2020-12-26 13:09:41 +01:00
|
|
|
use OCA\News\Db\Feed;
|
|
|
|
use OCA\News\Db\Item;
|
2019-03-11 22:36:00 +01:00
|
|
|
|
2018-03-27 15:35:06 +02:00
|
|
|
interface IFeedFetcher
|
|
|
|
{
|
2013-06-09 01:08:12 +02:00
|
|
|
|
2014-10-21 16:45:36 +02:00
|
|
|
/**
|
2018-11-29 20:59:46 +01:00
|
|
|
* Fetch feed content.
|
|
|
|
*
|
2019-01-31 13:40:52 +01:00
|
|
|
* @param string $url remote url of the feed
|
2021-02-11 07:56:31 +01:00
|
|
|
* @param bool $fullTextEnabled If true use a scraper to download the full article
|
2019-01-31 13:40:52 +01:00
|
|
|
* @param string|null $user if given, basic auth is set for this feed
|
|
|
|
* @param string|null $password if given, basic auth is set for this feed. Ignored if user is empty
|
2023-03-01 17:41:11 +01:00
|
|
|
* @param string|null $httpLastModified if given, will be used when sending a request to servers
|
2018-11-29 20:59:46 +01:00
|
|
|
*
|
2021-01-08 23:26:10 +01:00
|
|
|
* @return array<Feed, Item[]> an array containing the new feed and its items, first
|
2014-10-21 16:45:36 +02:00
|
|
|
* element being the Feed and second element being an array of Items
|
2020-09-28 21:07:24 +02:00
|
|
|
*
|
2019-03-11 22:36:00 +01:00
|
|
|
* @throws ReadErrorException if the Feed-IO fetcher encounters a problem
|
2014-10-21 16:45:36 +02:00
|
|
|
*/
|
2020-09-28 21:07:24 +02:00
|
|
|
public function fetch(
|
|
|
|
string $url,
|
|
|
|
bool $fullTextEnabled,
|
|
|
|
?string $user,
|
2023-02-24 09:16:45 +01:00
|
|
|
?string $password,
|
|
|
|
?string $httpLastModified
|
2020-09-28 21:07:24 +02:00
|
|
|
): array;
|
2013-04-02 11:14:04 +02:00
|
|
|
|
2014-10-21 16:45:36 +02:00
|
|
|
/**
|
2018-11-29 20:59:46 +01:00
|
|
|
* Can a fetcher handle a feed.
|
|
|
|
*
|
2014-10-21 16:45:36 +02:00
|
|
|
* @param string $url the url that should be fetched
|
2018-11-29 20:59:46 +01:00
|
|
|
*
|
2014-10-21 16:45:36 +02:00
|
|
|
* @return boolean if the fetcher can handle the url. This fetcher will be
|
|
|
|
* used exclusively to fetch the feed and the items of the page
|
|
|
|
*/
|
2020-08-29 23:39:35 +02:00
|
|
|
public function canHandle(string $url): bool;
|
2015-08-10 20:20:30 +02:00
|
|
|
}
|