Instagram jobs refactor + started InstagramNotifications

This commit is contained in:
2025-08-05 13:25:25 +02:00
parent 1f23b112d7
commit aa936a2a11
9 changed files with 444 additions and 86 deletions

View File

@ -0,0 +1,37 @@
<?php
namespace App\Services\Instagram;
use App\Models\InstagramNotificationType;
use Facebook\WebDriver\Remote\RemoteWebElement;
class NotificationTypeDetector
{
/**
* Detects the Instagram notification type from the DOM.
*
* @param string $descriptionText The text content of the notification description.
* @return InstagramNotificationType
*/
public static function detectType(string $descriptionText): InstagramNotificationType
{
$descriptionText = trim($descriptionText); // Remove leading/trailing whitespace
// Prioritize exact matches for reliability
if (strpos($descriptionText, 'liked') !== false) {
return InstagramNotificationType::LIKE;
} elseif (strpos($descriptionText, 'commented') !== false) {
return InstagramNotificationType::COMMENT;
} elseif (strpos($descriptionText, 'following you') !== false) {
return InstagramNotificationType::FOLLOW;
} elseif (strpos($descriptionText, 'message') !== false) {
return InstagramNotificationType::MESSAGE;
} elseif (strpos($descriptionText, 'congratulations') !== false || strpos($descriptionText, 'update') !== false) {
return InstagramNotificationType::SYSTEM;
} elseif (strpos($descriptionText, 'mention') !== false) {
return InstagramNotificationType::MENTION;
}
return InstagramNotificationType::OTHER;
}
}