File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
web/profiles/custom/os2loop/modules/os2loop_messages/src/Helper Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -69,8 +69,10 @@ public function entityUpdate(EntityInterface $entity) {
6969 private function createMessage (EntityInterface $ entity , string $ operation ) {
7070 $ template = $ this ->getMessageTemplate ($ entity , $ operation );
7171 if (NULL !== $ template ) {
72+ $ node = NULL ;
7273 $ message = Message::create (['template ' => $ template ]);
7374 if ($ entity instanceof NodeInterface) {
75+ $ node = $ entity ;
7476 if ($ entity ->hasField ('os2loop_notify_users ' ) && !(bool ) $ entity ->get ('os2loop_notify_users ' )->getString ()) {
7577 return ;
7678 }
@@ -85,7 +87,11 @@ private function createMessage(EntityInterface $entity, string $operation) {
8587 $ message ->set ('os2loop_message_node_refer ' , $ node );
8688 $ message ->set ('os2loop_message_comment_refer ' , $ entity );
8789 }
88- $ message ->save ();
90+
91+ // Only save message on published content.
92+ if ($ node instanceof NodeInterface && $ node ->isPublished ()) {
93+ $ message ->save ();
94+ }
8995 }
9096 }
9197
You can’t perform that action at this time.
0 commit comments