code fixes

This commit is contained in:
Dennis Eichhorn 2024-03-15 20:24:38 +00:00
parent 38565605f7
commit d937e54ff1
2 changed files with 17 additions and 13 deletions

View File

@ -83,6 +83,9 @@ final class ApiController extends Controller
public function apiMediaEmailSend(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void public function apiMediaEmailSend(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{ {
$email = $request->getDataString('email'); $email = $request->getDataString('email');
if (empty($email)) {
return;
}
$media = $data['media'] ?? MediaMapper::get() $media = $data['media'] ?? MediaMapper::get()
->where('id', (int) $request->getData('id')) ->where('id', (int) $request->getData('id'))
@ -522,7 +525,7 @@ final class ApiController extends Controller
case 'tiff': case 'tiff':
case 'webp': case 'webp':
case 'bmp': case 'bmp':
$ocr = new TesseractOcr(); $ocr = new TesseractOcr();
return $ocr->parseImage($path); return $ocr->parseImage($path);
case 'doc': case 'doc':
@ -980,13 +983,13 @@ final class ApiController extends Controller
$virtualPath = \trim($path, '/'); $virtualPath = \trim($path, '/');
$virtualPaths = \explode('/', $virtualPath); $virtualPaths = \explode('/', $virtualPath);
$tempVirtualPaths = $virtualPaths; $tempVirtualPaths = $virtualPaths;
$length = \count($virtualPaths); $length = \count($virtualPaths);
/** @var Collection $parentCollection */ /** @var Collection $parentCollection */
$parentCollection = null; $parentCollection = null;
$virtual = ''; $virtual = '';
$real = ''; $real = '';
$newVirtual = ''; $newVirtual = '';
for ($i = $length; $i > 0; --$i) { for ($i = $length; $i > 0; --$i) {
@ -1143,7 +1146,8 @@ final class ApiController extends Controller
$media->setVirtualPath(\dirname($path)); $media->setVirtualPath(\dirname($path));
$media->setPath('/' . \ltrim($path, '\\/')); $media->setPath('/' . \ltrim($path, '\\/'));
} else { } else {
$media = MediaMapper::getAll() /** @var Media $media */
$media = MediaMapper::get()
->where('virtualPath', $path) ->where('virtualPath', $path)
->limit(1) ->limit(1)
->execute(); ->execute();

View File

@ -72,10 +72,10 @@ final class SearchController extends Controller
'link' => '{/base}/media/view?id=' . $file->id, 'link' => '{/base}/media/view?id=' . $file->id,
'account' => '', 'account' => '',
'createdAt' => $file->createdAt, 'createdAt' => $file->createdAt,
'image' => '', 'image' => '',
'tags' => $file->tags, 'tags' => $file->tags,
'type' => 'list_links', 'type' => 'list_links',
'module' => 'Media', 'module' => 'Media',
]; ];
} }
@ -121,10 +121,10 @@ final class SearchController extends Controller
'link' => '{/base}/media/view?id=' . $file->id, 'link' => '{/base}/media/view?id=' . $file->id,
'account' => '', 'account' => '',
'createdAt' => $file->createdAt, 'createdAt' => $file->createdAt,
'image' => '', 'image' => '',
'tags' => $file->tags, 'tags' => $file->tags,
'type' => 'list_links', 'type' => 'list_links',
'module' => 'Media', 'module' => 'Media',
]; ];
} }