Closed (fixed)
Project:
Private Message
Version:
3.0.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
30 Jan 2019 at 11:53 UTC
Updated:
8 Mar 2022 at 16:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
gilmordComment #4
gilmordHi
notifications moved to a separate submodule.
Few things to pay attention to:
- not sure what to do with composer dependencies on message and message_notify modules - if we remove them users currently using this module may face issues;
- added update hook to enable a new submodule for all instances.
At some point, we will have to remove dependency from composer.json
Comment #5
ressinel@gilmord The hook
hook_private_message_notify_excludedoesn't work for me, excluded is always empty. I have created a patch from your PR with changes for the hook functionality.Comment #6
gilmordHi @Ressinel
So you added "return [1]" to the hook_private_message_notify_exclude and it started working, is that correct?
Patch has 500 lines, can you provide a diff so I can see your changes?
But if this is the only fix - looks like you use this hook the wrong way.
This hook should not return anything, it should modify the variable passed by reference, so you want something like this:
$exclude[] = $some_uid_to_exclude;
Also when you define a hook it should have $exclude argument as a reference.
I tried this scenario:
- implement hook_private_message_notify_exclude in custom module,
- add uids to the $exclude variable
- I can see the added uids in getNotificationRecipients where the hook is invoked
Comment #7
ressinelHi, @gilmord
I used the same scenario as you wrote, but UIDs added to $exclude argument as a reference (
$exclude[] = $some_uid_to_exclude;) do not pass togetNotificationRecipients().Apologize I didn't send the diff earlier. Check it, please:
Comment #8
gilmordHi again @Ressinel
You are right, nice catch!
$exclude was passed to a hooks in the wrong way. And $account->id() was missing, thanks for that also!
But I still want to keep it a as a reference:

Here is a commit:
https://git.drupalcode.org/project/private_message/-/merge_requests/31/d...
Can you please test if it works for you?
Thanks!
Comment #9
gilmordActually, I am not 100% sure if it should better be a return or variable passed by reference.
Reference allows to alter data, but maybe then the hook should be renamed to "_alter"?
Or we better have two hooks - one to collect excludes and one to alter?
Anyways solution with reference allows us to use it both as a collector and to alter the excludes.
Comment #10
ressinelHi, @gilmord
Yes, with the last changes hook works properly. Thanks!
But I think it would be nice to have the possibility of removing needed
$recipientsin hook directly instead of adding UIDs. It seems more logical to me.Comment #11
artem_sylchukI'd be happy to merge this but it is a breaking API update.
Let's try to switch the target branch to 3.x
Comment #13
artem_sylchukComment #14
artem_sylchukComment #15
navneet0693 commented@artem_sylchuk Thank you very much for the merge! This was one of the hot issues at Open Social. Is there any plan to release 3.0 branch?
Comment #16
artem_sylchuk@navneet0693 the first 3.x release was publised.
Comment #17
ressinelHi, @artem_sylchuk
Thanks for releasing these changes!
But we have faced another issue related to these changes. Take a look at this, please: https://www.drupal.org/project/private_message/issues/3265901