Permalink
Browse files

fix(notifications): default settings now get enabled also for new fri…

…ends

Handler that is supposed to enable default notification methods for new
friends was using the obsolete [create, friend] event, so the methods
never got enabled. This fixes the handler registration to use the correct
[create, relationship] event instead.
  • Loading branch information...
juho-jaakkola committed Dec 25, 2015
1 parent 99b6afb commit e84fc160b99a66816f70674e497acabfdd73a4bb
Showing with 7 additions and 1 deletion.
  1. +7 −1 mod/notifications/start.php
@@ -24,7 +24,7 @@ function notifications_plugin_init() {
elgg_register_event_handler('delete', 'friend', 'notifications_relationship_remove');
// update notifications when new friend or access collection membership
- elgg_register_event_handler('create', 'friend', 'notifications_update_friend_notify');
+ elgg_register_event_handler('create', 'relationship', 'notifications_update_friend_notify');
elgg_register_plugin_hook_handler('access:collections:add_user', 'collection', 'notifications_update_collection_notify');
$actions_base = __DIR__ . '/actions';
@@ -126,6 +126,12 @@ function notifications_relationship_remove($event, $object_type, $relationship)
* @param object $relationship
*/
function notifications_update_friend_notify($event, $object_type, $relationship) {
+ // The handler gets triggered regardless of which relationship was
+ // created, so proceed only if dealing with a 'friend' relationship.
+ if ($relationship->relationship != 'friend') {
+ return true;
+ }
+
$NOTIFICATION_HANDLERS = _elgg_services()->notifications->getMethodsAsDeprecatedGlobal();
$user_guid = $relationship->guid_one;

0 comments on commit e84fc16

Please sign in to comment.