mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-02-16 15:19:55 +03:00
fix: mastodon, cache tweaks, docs (#3661)
* cache tweaks * docs * fix(mastodon): type bug
This commit is contained in:
parent
4b9f6f7e53
commit
3178deb5a8
4 changed files with 19 additions and 5 deletions
|
@ -664,7 +664,7 @@ class ItakuBridge extends BridgeAbstract
|
|||
// Debug::log($url);
|
||||
if ($getJSON) { //get JSON object
|
||||
if ($cache) {
|
||||
$data = $this->loadCacheValue($url, 86400); // 24 hours
|
||||
$data = $this->loadCacheValue($url);
|
||||
if (is_null($data)) {
|
||||
$data = getContents($url, $httpHeaders, $curlOptions) or returnServerError("Could not load $url");
|
||||
$this->saveCacheValue($url, $data);
|
||||
|
|
|
@ -100,6 +100,10 @@ class MastodonBridge extends BridgeAbstract
|
|||
// We fetch the boosted content.
|
||||
try {
|
||||
$rtContent = $this->fetchAP($content['object']);
|
||||
if (!$rtContent) {
|
||||
// Sometimes fetchAP returns null. Someone should figure out why. json_decode failure?
|
||||
break;
|
||||
}
|
||||
$rtUser = $this->loadCacheValue($rtContent['attributedTo']);
|
||||
if (!isset($rtUser)) {
|
||||
// We fetch the author, since we cannot always assume the format of the URL.
|
||||
|
@ -277,6 +281,10 @@ class MastodonBridge extends BridgeAbstract
|
|||
array_push($headers, $sig);
|
||||
}
|
||||
}
|
||||
return json_decode(getContents($url, $headers), true);
|
||||
try {
|
||||
return Json::decode(getContents($url, $headers));
|
||||
} catch (\JsonException $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -353,10 +353,12 @@ class PixivBridge extends BridgeAbstract
|
|||
private function getCookie()
|
||||
{
|
||||
// checks if cookie is set, if not initialise it with the cookie from the config
|
||||
$value = $this->loadCacheValue('cookie', 2678400 /* 30 days + 1 day to let cookie chance to renew */);
|
||||
$value = $this->loadCacheValue('cookie');
|
||||
if (!isset($value)) {
|
||||
$value = $this->getOption('cookie');
|
||||
$this->saveCacheValue('cookie', $this->getOption('cookie'));
|
||||
|
||||
// 30 days + 1 day to let cookie chance to renew
|
||||
$this->saveCacheValue('cookie', $this->getOption('cookie'), 2678400);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
@ -370,7 +372,7 @@ class PixivBridge extends BridgeAbstract
|
|||
}
|
||||
|
||||
if ($cache) {
|
||||
$data = $this->loadCacheValue($url, 86400); // 24 hours
|
||||
$data = $this->loadCacheValue($url);
|
||||
if (!$data) {
|
||||
$data = getContents($url, $httpHeaders, $curlOptions, true) or returnServerError("Could not load $url");
|
||||
$this->saveCacheValue($url, $data);
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* The storage table has a column `updated` which is incorrectly named.
|
||||
* It should have been named `expiration` and the code treats it as an expiration date (in unix timestamp)
|
||||
*/
|
||||
class SQLiteCache implements CacheInterface
|
||||
{
|
||||
private \SQLite3 $db;
|
||||
|
|
Loading…
Add table
Reference in a new issue