Skip to content

Commit 6ae6689

Browse files
Removed broken tide_event webform email handler (#635)
* Removed broken tide_event webform email handler * Added update hook to remove tide_event_submission webform handler if its sending to that dead default email address * Only adjust the specific email handler --------- Co-authored-by: Vincent Gao <vincent.gao@dpc.vic.gov.au>
1 parent bd0a8a7 commit 6ae6689

File tree

2 files changed

+50
-35
lines changed

2 files changed

+50
-35
lines changed

modules/tide_event/config/install/webform.webform.tide_event_submission.yml

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -276,38 +276,4 @@ access:
276276
- authenticated
277277
users: { }
278278
permissions: { }
279-
handlers:
280-
event_submission_email:
281-
id: email
282-
label: 'Event Submission Email'
283-
handler_id: event_submission_email
284-
status: true
285-
conditions: { }
286-
weight: 0
287-
settings:
288-
states:
289-
- completed
290-
to_mail: contact.dpc@dsdbi.desk-mail.com
291-
to_options: { }
292-
cc_mail: ''
293-
cc_options: { }
294-
bcc_mail: ''
295-
bcc_options: { }
296-
from_mail: contact.dpc@dsdbi.desk-mail.com
297-
from_options: { }
298-
from_name: _default
299-
subject: 'Event Submission'
300-
body: _default
301-
excluded_elements:
302-
agree_privacy_statement: agree_privacy_statement
303-
ignore_access: false
304-
exclude_empty: true
305-
exclude_empty_checkbox: true
306-
html: true
307-
attachments: false
308-
twig: false
309-
debug: false
310-
reply_to: ''
311-
return_path: ''
312-
sender_mail: ''
313-
sender_name: ''
279+
handlers: { }

modules/tide_event/tide_event.install

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,52 @@ function tide_event_update_10002() {
106106
])
107107
->save();
108108
}
109+
110+
/**
111+
* Remove outdated email handler from tide_event_submission webform.
112+
*/
113+
function tide_event_update_10003() {
114+
$webform_id = 'tide_event_submission';
115+
116+
// Load the webform entity.
117+
$webform = \Drupal::entityTypeManager()
118+
->getStorage('webform')
119+
->load($webform_id);
120+
121+
if (!$webform) {
122+
return \Drupal::translation()->translate('Webform @id not found.', ['@id' => $webform_id]);
123+
}
124+
125+
// Get the handlers.
126+
$handlers = $webform->getHandlers();
127+
$updated = FALSE;
128+
129+
// Go through each handler.
130+
foreach ($handlers as $handler_id => $handler) {
131+
if ($handler_id == 'event_submission_email') {
132+
$configuration = $handler->getConfiguration();
133+
134+
// Check if this is an email handler with the specific to_mail address.
135+
if (isset($configuration['settings']['to_mail']) &&
136+
$configuration['settings']['to_mail'] === 'contact.dpc@dsdbi.desk-mail.com') {
137+
// Delete this handler.
138+
$webform->deleteWebformHandler($handler_id);
139+
$updated = TRUE;
140+
}
141+
}
142+
}
143+
144+
if ($updated) {
145+
// Save the updated webform.
146+
$webform->save();
147+
return \Drupal::translation()->translate(
148+
'Removed outdated email handler from @webform webform.',
149+
['@webform' => $webform_id]
150+
);
151+
}
152+
153+
return \Drupal::translation()->translate(
154+
'No handlers with the specified email address were found in @webform webform.',
155+
['@webform' => $webform_id]
156+
);
157+
}

0 commit comments

Comments
 (0)