Hello,

I'll upload a patch to provide the group feature to the content moderation notifications.

It's entirely optional and doesn't alter the module functionality.

When you create a new notification entity, a new checkbox is available if the group module is avalaible in your project to use the group support.

CommentFileSizeAuthor
#50 3015276-48.patch15.19 KBnaveenvalecha
#47 46-47-interdiff.txt179 bytesstella
#47 3015276-47.patch15.04 KBstella
#46 3015276-46.patch15.04 KBstella
#44 42-44-interdiff.txt590 byteseleonel
#44 3015276-44.patch15.16 KBeleonel
#42 content_moderation_notifications-group_support-3015275-42.patch15.16 KBjosh.fabean
#41 interdiff-3015275-40-41.txt872 bytesgrimreaper
#41 content_moderation_notifications-group_support-3015275-41.patch16.17 KBgrimreaper
#40 interdiff-3015275-37-40.txt1.32 KBgrimreaper
#40 content_moderation_notifications-group_support-3015275-40.patch16.04 KBgrimreaper
#37 interdiff-3015275-35-37.txt605 bytesgrimreaper
#37 content_moderation_notifications-group_support-3015275-37.patch15.96 KBgrimreaper
#35 content_moderation_notifications-3015275-35.patch15.16 KBr-mo
#34 interdiff-32-34.txt5.62 KBsergiuteaca
#34 content_moderation_notifications-3015276-34.patch14.85 KBsergiuteaca
#32 3015276-32.patch11.98 KBheddn
#32 interdiff_31-32.txt759 bytesheddn
#31 interdiff_30-31.txt9.12 KBheddn
#31 3015276-31.patch12.58 KBheddn
#30 interdiff_29-30.txt6.2 KBheddn
#30 3015276-30.patch13.3 KBheddn
#29 interdiff_28-29.txt2.61 KBheddn
#29 3015276-29.patch13.11 KBheddn
#28 3015276-28.patch12.97 KBheddn
#26 20190704_content_moderation_notifications_filter_group.patch26 KBdgaspara
#25 content_moderation_notification_group.patch8.34 KBdgaspara
#23 content_moderation_notifications-group_entity_support-3015276-23-rc2.patch16.02 KBgrimreaper
#21 content_moderation_notifications-group_entity_support-3015276-20-rc2.patch16.28 KBPiegefull
#19 content_moderation_notifications-group_entity_support-3015276-19.patch15.46 KBPiegefull
#18 content_moderation_notifications-group_entity_support-3015276-18-rc2.patch15.46 KBPiegefull
#16 content_moderation_notifications-group_entity_support-3015276-13-3.x.patch14.47 KBPiegefull
#15 content_moderation_notifications-group_entity_support-3015276-12-3.0-rc2.patch14.09 KBPiegefull
#13 content_moderation_notifications-group_entity_support-3015276-11-3.x.patch14.42 KBPiegefull
#12 content_moderation_notifications-group_entity_support-3015276-10-3.0-rc2.patch14.05 KBPiegefull
#9 content_moderation_notifications-group_entity_support-3015276-9-3.0-rc2.patch13.81 KBPiegefull
#8 content_moderation_notifications-group_entity_support-3015276-8-3.x.patch14.19 KBPiegefull
#7 content_moderation_notifications-group_entity_support-3015276-6.patch13.6 KBPiegefull
#4 content_moderation_notifications-group_entity_support-3015276-4.patch13.24 KBPiegefull
#2 content_moderation_notifications-group_entity_support-3015276-2.patch15.78 KBPiegefull
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Piegefull created an issue. See original summary.

Piegefull’s picture

Status: Active » Needs review
StatusFileSize
new15.78 KB
Piegefull’s picture

Version: 8.x-3.0-rc2 » 8.x-3.x-dev
Piegefull’s picture

Status: Needs review » Needs work

The last submitted patch, 4: content_moderation_notifications-group_entity_support-3015276-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

anruether’s picture

Thanks a lot for starting this! The patch works for me, although I would expect that it is possible to add only one notification for all groups of a specified group type and not only for a single group. At least this is our use case...
The help text "Select which Group Role triggers this notification." under Group Role is misleading, shouldn't it mean "Send notifications to all users with these roles."?

Piegefull’s picture

A patch for the 8.x-3.0-rc2

@anruether Thanks for the feedback, Thats a good ideas to select a group type or for a selected group type an group entity.

If i got more time i'll try to implement this.

Piegefull’s picture

Status: Needs work » Needs review
StatusFileSize
new14.19 KB

Update the group schema to a UUID from a ID.

Fix the codding standards and fix the module_handler service injection in the ContentModerationNotificationTest

Update the B.O. string with anruether suggestion

Piegefull’s picture

Same patch for 8.x-3.0-rc2

Status: Needs review » Needs work
Piegefull’s picture

Piegefull’s picture

Fix a fatal error when selecting a group with fixed UUID.

Patch for 8.x-3.0-rc2

Piegefull’s picture

Status: Needs work » Needs review
StatusFileSize
new14.42 KB

Same patch for 8.x-3.x-dev

Status: Needs review » Needs work
Piegefull’s picture

Piegefull’s picture

Same patch for 8.x-3.x-dev

Piegefull’s picture

Status: Needs work » Needs review
Piegefull’s picture

Add the group entity context in the Notification message for token.

Patch for the 8.x-3.0-rc2 version

Piegefull’s picture

Status: Needs review » Needs work
Piegefull’s picture

Late update after feedback on the mail sending for each user of the selected group.

grimreaper’s picture

+++ b/src/Notification.php
@@ -140,12 +140,73 @@ class Notification implements NotificationInterface {
+            break;

Hello,

It should be a continue here and not a break. Because with the break, on the first group where the content is not related to, it will stop the notifications.

I will update your patch for that.

grimreaper’s picture

grimreaper’s picture

+++ b/src/Notification.php
@@ -140,6 +140,65 @@ class Notification implements NotificationInterface {
+          foreach ($group->getContentEntities() as $group_entity) {

Instead of looping on the entities of the group, I think it will be better to use group/src/Entity/Storage/GroupContentStorageInterface.php loadByEntity method. to get the group in which the entity belongs. And this calculation can be done outside the "foreach ($notifications as $notification) {" loop.

dgaspara’s picture

Issue tags: +Needs tests, +Needs work
StatusFileSize
new8.34 KB

Patch to add group entity support to Content Moderation Notifications module and allows group roles configuration.

dgaspara’s picture

StatusFileSize
new26 KB

Patch to add group entity support to Content Moderation Notifications module and allows group roles configuration with some updates.

heddn’s picture

Status: Needs work » Needs review
Issue tags: -
heddn’s picture

Here's a straight re-roll of #23. Not sure where #25-26 are going, but there seems to be a lot of mention of a custom module embedded in those patches. So, let's switch back to #23.

heddn’s picture

StatusFileSize
new13.11 KB
new2.61 KB

Without any groups created, the notification add page WSOD. Here's a minor fix of that.

heddn’s picture

StatusFileSize
new13.3 KB
new6.2 KB

I don't like I have to pick specific groups for notifications. I'd much prefer to pick a role for all groups of a certain type. Say I've got a Department group content type. Then all editor role members of the department group should be notified on configured transitions.

To that end, I'm going to scratch that itch and throw up a patch with that solution.

Still needs automated tests.

heddn’s picture

StatusFileSize
new12.58 KB
new9.12 KB
heddn’s picture

StatusFileSize
new759 bytes
new11.98 KB

Removing out of scope changes. The remaining failing tests are the same as the ones identified in #3097199: Tests are failing against latest core. This is ready for review.

jhedstrom’s picture

Can this be done in a separate module via 3rd party settings and the alter hook provided by this module (hook_content_moderation_notification_mail_data_alter)?

sergiuteaca’s picture

StatusFileSize
new14.85 KB
new5.62 KB

When adding a new node to the group the sendNotification comes before the content is attached to the group.
Adding another option to find the $group from context provider

r-mo’s picture

Last patch gives an error on site-install

TypeError: Argument 7 passed to Drupal\content_moderation_notifications\Notification::__construct() must be an instance of Drupal\Core\Plugin\Context\ContextProviderInterface, null given

Adding null as default, along with some coding standards fixes.

josh.fabean’s picture

Just tried this patch and it appears to work as expected, due to scheme changes I had to reinstall the module to get it to save the settings but it's all working! Thanks for your work on this.

grimreaper’s picture

Hello,

I am currently updating a lot of contrib on the project we initially have created this issue with @Piegefull.

Thanks everyone for pushing it forward.

I am still stuck on group 8.x-1.0-rc2 but regarding the date of comment 35 this should not be a problem.

I have applied patch from comment 35 and I have a fatal error when the content is not in a group.

So here is an updated patch that add an if statement to check that a group entity i loaded.

I will pursue the tests.

grimreaper’s picture

Also regarding #3078110: Notification emails should not send to blocked users, is a similar check on user status should be done in setGroupData()?

grimreaper’s picture

Ok, I just realized two things:

Comment 30:

I don't like I have to pick specific groups for notifications. I'd much prefer to pick a role for all groups of a certain type.

It depends of use cases. For the original use case of this issue, we had to configure notifications depending on specific roles for specific groups.

I am still testing if this new approach is incompatible with our use case.

Comment 33:

Can this be done in a separate module via 3rd party settings and the alter hook provided by this module (hook_content_moderation_notification_mail_data_alter)?

If this can avoid to have to maintain a patch and have the issue done, YES! But @jhedstrom, do you mean a sub-module into this project or a complete dedicated project?

grimreaper’s picture

Ok the new approach is working on my project too. I just had to block a lot of users and disable a lot of notifications to have my manual test isolated.

So updating the patch regarding my comment 38 on blocked users.

Also catched an unused variable. I think it was a copy paste error to ensure a variable is still initialized.

grimreaper’s picture

I changed the config form a little to bit to exclude all internal roles except the member role.

As anonymous role is already excluded, as outsiders are not gathered when loading group members (by definition), and as the other roles created for each standard user roles are internal, it is not possible to give those rules in the UI so I think it gives a confusing config form otherwise.

josh.fabean’s picture

Re rolled patch on #41 to work with the latest dev.

caesius’s picture

The last few patches use 3015275 as the node ID in the filename. The issue node ID is actually 3015276 (I had to Google to find this issue).

eleonel’s picture

StatusFileSize
new15.16 KB
new590 bytes

Patch re-rolled.

stella’s picture

Status: Needs review » Needs work

I get the following error on the settings page with latest version of the module and Drupal 9.5.9

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\group\Entity\GroupRole::isInternal() in Drupal\content_moderation_notifications\Form\ContentModerationNotificationsFormBase::Drupal\content_moderation_notifications\Form\{closure}() (line 248 of modules/contrib/content_moderation_notifications/src/Form/ContentModerationNotificationsFormBase.php).

If I remove the check for isInternal() introduced in #41, then the page loads. However, it still has no group roles appearing on the form as a result of the rest of the change in #41 as I have no "member" role. I have editor and other roles, and none called "member", so I think that change is too restrictive and doesn't work for every scenario.

stella’s picture

Status: Needs work » Needs review
StatusFileSize
new15.04 KB

Updated version of the patch with the change from #41 rolled back.

stella’s picture

StatusFileSize
new15.04 KB
new179 bytes

When testing the actual sending of the notifications I got this error:

The website encountered an unexpected error. Please try again later.

Drupal\Core\Entity\EntityStorageException: The "group_content" entity type does not exist. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Drupal\Core\Entity\EntityTypeManager->getHandler('group_content', 'storage') (Line: 192)
Drupal\Core\Entity\EntityTypeManager->getStorage('group_content') (Line: 205)
Drupal\content_moderation_notifications\Notification->sendNotification(Object, Array) (Line: 100)
Drupal\content_moderation_notifications\Notification->processEntity(Object) (Line: 36)
content_moderation_notifications_entity_insert(Object)
call_user_func_array(Object, Array) (Line: 426)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'content_moderation_notifications') (Line: 405)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_insert', Object) (Line: 433)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_insert', Array) (Line: 251)
Drupal\Core\Entity\EntityStorageBase->invokeHook('insert', Object) (Line: 903)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('insert', Object) (Line: 598)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, ) (Line: 784)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, ) (Line: 523)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 804)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 270)
Drupal\node\NodeForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 595)
Drupal\Core\Form\FormBuilder->processForm('node_blog_form', Array, Object) (Line: 323)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'default', Array) (Line: 391)
Drupal\group\Entity\Controller\GroupRelationshipController->createForm(Object, 'group_node:blog')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

This because the "group_content" entity has since been renamed to "group_relationship".

Updated patch attached for that one change.

naveenvalecha made their first commit to this issue’s fork.

naveenvalecha’s picture

StatusFileSize
new15.19 KB

Here's the patch against the 8.x-3.7 version
The PR is opened for review

vistree’s picture

@naveenvalecha,
after using your latest patch #50 I get an error on editiong and creating new group notifications:
Error: Call to undefined method Drupal\group\Entity\GroupRole::isInternal()
The full message is:

The website encountered an unexpected error. Try again later.

Error: Call to undefined method Drupal\group\Entity\GroupRole::isInternal() in Drupal\content_moderation_notifications\Form\ContentModerationNotificationsFormBase::Drupal\content_moderation_notifications\Form\{closure}() (line 251 of modules/contrib/content_moderation_notifications/src/Form/ContentModerationNotificationsFormBase.php).
array_filter() (Line: 252)
Drupal\content_moderation_notifications\Form\ContentModerationNotificationsFormBase->buildForm()
call_user_func_array() (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 97)
Drupal\autosave_form\Form\AutosaveFormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)
skyredwang’s picture

Following the suggestion from #33,

I turned the patch into a module: Group Content Moderation Notifications and with these additional changes:

  • Added the subgroup support
  • Replaced Group 1.x API usage with 2.x/3.x usage
bkosborne’s picture

Status: Needs review » Closed (won't fix)

Thank you for turning this feature into a contrib module.

This module is already pretty bloated with the number of options it presents users on who to notify. This would bloat it further. It's a slippery slope adding support for other contrib solutions in here. At some point it makes more sense to use a module like ECA which probably provides the flexibility needed, or use the new contrib module created in #52. I'm conflicted closing this because it's clear a lot of people want this functionality, but at the same time no maintainer has committed the work in many years and no tests have been added.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

vistree’s picture

Patch from #50 does not apply to current 8.x-3.8 version. Should we provide a new patch or is it better to use the new submoudle provided in #52?