mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
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:
parent
9e4178a465
commit
47138d9157
2 changed files with 12 additions and 5 deletions
|
@ -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]);
|
$conv = $DB->get_record('message_conversations', ['id' => $conversationid]);
|
||||||
if ($conv->type == self::MESSAGE_CONVERSATION_TYPE_GROUP) {
|
if ($conv->type == self::MESSAGE_CONVERSATION_TYPE_GROUP) {
|
||||||
$convextrafields = self::get_linked_conversation_extra_fields([$conv]);
|
$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;
|
$imageurl = isset($convextrafields[$conv->id]) ? $convextrafields[$conv->id]['imageurl'] : null;
|
||||||
if ($imageurl) {
|
if ($imageurl) {
|
||||||
$customdata['notificationiconurl'] = $imageurl;
|
$customdata['notificationiconurl'] = $imageurl;
|
||||||
|
@ -1999,8 +2004,7 @@ class api {
|
||||||
}
|
}
|
||||||
$customdata['conversationname'] = format_string($conv->name, true, ['context' => $convcontext]);
|
$customdata['conversationname'] = format_string($conv->name, true, ['context' => $convcontext]);
|
||||||
} else if ($conv->type == self::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL) {
|
} else if ($conv->type == self::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL) {
|
||||||
$userpicture = new \user_picture($eventdata->userfrom);
|
$customdata['notificationiconurl'] = $userpicture;
|
||||||
$customdata['notificationiconurl'] = $userpicture->get_url($PAGE)->out(false);
|
|
||||||
}
|
}
|
||||||
$eventdata->customdata = $customdata;
|
$eventdata->customdata = $customdata;
|
||||||
|
|
||||||
|
|
|
@ -6298,7 +6298,7 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
|
||||||
* Test verifying that messages can be sent to existing linked group conversations.
|
* Test verifying that messages can be sent to existing linked group conversations.
|
||||||
*/
|
*/
|
||||||
public function test_send_message_to_conversation_linked_group_conversation() {
|
public function test_send_message_to_conversation_linked_group_conversation() {
|
||||||
global $CFG;
|
global $CFG, $PAGE;
|
||||||
|
|
||||||
// Create some users.
|
// Create some users.
|
||||||
$user1 = self::getDataGenerator()->create_user();
|
$user1 = self::getDataGenerator()->create_user();
|
||||||
|
@ -6349,9 +6349,12 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
|
||||||
// Test customdata.
|
// Test customdata.
|
||||||
$customdata = json_decode($messages[0]->customdata);
|
$customdata = json_decode($messages[0]->customdata);
|
||||||
$this->assertObjectHasAttribute('notificationiconurl', $customdata);
|
$this->assertObjectHasAttribute('notificationiconurl', $customdata);
|
||||||
|
$this->assertObjectHasAttribute('notificationsendericonurl', $customdata);
|
||||||
$this->assertEquals($groupimageurl, $customdata->notificationiconurl);
|
$this->assertEquals($groupimageurl, $customdata->notificationiconurl);
|
||||||
$this->assertEquals($group->name, $customdata->conversationname);
|
$this->assertEquals($group->name, $customdata->conversationname);
|
||||||
|
$userpicture = new \user_picture($user1);
|
||||||
|
$userpicture->size = 1; // Use f1 size.
|
||||||
|
$this->assertEquals($userpicture->get_url($PAGE)->out(false), $customdata->notificationsendericonurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue