Return exif in info call

pull/221/head
Varun Patil 2022-11-07 13:25:52 -08:00
parent 1d65a6dabe
commit 0fbe35db7d
5 changed files with 23 additions and 23 deletions

View File

@ -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);
}

View File

@ -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),
];
}
}

View File

@ -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);
}
}

View File

@ -186,7 +186,7 @@ export default class EditDate extends Mixins(GlobalMixin) {
const calls = photos.map((p) => async () => {
try {
const res = await axios.get<any>(
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);