ip
This commit is contained in:
+33
-1
@@ -10,9 +10,41 @@ $input = json_decode(file_get_contents('php://input'), true) ?: $_POST;
|
||||
$message_id = $input['message_id'] ?? null;
|
||||
$emoji = $input['emoji'] ?? null;
|
||||
|
||||
// Normalize emoji aliases and decode any HTML entities
|
||||
function normalize_emoji($s) {
|
||||
if (!$s) return $s;
|
||||
$orig = $s;
|
||||
$s = html_entity_decode($s, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
$s_trim = trim(mb_strtolower($s, 'UTF-8'));
|
||||
$map = [
|
||||
'corazon' => '❤️', 'heart' => '❤️', '<3' => '❤️',
|
||||
'like' => '👍', 'thumbsup' => '👍', 'thumbs_up' => '👍',
|
||||
'laugh' => '😂', 'risa' => '😂', 'joy' => '😂',
|
||||
'wow' => '😮', 'surprised' => '😮',
|
||||
'sad' => '😢', 'triste' => '😢',
|
||||
'clap' => '👏', 'applause' => '👏',
|
||||
'party' => '🎉', 'celebrate' => '🎉',
|
||||
'fire' => '🔥', 'pray' => '🙏'
|
||||
];
|
||||
|
||||
$key = preg_replace('/[^a-z0-9_\-]/u', '', $s_trim);
|
||||
if (isset($map[$key])) return $map[$key];
|
||||
|
||||
// If it already contains an emoji, extract the first emoji char
|
||||
if (preg_match('/[\x{1F300}-\x{1F6FF}\x{1F900}-\x{1F9FF}\x{2600}-\x{26FF}\x{2700}-\x{27BF}]/u', $s, $m)) {
|
||||
return $m[0];
|
||||
}
|
||||
|
||||
return trim($orig);
|
||||
}
|
||||
|
||||
$rawEmoji = $input['emoji'] ?? null;
|
||||
$emoji = normalize_emoji($emoji);
|
||||
error_log('react_message: received raw=' . ($rawEmoji ?? 'NULL') . ' normalized=' . ($emoji ?? 'NULL') . ' message_id=' . ($message_id ?? 'NULL'));
|
||||
|
||||
if (!$message_id || !$emoji) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['success' => false, 'error' => 'Parámetros faltantes: message_id, emoji']);
|
||||
echo json_encode(['success' => false, 'error' => 'Parámetros faltantes: message_id, emoji (después de normalizar)']);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user