diff --git a/lib/Controller/ImageController.php b/lib/Controller/ImageController.php index ad9b7023..d790ee83 100644 --- a/lib/Controller/ImageController.php +++ b/lib/Controller/ImageController.php @@ -52,7 +52,8 @@ class ImageController extends ApiBase $file = $file[0]; // Get the image info - $info = $this->timelineQuery->getInfoById($file->getId()); + $basic = false !== $this->request->getParam('basic', false); + $info = $this->timelineQuery->getInfoById($file->getId(), $basic); return new JSONResponse($info, Http::STATUS_OK); } diff --git a/lib/Db/TimelineQuery.php b/lib/Db/TimelineQuery.php index 8974e541..e5d4eb2a 100644 --- a/lib/Db/TimelineQuery.php +++ b/lib/Db/TimelineQuery.php @@ -48,14 +48,18 @@ class TimelineQuery { } - public function getInfoById(int $id): array + public function getInfoById(int $id, bool $basic): array { $qb = $this->connection->getQueryBuilder(); - $qb->select('fileid', 'dayid', 'datetaken') + $qb->select('fileid', 'dayid', 'datetaken', 'w', 'h') ->from('memories') ->where($qb->expr()->eq('fileid', $qb->createNamedParameter($id, \PDO::PARAM_INT))) ; + if (!$basic) { + $qb->addSelect('exif'); + } + $result = $qb->executeQuery(); $row = $result->fetch(); $result->closeCursor(); @@ -72,6 +76,9 @@ class TimelineQuery 'fileid' => (int) $row['fileid'], 'dayid' => (int) $row['dayid'], 'datetaken' => $utcTs, + 'w' => (int) $row['w'], + 'h' => (int) $row['h'], + 'exif' => $basic ? [] : json_decode($row['exif'], true), ]; } } diff --git a/lib/Db/TimelineWrite.php b/lib/Db/TimelineWrite.php index f9744442..bcd9145c 100644 --- a/lib/Db/TimelineWrite.php +++ b/lib/Db/TimelineWrite.php @@ -99,20 +99,12 @@ class TimelineWrite // Store raw metadata in the database // We need to remove blacklisted fields to prevent leaking info - unset($exif['SourceFile']); - unset($exif['FileName']); - unset($exif['ExifToolVersion']); - unset($exif['Directory']); - unset($exif['FileSize']); - unset($exif['FileModifyDate']); - unset($exif['FileAccessDate']); - unset($exif['FileInodeChangeDate']); - unset($exif['FilePermissions']); + unset($exif['SourceFile'], $exif['FileName'], $exif['ExifToolVersion'], $exif['Directory'], $exif['FileSize'], $exif['FileModifyDate'], $exif['FileAccessDate'], $exif['FileInodeChangeDate'], $exif['FilePermissions']); // Truncate any fields >2048 chars foreach ($exif as $key => &$value) { if (\is_string($value) && \strlen($value) > 2048) { - $exif[$key] = \substr($value, 0, 2048); + $exif[$key] = substr($value, 0, 2048); } } diff --git a/lib/Migration/Version400604Date20221107205439.php b/lib/Migration/Version400604Date20221107205439.php index 5e6c0bbb..c978652f 100644 --- a/lib/Migration/Version400604Date20221107205439.php +++ b/lib/Migration/Version400604Date20221107205439.php @@ -44,18 +44,18 @@ class Version400604Date20221107205439 extends SimpleMigrationStep */ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options): ?ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); - $table = $schema->getTable('memories'); + $table = $schema->getTable('memories'); - $table->addColumn('exif', 'text', [ - 'notnull' => false, - 'length' => 65535, - 'default' => '', - ]); + $table->addColumn('exif', 'text', [ + 'notnull' => false, + 'length' => 65535, + 'default' => '', + ]); - return $schema; + return $schema; } /** diff --git a/src/components/modal/EditDate.vue b/src/components/modal/EditDate.vue index da5723d8..ebf0f8c5 100644 --- a/src/components/modal/EditDate.vue +++ b/src/components/modal/EditDate.vue @@ -186,7 +186,7 @@ export default class EditDate extends Mixins(GlobalMixin) { const calls = photos.map((p) => async () => { try { const res = await axios.get( - generateUrl(INFO_API_URL, { id: p.fileid }) + generateUrl(INFO_API_URL, { id: p.fileid }) + "?basic=1" ); if (typeof res.data.datetaken !== "number") { console.error("Invalid date for", p.fileid);