mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
chore(server/photo): Added try/catch to missing sql query
This commit is contained in:
1 parent
598bcd2eb3
commit
23ef9b8cd6
1 file changed
+10
-5
@@ -14,8 +14,7 @@ async function uploadPhoto(identifier: string, image: string) {
|
||||
async function getPhotosByIdentifier(identifier: string): Promise<IPhoto[]> {
|
||||
const query = 'SELECT id, image FROM npwd_phone_gallery WHERE identifier = ? ORDER BY id DESC';
|
||||
const [results] = await pool.query(query, [identifier]);
|
||||
const photos = <IPhoto[]>results;
|
||||
return photos;
|
||||
return <IPhoto[]>results;
|
||||
}
|
||||
|
||||
async function deletePhoto(photo: IPhoto, identifier: string) {
|
||||
@@ -38,9 +37,15 @@ onNet(events.CAMERA_UPLOAD_PHOTO, async (image: string) => {
|
||||
|
||||
onNet(events.CAMERA_FETCH_PHOTOS, async () => {
|
||||
const _source = getSource();
|
||||
const identifier = getIdentifier(_source);
|
||||
const photos = await getPhotosByIdentifier(identifier);
|
||||
emitNet(events.CAMERA_SEND_PHOTOS, source, photos);
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
const photos = await getPhotosByIdentifier(identifier);
|
||||
emitNet(events.CAMERA_SEND_PHOTOS, _source, photos);
|
||||
} catch (e) {
|
||||
photoLogger.error(`Failed to fetch photos, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.CAMERA_DELETE_PHOTO, async (photo: IPhoto) => {
|
||||
|
||||
Reference in new issue
Block a user