From a129ba04c4a31510b6faa19809aa0315aff37b43 Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Fri, 5 Apr 2019 09:50:05 +0200 Subject: [PATCH] MDL-60680 notifications: Support privacy API --- lang/en/message.php | 2 ++ message/classes/privacy/provider.php | 10 +++++++--- message/tests/privacy_provider_test.php | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lang/en/message.php b/lang/en/message.php index 8ce4b5949ca..a1068025f42 100644 --- a/lang/en/message.php +++ b/lang/en/message.php @@ -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: '; diff --git a/message/classes/privacy/provider.php b/message/classes/privacy/provider.php index ee90f5c1fce..e1f276ebae4 100644 --- a/message/classes/privacy/provider.php +++ b/message/classes/privacy/provider.php @@ -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; diff --git a/message/tests/privacy_provider_test.php b/message/tests/privacy_provider_test.php index 6fc24366528..28a7dcf1164 100644 --- a/message/tests/privacy_provider_test.php +++ b/message/tests/privacy_provider_test.php @@ -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++; -- 2.43.0