use Friendica\BaseFactory;
use Friendica\Model\Attach;
use Friendica\Model\Photo;
-use Friendica\Network\HTTPException;
+use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Model\Post;
use Friendica\Util\Images;
use Friendica\Util\Proxy;
/**
* @param int $uriId Uri-ID of the attachments
* @return array
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
public function createFromUriId(int $uriId): array
{
/**
* @param int $id id of the media
* @return \Friendica\Object\Api\Mastodon\Attachment
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
public function createFromId(int $id): \Friendica\Object\Api\Mastodon\Attachment
{
$attachment = Post\Media::getById($id);
+
if (empty($attachment)) {
- return [];
+ $attachment = [
+ 'id' => '',
+ 'description' => '',
+ 'url' => '',
+ 'mimetype' => '',
+ 'blurhash' => '',
+ 'type' => Post\Media::UNKNOWN,
+ ];
}
+
return $this->createFromMediaArray($attachment);
}
/**
* @param array $attachment
* @return \Friendica\Object\Api\Mastodon\Attachment
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
private function createFromMediaArray(array $attachment): \Friendica\Object\Api\Mastodon\Attachment
{
* @param int $id id of the photo
*
* @return array
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
public function createFromPhoto(int $id): array
{
* @param int $id id of the attachment
*
* @return array
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
public function createFromAttach(int $id): array
{
* Insert a user-contact for a given contact array
*
* @param array $contact
- * @return void
*/
- public static function insertForContactArray(array $contact)
+ public static function insertForContactArray(array $contact): bool
{
if (empty($contact['uid'])) {
// We don't create entries for the public user - by now
{
$pcid = Contact::getPublicContactId($cid, $uid);
if (!$pcid) {
- return false;
+ return self::FREQUENCY_DEFAULT;
}
$public_contact = DBA::selectFirst('user-contact', ['channel-frequency'], ['cid' => $pcid, 'uid' => $uid]);