MDL-66244 message: Include group sender images in payload

Android 9 notifications now displays two image icons in conversations.
The group and the sender.
This commit is contained in:
Juan Leyva 2019-08-15 20:05:59 +01:00
parent 9e4178a465
commit 47138d9157
2 changed files with 12 additions and 5 deletions

View file

@ -1983,10 +1983,15 @@ class api {
],
];
$userpicture = new \user_picture($eventdata->userfrom);
$userpicture->size = 1; // Use f1 size.
$userpicture = $userpicture->get_url($PAGE)->out(false);
$conv = $DB->get_record('message_conversations', ['id' => $conversationid]);
if ($conv->type == self::MESSAGE_CONVERSATION_TYPE_GROUP) {
$convextrafields = self::get_linked_conversation_extra_fields([$conv]);
// Conversation image.
// Conversation images.
$customdata['notificationsendericonurl'] = $userpicture;
$imageurl = isset($convextrafields[$conv->id]) ? $convextrafields[$conv->id]['imageurl'] : null;
if ($imageurl) {
$customdata['notificationiconurl'] = $imageurl;
@ -1999,8 +2004,7 @@ class api {
}
$customdata['conversationname'] = format_string($conv->name, true, ['context' => $convcontext]);
} else if ($conv->type == self::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL) {
$userpicture = new \user_picture($eventdata->userfrom);
$customdata['notificationiconurl'] = $userpicture->get_url($PAGE)->out(false);
$customdata['notificationiconurl'] = $userpicture;
}
$eventdata->customdata = $customdata;