Fix image posts done by Buffer

This commit is contained in:
Michael 2024-10-19 03:35:21 +00:00
parent 159e6e79dc
commit 55381329b3

View file

@ -42,16 +42,16 @@ class Media extends BaseApi
$type = Post\Media::getType($request['file']['type']); $type = Post\Media::getType($request['file']['type']);
if (in_array($type, [Post\Media::IMAGE, Post\Media::UNKNOWN])) { if (in_array($type, [Post\Media::IMAGE, Post\Media::UNKNOWN, Post\Media::APPLICATION])) {
$media = Photo::upload($uid, $request['file'], '', null, null, '', '', $request['description']); $media = Photo::upload($uid, $request['file'], '', null, null, '', '', $request['description']);
if (empty($media)) { if (!empty($media)) {
$this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); Logger::info('Uploaded photo', ['media' => $media]);
$this->jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id']));
} elseif ($type == Post\Media::IMAGE) {
$this->jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id']));
}
} }
Logger::info('Uploaded photo', ['media' => $media]);
$this->jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id']));
} else {
$tempFileName = $request['file']['tmp_name']; $tempFileName = $request['file']['tmp_name'];
$fileName = basename($request['file']['name']); $fileName = basename($request['file']['name']);
$fileSize = intval($request['file']['size']); $fileSize = intval($request['file']['size']);
@ -74,7 +74,6 @@ class Media extends BaseApi
Logger::info('Uploaded media', ['id' => $id]); Logger::info('Uploaded media', ['id' => $id]);
$this->jsonExit(DI::mstdnAttachment()->createFromAttach($id)); $this->jsonExit(DI::mstdnAttachment()->createFromAttach($id));
} }
}
public function put(array $request = []) public function put(array $request = [])
{ {