mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +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
+8
-3
@@ -14,8 +14,7 @@ async function uploadPhoto(identifier: string, image: string) {
|
|||||||
async function getPhotosByIdentifier(identifier: string): Promise<IPhoto[]> {
|
async function getPhotosByIdentifier(identifier: string): Promise<IPhoto[]> {
|
||||||
const query = 'SELECT id, image FROM npwd_phone_gallery WHERE identifier = ? ORDER BY id DESC';
|
const query = 'SELECT id, image FROM npwd_phone_gallery WHERE identifier = ? ORDER BY id DESC';
|
||||||
const [results] = await pool.query(query, [identifier]);
|
const [results] = await pool.query(query, [identifier]);
|
||||||
const photos = <IPhoto[]>results;
|
return <IPhoto[]>results;
|
||||||
return photos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deletePhoto(photo: IPhoto, identifier: string) {
|
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 () => {
|
onNet(events.CAMERA_FETCH_PHOTOS, async () => {
|
||||||
const _source = getSource();
|
const _source = getSource();
|
||||||
|
try {
|
||||||
const identifier = getIdentifier(_source);
|
const identifier = getIdentifier(_source);
|
||||||
const photos = await getPhotosByIdentifier(identifier);
|
const photos = await getPhotosByIdentifier(identifier);
|
||||||
emitNet(events.CAMERA_SEND_PHOTOS, source, photos);
|
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) => {
|
onNet(events.CAMERA_DELETE_PHOTO, async (photo: IPhoto) => {
|
||||||
|
|||||||
Reference in new issue
Block a user