File tree Expand file tree Collapse file tree 2 files changed +12
-13
lines changed Expand file tree Collapse file tree 2 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -123,10 +123,12 @@ public function actionAddComment(string $id) {
123
123
$ this ->comments ->flush ();
124
124
125
125
// send email to all participants in comment thread
126
- if ($ solution = $ this ->assignmentSolutions ->get ($ id )) {
127
- $ this ->solutionCommentsEmailsSender ->assignmentSolutionComment ($ solution , $ comment );
128
- } else if ($ solution = $ this ->referenceExerciseSolutions ->get ($ id )) {
129
- $ this ->solutionCommentsEmailsSender ->referenceSolutionComment ($ solution , $ comment );
126
+ $ assignmentSolution = $ this ->assignmentSolutions ->get ($ id );
127
+ $ referenceSolution = $ this ->referenceExerciseSolutions ->get ($ id );
128
+ if ($ assignmentSolution ) {
129
+ $ this ->solutionCommentsEmailsSender ->assignmentSolutionComment ($ assignmentSolution , $ comment );
130
+ } else if ($ referenceSolution ) {
131
+ $ this ->solutionCommentsEmailsSender ->referenceSolutionComment ($ referenceSolution , $ comment );
130
132
} else {
131
133
// Nothing to do here...
132
134
}
Original file line number Diff line number Diff line change @@ -49,22 +49,19 @@ private function sendSolutionComment($solution, Comment $comment): bool {
49
49
50
50
$ baseSolution = $ solution ->getSolution ();
51
51
$ subject = $ this ->assignmentSolutionCommentPrefix . $ baseSolution ->getAuthor ()->getName ();
52
- $ recipients = [$ baseSolution ->getAuthor ()->getEmail ()];
52
+
53
+ $ recipients = [];
54
+ $ recipients [$ baseSolution ->getAuthor ()->getEmail ()] = $ baseSolution ->getAuthor ();
53
55
foreach ($ comment ->getThread ()->findAllPublic () as $ pComment ) {
54
56
$ user = $ pComment ->getUser ();
55
57
if (!$ user ->getSettings ()->getSolutionCommentsEmails ()) {
56
58
continue ;
57
59
}
58
- $ recipients [] = $ user ->getEmail ();
60
+ $ recipients [$ user ->getEmail ()] = $ user ;
59
61
}
60
62
61
- // make user emails unique, so the emails won't be multiplied
62
- $ recipients = array_unique ($ recipients );
63
-
64
63
// filter out the author of the comment, it is pointless to send email to that user
65
- $ recipients = array_filter ($ recipients , function (string $ email ) use ($ comment ) {
66
- return $ email !== $ comment ->getUser ()->getEmail ();
67
- });
64
+ unset($ recipients [$ comment ->getUser ()->getEmail ()]);
68
65
69
66
if (count ($ recipients ) === 0 ) {
70
67
return true ;
@@ -82,7 +79,7 @@ private function sendSolutionComment($solution, Comment $comment): bool {
82
79
[],
83
80
$ subject ,
84
81
$ body ,
85
- $ recipients
82
+ array_keys ( $ recipients)
86
83
);
87
84
}
88
85
You can’t perform that action at this time.
0 commit comments