fix: improve match notification handling and embed display
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user