MDL-60680 notifications: Support privacy API
authorJuan Leyva <juanleyvadelgado@gmail.com>
Fri, 5 Apr 2019 07:50:05 +0000 (09:50 +0200)
committerJuan Leyva <juanleyvadelgado@gmail.com>
Thu, 25 Apr 2019 12:55:59 +0000 (14:55 +0200)
lang/en/message.php
message/classes/privacy/provider.php
message/tests/privacy_provider_test.php

index 8ce4b59..a106802 100644 (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: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';
 $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: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: ';
 $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: ';
index ee90f5c..e1f276e 100644 (file)
@@ -73,7 +73,8 @@ class provider implements
                 'fullmessageformat' => 'privacy:metadata:messages:fullmessageformat',
                 'fullmessagehtml' => 'privacy:metadata:messages:fullmessagehtml',
                 'smallmessage' => 'privacy:metadata:messages:smallmessage',
                 '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'
         );
             ],
             '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',
                 'contexturlname' => 'privacy:metadata:notifications:contexturlname',
                 'timeread' => 'privacy:metadata:notifications:timeread',
                 'timecreated' => 'privacy:metadata:notifications:timecreated',
+                'customdata' => 'privacy:metadata:notifications:customdata',
             ],
             'privacy:metadata:notifications'
         );
             ],
             '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),
                 '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.
             ];
             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,
                 'contexturl' => $notification->contexturl,
                 'contexturlname' => $notification->contexturlname,
                 'timeread' => $timeread,
-                'timecreated' => transform::datetime($notification->timecreated)
+                'timecreated' => transform::datetime($notification->timecreated),
+                'customdata' => $notification->customdata,
             ];
 
             $notificationdata[] = $data;
             ];
 
             $notificationdata[] = $data;
index 6fc2436..28a7dcf 100644 (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('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();
         $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('contexturlname', $privacyfields);
         $this->assertArrayHasKey('timeread', $privacyfields);
         $this->assertArrayHasKey('timecreated', $privacyfields);
+        $this->assertArrayHasKey('customdata', $privacyfields);
         $this->assertEquals('privacy:metadata:notifications', $notificationstable->get_summary());
     }
 
         $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->fullmessage = 'A rad message ' . $i;
         $record->smallmessage = 'A rad message ' . $i;
         $record->timecreated = $timecreated;
+        $record->customdata = json_encode(['akey' => 'avalue']);
 
         $i++;
 
 
         $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->smallmessage = 'Yo homie, you got some stuff to do, yolo. ' . $i;
         $record->timeread = $timeread;
         $record->timecreated = $timecreated;
+        $record->customdata = json_encode(['akey' => 'avalue']);
 
         $i++;
 
 
         $i++;