Fix mentions in front-end + email spam
This commit is contained in:
parent
dad5c825b1
commit
97c4b9db5b
|
|
@ -127,14 +127,23 @@ class FormEmailNotification extends Notification implements ShouldQueue
|
||||||
$formId = $this->event->form->id;
|
$formId = $this->event->form->id;
|
||||||
$submissionId = $this->event->data['submission_id'] ?? 'unknown';
|
$submissionId = $this->event->data['submission_id'] ?? 'unknown';
|
||||||
$domain = Str::after(config('app.url'), '://');
|
$domain = Str::after(config('app.url'), '://');
|
||||||
|
$timestamp = time();
|
||||||
|
|
||||||
$uniquePart = substr(md5($formId . $submissionId), 0, 8);
|
// Create a unique Message-ID for each submission
|
||||||
$messageId = "form-{$formId}-{$uniquePart}@{$domain}";
|
$messageId = "<form-{$formId}-submission-{$submissionId}-{$timestamp}@{$domain}>";
|
||||||
$references = "form-{$formId}@{$domain}";
|
|
||||||
|
|
||||||
$message->getHeaders()->remove('Message-ID');
|
// Create a References header that links to the form, but not to specific submissions
|
||||||
$message->getHeaders()->addIdHeader('Message-ID', $messageId);
|
$references = "<form-{$formId}@{$domain}>";
|
||||||
|
|
||||||
|
// Add our custom Message-ID as X-Custom-Message-ID
|
||||||
|
$message->getHeaders()->addTextHeader('X-Custom-Message-ID', $messageId);
|
||||||
|
|
||||||
|
// Add References header
|
||||||
$message->getHeaders()->addTextHeader('References', $references);
|
$message->getHeaders()->addTextHeader('References', $references);
|
||||||
|
|
||||||
|
// Add a unique Thread-Index to further prevent grouping
|
||||||
|
$threadIndex = base64_encode(pack('H*', md5($formId . $submissionId . $timestamp)));
|
||||||
|
$message->getHeaders()->addTextHeader('Thread-Index', $threadIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getMailData(): array
|
private function getMailData(): array
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export function useParseMention(content, mentionsAllowed, form, formData) {
|
||||||
const doc = parser.parseFromString(content, 'text/html')
|
const doc = parser.parseFromString(content, 'text/html')
|
||||||
|
|
||||||
// Find all elements with mention attribute
|
// Find all elements with mention attribute
|
||||||
const mentionElements = doc.querySelectorAll('[mention]')
|
const mentionElements = doc.querySelectorAll('[mention], [mention=""]')
|
||||||
|
|
||||||
mentionElements.forEach(element => {
|
mentionElements.forEach(element => {
|
||||||
const fieldId = element.getAttribute('mention-field-id')
|
const fieldId = element.getAttribute('mention-field-id')
|
||||||
|
|
@ -36,4 +36,4 @@ export function useParseMention(content, mentionsAllowed, form, formData) {
|
||||||
|
|
||||||
// Return the processed HTML content
|
// Return the processed HTML content
|
||||||
return doc.body.innerHTML
|
return doc.body.innerHTML
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ export default function registerMentionExtension(Quill) {
|
||||||
node.setAttribute('mention', 'true')
|
node.setAttribute('mention', 'true')
|
||||||
|
|
||||||
if (data && typeof data === 'object') {
|
if (data && typeof data === 'object') {
|
||||||
node.setAttribute('mention-field-id', data.field?.nf_id || '')
|
node.setAttribute('mention-field-id', data.field?.id || '')
|
||||||
node.setAttribute('mention-field-name', data.field?.name || '')
|
node.setAttribute('mention-field-name', data.field?.name || '')
|
||||||
node.setAttribute('mention-fallback', data.fallback || '')
|
node.setAttribute('mention-fallback', data.fallback || '')
|
||||||
node.textContent = data.field?.name || ''
|
node.textContent = data.field?.name || ''
|
||||||
|
|
@ -53,7 +53,7 @@ export default function registerMentionExtension(Quill) {
|
||||||
static value(domNode) {
|
static value(domNode) {
|
||||||
return {
|
return {
|
||||||
field: {
|
field: {
|
||||||
nf_id: domNode.getAttribute('mention-field-id') || '',
|
id: domNode.getAttribute('mention-field-id') || '',
|
||||||
name: domNode.getAttribute('mention-field-name') || ''
|
name: domNode.getAttribute('mention-field-name') || ''
|
||||||
},
|
},
|
||||||
fallback: domNode.getAttribute('mention-fallback') || ''
|
fallback: domNode.getAttribute('mention-fallback') || ''
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue