Return exif in info call
parent
1d65a6dabe
commit
0fbe35db7d
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue