API: Improved avatar handling

This commit is contained in:
Michael 2021-06-24 07:08:38 +00:00
parent a02426c08c
commit 96809b3fdd
5 changed files with 67 additions and 35 deletions

View file

@ -22,6 +22,7 @@
namespace Friendica\Model\Storage;
use \BadMethodCallException;
use Friendica\DI;
/**
* System resource storage class
@ -41,6 +42,16 @@ class SystemResource implements IStorage
*/
public function get(string $filename)
{
$parts = parse_url($filename);
if (!empty($parts['scheme']) && !empty($parts['host'])) {
$curlResult = DI::httpRequest()->get($filename);
if ($curlResult->isSuccess()) {
return $curlResult->getBody();
} else {
return "";
}
}
$folder = dirname($filename);
if (!in_array($folder, self::VALID_FOLDERS)) {
return "";