mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-64666 core_message: Favourite private conversations data generator
This commit is contained in:
parent
bc342f101a
commit
a8915a3a7f
@ -198,6 +198,16 @@ class behat_data_generators extends behat_base {
|
||||
'required' => array('user', 'contact'),
|
||||
'switchids' => array('user' => 'userid', 'contact' => 'contactid')
|
||||
),
|
||||
'private messages' => array(
|
||||
'datagenerator' => 'private_messages',
|
||||
'required' => array('user', 'contact', 'message'),
|
||||
'switchids' => array('user' => 'userid', 'contact' => 'contactid')
|
||||
),
|
||||
'favourite conversations' => array(
|
||||
'datagenerator' => 'favourite_conversations',
|
||||
'required' => array('user', 'contact'),
|
||||
'switchids' => array('user' => 'userid', 'contact' => 'contactid')
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
@ -876,4 +886,38 @@ class behat_data_generators extends behat_base {
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a new message from user to contact in a private conversation
|
||||
*
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
protected function process_private_messages($data) {
|
||||
if (!$conversationid = \core_message\api::get_conversation_between_users([$data['userid'], $data['contactid']])) {
|
||||
$conversation = \core_message\api::create_conversation(
|
||||
\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$data['userid'], $data['contactid']]
|
||||
);
|
||||
$conversationid = $conversation->id;
|
||||
}
|
||||
\core_message\api::send_message_to_conversation($data['userid'], $conversationid, $data['message'], FORMAT_PLAIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a private conversation as favourite for user
|
||||
*
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
protected function process_favourite_conversations($data) {
|
||||
if (!$conversationid = \core_message\api::get_conversation_between_users([$data['userid'], $data['contactid']])) {
|
||||
$conversation = \core_message\api::create_conversation(
|
||||
\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$data['userid'], $data['contactid']]
|
||||
);
|
||||
$conversationid = $conversation->id;
|
||||
}
|
||||
\core_message\api::set_favourite_conversation($conversationid, $data['userid']);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user