fix: improve match notification handling and embed display

This commit is contained in:
VinceC
2024-11-29 04:34:55 -06:00
parent 3651537c1f
commit 426bdaceb7
2 changed files with 32 additions and 6 deletions

View File

@@ -117,11 +117,8 @@ class NotificationService {
}
validateMatchData(matchData) {
if (matchData.type !== 'match_request') {
return false;
}
const requiredFields = [
'type',
'game_name',
'game_id',
'created_by_user_id',
@@ -134,7 +131,27 @@ class NotificationService {
'match_class'
];
return requiredFields.every(field => matchData[field] !== undefined);
// Check if all required fields are present
const hasAllFields = requiredFields.every(field => {
const hasField = matchData.hasOwnProperty(field) && matchData[field] !== null && matchData[field] !== undefined;
if (!hasField) {
console.log(`Missing or null field: ${field}`);
}
return hasField;
});
if (!hasAllFields) {
return false;
}
// Validate team size format (should be a number or string containing a number)
const teamSize = matchData.team_size.toString().replace(/[^0-9]/g, '');
if (!teamSize || isNaN(teamSize) || teamSize < 1) {
console.log('Invalid team size format');
return false;
}
return true;
}
}