mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
refactor(server/source-handling): Altered how we handle source
These changes are made in case source is not guranteed to remain the same Due to how JS should operate, this shouldn't be an issue but this just ensures that
This commit is contained in:
1 parent
acb8e056c3
commit
1aa6a383ab
12 files changed
+222
-140
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import events from '../utils/events';
|
||||
import { getSource } from './server';
|
||||
import { pool } from './db';
|
||||
import { useIdentifier } from './functions';
|
||||
import { getIdentifier, getSource } from './functions';
|
||||
import { IPhoto } from '../../phone/src/common/typings/photo';
|
||||
import { mainLogger } from './sv_logger';
|
||||
|
||||
@@ -28,28 +27,34 @@ async function deletePhoto(photo: IPhoto, identifier: string) {
|
||||
}
|
||||
|
||||
onNet(events.CAMERA_UPLOAD_PHOTO, async (image: string) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const pSource = (global as any).source;
|
||||
const identifier = await useIdentifier();
|
||||
const identifier = getIdentifier(_source);
|
||||
await uploadPhoto(identifier, image);
|
||||
emitNet(events.CAMERA_UPLOAD_PHOTO_SUCCESS, pSource);
|
||||
emitNet(events.CAMERA_UPLOAD_PHOTO_SUCCESS, _source);
|
||||
} catch (e) {
|
||||
photoLogger.error(`Failed to upload photo, ${e.message}`);
|
||||
photoLogger.error(`Failed to upload photo, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.CAMERA_FETCH_PHOTOS, async () => {
|
||||
const identifier = await useIdentifier();
|
||||
const _source = getSource();
|
||||
const identifier = getIdentifier(_source);
|
||||
const photos = await getPhotosByIdentifier(identifier);
|
||||
emitNet(events.CAMERA_SEND_PHOTOS, getSource(), photos);
|
||||
emitNet(events.CAMERA_SEND_PHOTOS, source, photos);
|
||||
});
|
||||
|
||||
onNet(events.CAMERA_DELETE_PHOTO, async (photo: IPhoto) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = await useIdentifier();
|
||||
const identifier = getIdentifier(_source);
|
||||
await deletePhoto(photo, identifier);
|
||||
emitNet(events.CAMERA_DELETE_PHOTO_SUCCESS, getSource());
|
||||
emitNet(events.CAMERA_DELETE_PHOTO_SUCCESS, _source);
|
||||
} catch (e) {
|
||||
photoLogger.error(`Failed to fetch photos, ${e.message}`);
|
||||
photoLogger.error(`Failed to fetch photos, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user