Skip to content

Commit

Permalink
MDL-65968 notifications: Use f1 size avatars for Push notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed Sep 17, 2019
1 parent 1c3efe4 commit dcadc8c
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions competency/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ function core_competency_comment_add($comment, $params) {
$message->contexturlname = $urlname;

$userpicture = new \user_picture($user);
$userpicture->size = 1; // Use f1 size.
// Message each recipient.
foreach ($recipients as $recipient) {
$msgcopy = clone($message);
Expand Down Expand Up @@ -208,6 +209,7 @@ function core_competency_comment_add($comment, $params) {
$message->contexturlname = $urlname;

$userpicture = new \user_picture($user);
$userpicture->size = 1; // Use f1 size.
// Message each recipient.
foreach ($recipients as $recipient) {
$msgcopy = clone($message);
Expand Down
1 change: 1 addition & 0 deletions competency/tests/lib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public function test_comment_add_user_competency() {
$this->assertObjectHasAttribute('notificationiconurl', $customdata);
$this->assertContains('tokenpluginfile.php', $customdata->notificationiconurl);
$userpicture = new \user_picture($u1);
$userpicture->size = 1; // Use f1 size.
$userpicture->includetoken = $u2->id;
$this->assertEquals($userpicture->get_url($PAGE)->out(false), $customdata->notificationiconurl);

Expand Down
1 change: 1 addition & 0 deletions message/classes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2676,6 +2676,7 @@ public static function create_contact_request(int $userid, int $requesteduserid)
$message->smallmessage = '';
$message->contexturl = $url->out(false);
$userpicture = new \user_picture($userfrom);
$userpicture->size = 1; // Use f1 size.
$userpicture->includetoken = $userto->id; // Generate an out-of-session token for the user receiving the message.
$message->customdata = [
'notificationiconurl' => $userpicture->get_url($PAGE)->out(false),
Expand Down
1 change: 1 addition & 0 deletions message/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ function message_post_message($userfrom, $userto, $message, $format) {
$eventdata->notification = 0;
// User image.
$userpicture = new user_picture($userfrom);
$userpicture->size = 1; // Use f1 size.
$userpicture->includetoken = $userto->id; // Generate an out-of-session token for the user receiving the message.
$eventdata->customdata = [
'notificationiconurl' => $userpicture->get_url($PAGE)->out(false),
Expand Down
1 change: 1 addition & 0 deletions mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -6335,6 +6335,7 @@ public static function send_assignment_notification($userfrom,
// Check if the userfrom is real and visible.
if (!empty($userfrom->id) && core_user::is_real_user($userfrom->id)) {
$userpicture = new user_picture($userfrom);
$userpicture->size = 1; // Use f1 size.
$userpicture->includetoken = $userto->id; // Generate an out-of-session token for the user receiving the message.
$customdata['notificationiconurl'] = $userpicture->get_url($PAGE)->out(false);
}
Expand Down
1 change: 1 addition & 0 deletions mod/assign/tests/locallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,7 @@ public function test_cron() {
$this->assertEquals($assign->get_instance()->id, $customdata->instance);
$this->assertEquals('feedbackavailable', $customdata->messagetype);
$userpicture = new user_picture($teacher);
$userpicture->size = 1; // Use f1 size.
$this->assertEquals($userpicture->get_url($PAGE)->out(false), $customdata->notificationiconurl);
$this->assertEquals(0, $customdata->uniqueidforuser); // Not used in this case.
$this->assertFalse($customdata->blindmarking);
Expand Down
1 change: 1 addition & 0 deletions mod/feedback/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2639,6 +2639,7 @@ function feedback_send_email($cm, $feedback, $course, $user, $completed = null)
$eventdata->contexturlname = $info->feedback;
// User image.
$userpicture = new user_picture($user);
$userpicture->size = 1; // Use f1 size.
$userpicture->includetoken = $teacher->id; // Generate an out-of-session token for the user receiving the message.
$customdata['notificationiconurl'] = $userpicture->get_url($PAGE)->out(false);
$eventdata->customdata = $customdata;
Expand Down
1 change: 1 addition & 0 deletions mod/forum/classes/task/send_user_notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ protected function send_post($course, $forum, $discussion, $post, $cm, $context)
$eventdata->contexturlname = $discussion->name;
// User image.
$userpicture = new \user_picture($author);
$userpicture->size = 1; // Use f1 size.
$userpicture->includetoken = $this->recipient->id; // Generate an out-of-session token for the user receiving the message.
$eventdata->customdata = [
'cmid' => $cm->id,
Expand Down
1 change: 1 addition & 0 deletions mod/lesson/essay.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
}

$userpicture = new user_picture($USER);
$userpicture->size = 1; // Use f1 size.
foreach ($attempts as $attempt) {
$essayinfo = lesson_page_type_essay::extract_useranswer($attempt->useranswer);
if ($essayinfo->graded && !$essayinfo->sent) {
Expand Down
1 change: 1 addition & 0 deletions mod/quiz/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,7 @@ function quiz_send_notification($recipient, $submitter, $a) {
$eventdata->contexturl = $a->quizreviewurl;
$eventdata->contexturlname = $a->quizname;
$userpicture = new user_picture($submitter);
$userpicture->size = 1; // Use f1 size.
$userpicture->includetoken = $recipient->id; // Generate an out-of-session token for the user receiving the message.
$eventdata->customdata = [
'cmid' => $a->quizcmid,
Expand Down

0 comments on commit dcadc8c

Please sign in to comment.