Support album-based photo lookup & routing
This commit is contained in:
@@ -5,18 +5,22 @@ import md5 from "md5";
|
||||
|
||||
export async function getPhotoFromHash(albumUrl: string, hash: string): Promise<PhotoAlbumPhoto | null> {
|
||||
const client = await createDirectusConnection();
|
||||
const result = await client.query(print(getPhotos));
|
||||
const result = await client.query(print(getPhotos), {
|
||||
albumUrl: albumUrl
|
||||
});
|
||||
|
||||
let object: PhotoAlbumPhoto | null = null;
|
||||
|
||||
result["Photo_Albums"][0]["photos"].forEach((photo: any) => {
|
||||
const hashObject = md5(JSON.stringify({
|
||||
id: photo.id,
|
||||
url: photo.photo.url,
|
||||
url: photo.photo.filename_disk,
|
||||
width: photo.photo.width,
|
||||
height: photo.photo.height
|
||||
}));
|
||||
|
||||
if (hash.substring(hash.length - 10) === hash) {
|
||||
return {
|
||||
if (hashObject.substring(hashObject.length - 10) === hash) {
|
||||
object = {
|
||||
id: photo.id,
|
||||
text: photo.text,
|
||||
photo: {
|
||||
@@ -27,4 +31,6 @@ export async function getPhotoFromHash(albumUrl: string, hash: string): Promise<
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user