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

@ -1614,7 +1614,7 @@ class Contact
*
* @param array $contact contact array
* @param string $size Size of the avatar picture
* @return void
* @return string avatar URL
*/
public static function getDefaultAvatar(array $contact, string $size)
{

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 "";