@@ -156,7 +156,7 @@ public function sendDigitalPost(WebformSubmissionInterface $submission, array $h
156156 $ recipientIdentifierType = 'CPR ' ;
157157 }
158158
159- $ this -> digitalPostSubscriber -> setDigitalPostContext ( $ submission , $ lookupResult );
159+
160160
161161 $ senderSettings = $ this ->settings ->getSender ();
162162 $ messageOptions = [
@@ -169,7 +169,13 @@ public function sendDigitalPost(WebformSubmissionInterface $submission, array $h
169169 WebformHandlerSF1601::SENDER_LABEL => $ handlerMessageSettings [WebformHandlerSF1601::SENDER_LABEL ],
170170 WebformHandlerSF1601::MESSAGE_HEADER_LABEL => $ handlerMessageSettings [WebformHandlerSF1601::MESSAGE_HEADER_LABEL ],
171171 ];
172+
173+ // Set flag indicating digital post context.
174+ $ this ->digitalPostSubscriber ->setDigitalPostContext ($ submission , $ lookupResult );
172175 $ message = $ this ->meMoHelper ->buildWebformSubmissionMessage ($ submission , $ messageOptions , $ handlerSettings , $ lookupResult );
176+ // Remove flag.
177+ $ this ->digitalPostSubscriber ->deleteDigitalPostContext ($ submission );
178+
173179 $ forsendelseOptions = [
174180 self ::RECIPIENT_IDENTIFIER_TYPE => $ recipientIdentifierType ,
175181 self ::RECIPIENT_IDENTIFIER => $ recipientIdentifier ,
@@ -181,7 +187,12 @@ public function sendDigitalPost(WebformSubmissionInterface $submission, array $h
181187 WebformHandlerSF1601::SENDER_LABEL => $ handlerMessageSettings [WebformHandlerSF1601::SENDER_LABEL ],
182188 WebformHandlerSF1601::MESSAGE_HEADER_LABEL => $ handlerMessageSettings [WebformHandlerSF1601::MESSAGE_HEADER_LABEL ],
183189 ];
190+
191+ // Set flag indicating digital post context.
192+ $ this ->digitalPostSubscriber ->setDigitalPostContext ($ submission , $ lookupResult );
184193 $ forsendelse = $ this ->forsendelseHelper ->buildSubmissionForsendelse ($ submission , $ forsendelseOptions , $ handlerSettings , $ lookupResult );
194+ // Remove flag.
195+ $ this ->digitalPostSubscriber ->deleteDigitalPostContext ($ submission );
185196
186197 $ type = $ handlerMessageSettings [WebformHandlerSF1601::TYPE ] ?? SF1601 ::TYPE_DIGITAL_POST ;
187198
0 commit comments