MDL-63466 core_message: Add conversation support to get_messages

- The get_conversation_messages has been added to the API and the WS
with the conversation identifier (convid) instead of the userto,
to let get conversation messages and the members involved.
- The cache has been also reviewed, to use the convid instead of the
[userfrom, userto] keys.
- The get_most_recent_conversation_messages has been added to the API
to update the cache when needed.
This commit is contained in:
Sara Arjona
2018-10-24 09:39:05 +08:00
committed by Jake Dallimore
parent d89d0d6593
commit fb04293bb1
11 changed files with 1002 additions and 24 deletions
@@ -28,7 +28,7 @@ namespace core_message;
defined('MOODLE_INTERNAL') || die();
/**
* Cache data source for the time of the last message between users.
* Cache data source for the time of the last message in a conversation.
*
* @package core_message
* @category cache
@@ -61,9 +61,7 @@ class time_last_message_between_users implements \cache_data_source {
* @return mixed What ever data should be returned, or false if it can't be loaded.
*/
public function load_for_cache($key) {
list($userid1, $userid2) = explode('_', $key);
$message = api::get_most_recent_message($userid1, $userid2);
$message = api::get_most_recent_conversation_message($key);
if ($message) {
return $message->timecreated;