aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Dag <me@dvikan.no> 2024-04-06 18:07:45 +0200
committerGravatar GitHub <noreply@github.com> 2024-04-06 18:07:45 +0200
commit4602f4f475d938202de6c65214b321d41d0a93e8 (patch)
tree0558075d2057606a8bcc91f2e496aa3b3d08cd97
parentb3ac1d176ce9f4778986190702216f0f25918a70 (diff)
downloadrss-bridge-4602f4f475d938202de6c65214b321d41d0a93e8.tar.gz
rss-bridge-4602f4f475d938202de6c65214b321d41d0a93e8.tar.zst
rss-bridge-4602f4f475d938202de6c65214b321d41d0a93e8.zip
tweaks (#4065)
-rw-r--r--bridges/FilterBridge.php2
-rw-r--r--bridges/TrelloBridge.php34
-rw-r--r--bridges/TwitchBridge.php2
-rw-r--r--formats/HtmlFormat.php2
-rw-r--r--lib/BridgeAbstract.php9
-rw-r--r--lib/contents.php2
6 files changed, 24 insertions, 27 deletions
diff --git a/bridges/FilterBridge.php b/bridges/FilterBridge.php
index 1add47f4..3448a8c7 100644
--- a/bridges/FilterBridge.php
+++ b/bridges/FilterBridge.php
@@ -77,7 +77,7 @@ class FilterBridge extends FeedExpander
{
$url = $this->getInput('url');
if (!Url::validate($url)) {
- returnClientError('The url parameter must either refer to http or https protocol.');
+ throw new \Exception('The url parameter must either refer to http or https protocol.');
}
$this->collectExpandableDatas($this->getURI());
}
diff --git a/bridges/TrelloBridge.php b/bridges/TrelloBridge.php
index cab2bde2..42651fd1 100644
--- a/bridges/TrelloBridge.php
+++ b/bridges/TrelloBridge.php
@@ -553,10 +553,8 @@ class TrelloBridge extends BridgeAbstract
private function queryAPI($path, $params = [])
{
- $data = json_decode(getContents('https://trello.com/1/'
- . $path
- . '?'
- . http_build_query($params)));
+ $url = 'https://trello.com/1/' . $path . '?' . http_build_query($params);
+ $data = json_decode(getContents($url));
return $data;
}
@@ -576,33 +574,21 @@ class TrelloBridge extends BridgeAbstract
&& !$textOnly
&& isset($entity->originalUrl)
) {
- $string = '<p><a href="'
- . $entity->originalUrl
- . '"><img src="'
- . $entity->previewUrl
- . '"></a></p>';
+ $string = sprintf(
+ '<p><a href="%s"><img src="%s"></a></p>',
+ $entity->originalUrl,
+ $entity->previewUrl ?? ''
+ );
} elseif ($type === 'card' && !$textOnly) {
- $string = '<a href="https://trello.com/c/'
- . $entity->shortLink
- . '">'
- . $entity->text
- . '</a>';
+ $string = sprintf('<a href="https://trello.com/c/%s">%s</a>', $entity->shortLink, $entity->text);
} elseif ($type === 'member' && !$textOnly) {
- $string = '<a href="https://trello.com/'
- . $entity->username
- . '">'
- . $entity->text
- . '</a>';
+ $string = sprintf('<a href="https://trello.com/%s">%s</a>', $entity->username, $entity->text);
} elseif ($type === 'date') {
$string = gmdate('M j, Y \a\t g:i A T', strtotime($entity->date));
} elseif ($type === 'translatable') {
$string = self::ACTION_TEXTS[$entity->translationKey];
} else {
- if (isset($entity->text)) {
- $string = $entity->text;
- } else {
- $string = '';
- }
+ $string = $entity->text ?? '';
}
$strings['{' . $entity_name . '}'] = $string;
}
diff --git a/bridges/TwitchBridge.php b/bridges/TwitchBridge.php
index 9e70944e..424cd6e3 100644
--- a/bridges/TwitchBridge.php
+++ b/bridges/TwitchBridge.php
@@ -99,7 +99,7 @@ EOD;
$user = $data->user;
if ($user->videos === null) {
// twitch regularly does this for unknown reasons
- $this->logger->info('Twitch returned empty set of videos', ['data' => $data]);
+ //$this->logger->info('Twitch returned empty set of videos', ['data' => $data]);
return;
}
diff --git a/formats/HtmlFormat.php b/formats/HtmlFormat.php
index 1e2f60e6..37ef3a93 100644
--- a/formats/HtmlFormat.php
+++ b/formats/HtmlFormat.php
@@ -6,7 +6,7 @@ class HtmlFormat extends FormatAbstract
public function stringify()
{
- // This query string comes in already url decoded
+ // This query string is url encoded
$queryString = $_SERVER['QUERY_STRING'];
$feedArray = $this->getFeed();
diff --git a/lib/BridgeAbstract.php b/lib/BridgeAbstract.php
index 1456e1c3..2467dec6 100644
--- a/lib/BridgeAbstract.php
+++ b/lib/BridgeAbstract.php
@@ -6,8 +6,17 @@ abstract class BridgeAbstract
const URI = '';
const DONATION_URI = '';
const DESCRIPTION = 'No description provided';
+
+ /**
+ * Preferably a github username
+ */
const MAINTAINER = 'No maintainer';
+
+ /**
+ * Cache TTL in seconds
+ */
const CACHE_TIMEOUT = 3600;
+
const CONFIGURATION = [];
const PARAMETERS = [];
const TEST_DETECT_PARAMETERS = [];
diff --git a/lib/contents.php b/lib/contents.php
index 43db8c03..ba6dd531 100644
--- a/lib/contents.php
+++ b/lib/contents.php
@@ -17,6 +17,8 @@ function getContents(
$httpClient = RssBridge::getHttpClient();
$cache = RssBridge::getCache();
+ // TODO: consider url validation at this point
+
$httpHeadersNormalized = [];
foreach ($httpHeaders as $httpHeader) {
$parts = explode(':', $httpHeader);