@@ -83,8 +83,12 @@ public static function addQuestionOwnerToCommentSubscribers(\Elgg\Hook $hook) {
83
83
84
84
/* @var $owner \ElggUser */
85
85
$ owner = $ question ->getOwnerEntity ();
86
+ if ($ object ->owner_guid === $ owner ->guid ) {
87
+ // don't add question owner if it's the comment owner
88
+ return ;
89
+ }
86
90
87
- $ filtered_methods = array_keys (array_filter ($ owner ->getNotificationSettings ()));
91
+ $ filtered_methods = array_keys (array_filter ($ owner ->getNotificationSettings (' create_comment ' )));
88
92
if (empty ($ filtered_methods )) {
89
93
return ;
90
94
}
@@ -109,17 +113,17 @@ public static function addQuestionSubscribersToCommentSubscribers(\Elgg\Hook $ho
109
113
return ;
110
114
}
111
115
112
- $ object = $ event ->getObject ();
113
- if (!$ object instanceof \ElggComment) {
116
+ $ comment = $ event ->getObject ();
117
+ if (!$ comment instanceof \ElggComment) {
114
118
return ;
115
119
}
116
120
117
- $ container = $ object ->getContainerEntity ();
118
- if (!$ container instanceof \ElggAnswer) {
121
+ $ answer = $ comment ->getContainerEntity ();
122
+ if (!$ answer instanceof \ElggAnswer) {
119
123
return ;
120
124
}
121
125
122
- $ question = $ container ->getContainerEntity ();
126
+ $ question = $ answer ->getContainerEntity ();
123
127
if (!$ question instanceof \ElggQuestion) {
124
128
// something went wrong, maybe access
125
129
return ;
@@ -130,6 +134,11 @@ public static function addQuestionSubscribersToCommentSubscribers(\Elgg\Hook $ho
130
134
return ;
131
135
}
132
136
137
+ if (isset ($ subscribers [$ comment ->owner_guid ])) {
138
+ // remove the comment owner from the subscribers
139
+ unset($ subscribers [$ comment ->owner_guid ]);
140
+ }
141
+
133
142
return ($ hook ->getValue () + $ subscribers );
134
143
}
135
144
}
0 commit comments