MDL-64715 message: add support for self conversations
Added new MESSAGE_CONVERSATION_TYPE_SELF type for self-conversations and upgraded legacy self-conversations to the new type, removing repeated members in the message_conversation_members table. Besides, from now, a self-conversation will be created by default for all the existing users. All the self-conversations have been also starred and a default message will be displayed always to explain how to use them.
This commit is contained in:
@@ -122,7 +122,18 @@ class migrate_message_data extends \core\task\adhoc_task {
|
||||
private function migrate_data($userid, $otheruserid) {
|
||||
global $DB;
|
||||
|
||||
if (!$conversationid = \core_message\api::get_conversation_between_users([$userid, $otheruserid])) {
|
||||
if ($userid == $otheruserid) {
|
||||
// Since 3.7, pending self-conversations should be migrated during the upgrading process so shouldn't be any
|
||||
// self-conversations on the legacy tables. However, this extra-check has been added just in case.
|
||||
$conversation = \core_message\api::get_self_conversation($userid);
|
||||
if (empty($conversation)) {
|
||||
$conversation = \core_message\api::create_conversation(
|
||||
\core_message\api::MESSAGE_CONVERSATION_TYPE_SELF,
|
||||
[$userid]
|
||||
);
|
||||
}
|
||||
$conversationid = $conversation->id;
|
||||
} else if (!$conversationid = \core_message\api::get_conversation_between_users([$userid, $otheruserid])) {
|
||||
$conversation = \core_message\api::create_conversation(
|
||||
\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user