MDL-60680 notifications: Support privacy API

This commit is contained in:
Juan Leyva 2019-04-05 09:50:05 +02:00
parent 2356454f21
commit a129ba04c4
3 changed files with 13 additions and 3 deletions

View File

@ -153,6 +153,7 @@ $string['privacy:metadata:messages:useridfrom'] = 'The ID of the user who sent t
$string['privacy:metadata:messages:smallmessage'] = 'A small version of the message';
$string['privacy:metadata:messages:subject'] = 'The subject of the message';
$string['privacy:metadata:messages:timecreated'] = 'The time when the message was created';
$string['privacy:metadata:messages:customdata'] = 'Custom data, usually contains internal ids and a public URL of the sender image (user or group).';
$string['privacy:metadata:message_contacts'] = 'The list of contacts';
$string['privacy:metadata:message_contacts:contactid'] = 'The ID of the user who is a contact';
$string['privacy:metadata:message_contacts:timecreated'] = 'The time when the contact was created';
@ -193,6 +194,7 @@ $string['privacy:metadata:notifications:timeread'] = 'The time when the notifica
$string['privacy:metadata:notifications:timecreated'] = 'The time when the notification was created';
$string['privacy:metadata:notifications:useridfrom'] = 'The ID of the user who sent the notification';
$string['privacy:metadata:notifications:useridto'] = 'The ID of the user who received the notification';
$string['privacy:metadata:notifications:customdata'] = 'Custom data, usually contains internal ids and a public URL of the sender picture (if any).';
$string['privacy:metadata:preference:core_message_settings'] = 'Settings related to messaging';
$string['privacy:request:preference:set'] = 'The value of the setting \'{$a->name}\' was \'{$a->value}\'';
$string['privacy:export:conversationprefix'] = 'Conversation: ';

View File

@ -73,7 +73,8 @@ class provider implements
'fullmessageformat' => 'privacy:metadata:messages:fullmessageformat',
'fullmessagehtml' => 'privacy:metadata:messages:fullmessagehtml',
'smallmessage' => 'privacy:metadata:messages:smallmessage',
'timecreated' => 'privacy:metadata:messages:timecreated'
'timecreated' => 'privacy:metadata:messages:timecreated',
'customdata' => 'privacy:metadata:messages:customdata',
],
'privacy:metadata:messages'
);
@ -155,6 +156,7 @@ class provider implements
'contexturlname' => 'privacy:metadata:notifications:contexturlname',
'timeread' => 'privacy:metadata:notifications:timeread',
'timecreated' => 'privacy:metadata:notifications:timecreated',
'customdata' => 'privacy:metadata:notifications:customdata',
],
'privacy:metadata:notifications'
);
@ -930,7 +932,8 @@ class provider implements
'issender' => transform::yesno($issender),
'message' => message_format_message_text($message),
'timecreated' => transform::datetime($message->timecreated),
'timeread' => $timeread
'timeread' => $timeread,
'customdata' => $message->customdata,
];
if ($conversation->type == \core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP && !$issender) {
// Only export sender for group conversations when is not the current user.
@ -1037,7 +1040,8 @@ class provider implements
'contexturl' => $notification->contexturl,
'contexturlname' => $notification->contexturlname,
'timeread' => $timeread,
'timecreated' => transform::datetime($notification->timecreated)
'timecreated' => transform::datetime($notification->timecreated),
'customdata' => $notification->customdata,
];
$notificationdata[] = $data;

View File

@ -89,6 +89,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
$this->assertArrayHasKey('fullmessagehtml', $privacyfields);
$this->assertArrayHasKey('smallmessage', $privacyfields);
$this->assertArrayHasKey('timecreated', $privacyfields);
$this->assertArrayHasKey('customdata', $privacyfields);
$this->assertEquals('privacy:metadata:messages', $messagestable->get_summary());
$privacyfields = $messageuseractionstable->get_privacy_fields();
@ -136,6 +137,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
$this->assertArrayHasKey('contexturlname', $privacyfields);
$this->assertArrayHasKey('timeread', $privacyfields);
$this->assertArrayHasKey('timecreated', $privacyfields);
$this->assertArrayHasKey('customdata', $privacyfields);
$this->assertEquals('privacy:metadata:notifications', $notificationstable->get_summary());
}
@ -2724,6 +2726,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
$record->fullmessage = 'A rad message ' . $i;
$record->smallmessage = 'A rad message ' . $i;
$record->timecreated = $timecreated;
$record->customdata = json_encode(['akey' => 'avalue']);
$i++;
@ -2763,6 +2766,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
$record->smallmessage = 'Yo homie, you got some stuff to do, yolo. ' . $i;
$record->timeread = $timeread;
$record->timecreated = $timecreated;
$record->customdata = json_encode(['akey' => 'avalue']);
$i++;