Step 6: Pest integration tests for webhook ingestion and background job
This commit is contained in:
@@ -107,10 +107,16 @@ class ProcessIncomingEmail implements ShouldQueue
|
||||
}
|
||||
|
||||
if (! empty($bodyHtml)) {
|
||||
$stripped = strip_tags($bodyHtml);
|
||||
$stripped = preg_replace('/\s+/', ' ', $stripped);
|
||||
// Replace all HTML tags with spaces to prevent words from running together
|
||||
$html = preg_replace('/<[^>]*>/', ' ', $bodyHtml);
|
||||
|
||||
return mb_substr(trim($stripped), 0, 500);
|
||||
// Decode HTML entities (e.g. , &)
|
||||
$decoded = html_entity_decode($html ?? '', ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
|
||||
// Collapse multiple spaces into a single space
|
||||
$stripped = preg_replace('/\s+/', ' ', $decoded);
|
||||
|
||||
return mb_substr(trim($stripped ?? ''), 0, 500);
|
||||
}
|
||||
|
||||
return '';
|
||||
@@ -126,12 +132,13 @@ class ProcessIncomingEmail implements ShouldQueue
|
||||
Cache::rememberForever('mongodb_ttl_index_ensured', function () {
|
||||
$ttlSeconds = config('services.mailops.email_body_ttl_seconds', 259200);
|
||||
|
||||
/** @var Collection $collection */
|
||||
$collection = (new EmailBody)->getCollection();
|
||||
$collection->createIndex(
|
||||
['created_at' => 1],
|
||||
['expireAfterSeconds' => $ttlSeconds, 'name' => 'ttl_created_at']
|
||||
);
|
||||
EmailBody::raw(function ($collection) use ($ttlSeconds) {
|
||||
/* @var \MongoDB\Collection $collection */
|
||||
$collection->createIndex(
|
||||
['created_at' => 1],
|
||||
['expireAfterSeconds' => $ttlSeconds, 'name' => 'ttl_created_at']
|
||||
);
|
||||
});
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user