mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
feat(resources/server): refactor matchmaker
This commit is contained in:
1 parent
44a9595463
commit
6a3bef1e34
6 files changed
+420
-529
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import { Like, MatchEvents, Profile } from '../../../typings/match';
|
||||
import MatchService from './match.service';
|
||||
import { getSource } from '../utils/miscUtils';
|
||||
import { matchLogger } from './match.utils';
|
||||
import { config } from '../server';
|
||||
|
||||
onNet(MatchEvents.INITIALIZE, () => {
|
||||
const _source = getSource();
|
||||
MatchService.handleInitialize(_source).catch((e) =>
|
||||
matchLogger.error(`Error occurred in initialize event (${_source}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
|
||||
onNet(MatchEvents.CREATE_MY_PROFILE, (profile: Profile) => {
|
||||
const _source = getSource();
|
||||
MatchService.handleCreateMyProfile(_source, profile).catch((e) =>
|
||||
matchLogger.error(`Error occurred in createMyProfile event (${_source}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
|
||||
onNet(MatchEvents.UPDATE_MY_PROFILE, (profile: Profile) => {
|
||||
const _source = getSource();
|
||||
MatchService.handleUpdateMyProfile(_source, profile).catch((e) =>
|
||||
matchLogger.error(`Error occurred in updateMyProfile event (${_source}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
|
||||
onNet(MatchEvents.SAVE_LIKES, (likes: Like[]) => {
|
||||
const _source = getSource();
|
||||
MatchService.handleSaveLikes(_source, likes).catch((e) =>
|
||||
matchLogger.error(`Error occurred in saveLikes event (${_source}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
|
||||
onNet(MatchEvents.GET_MATCHES, () => {
|
||||
const _source = getSource();
|
||||
MatchService.handleGetMatches(_source).catch((e) =>
|
||||
matchLogger.error(`Error occurred in getMatches event (${_source}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
|
||||
if (!config.match.allowEditableProfileName && !config.match.generateProfileNameFromUsers) {
|
||||
const warning =
|
||||
`Both allowEdtiableProfileName and generateProfileNameFromUsers ` +
|
||||
`are set false - this means users will likely not have profile names ` +
|
||||
`for the Match App and won't be able to use it!`;
|
||||
matchLogger.warn(warning);
|
||||
}
|
||||
Reference in new issue
Block a user