$attachment = Post\Media::getById($id);
if (empty($attachment)) {
- $attachment = [
- 'id' => '',
- 'description' => '',
- 'url' => '',
- 'mimetype' => '',
- 'blurhash' => '',
- 'type' => Post\Media::UNKNOWN,
- ];
+ throw new InternalServerErrorException();
}
return $this->createFromMediaArray($attachment);
use Friendica\Model\Photo;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
+use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Util\Strings;
/**
$photo = Photo::selectFirst(['resource-id'], ['id' => $this->parameters['id'], 'uid' => $uid]);
if (empty($photo['resource-id'])) {
$media = Post\Media::getById($this->parameters['id']);
+
if (empty($media['uri-id'])) {
$this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
}
+
if (!Post::exists(['uri-id' => $media['uri-id'], 'uid' => $uid, 'origin' => true])) {
$this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
}
+
Post\Media::updateById(['description' => $request['description']], $this->parameters['id']);
- $this->jsonExit(DI::mstdnAttachment()->createFromId($this->parameters['id']));
+
+ try {
+ $attachment = DI::mstdnAttachment()->createFromId($this->parameters['id'] . '1');
+ } catch (InternalServerErrorException $th) {
+ $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
+ }
+
+ $this->jsonExit($attachment);
}
Photo::update(['desc' => $request['description']], ['resource-id' => $photo['resource-id']]);