@@ -2199,13 +2199,13 @@ public static function get_conversation_messages_parameters() {
2199
2199
* @param int $limitnum Return a subset comprising this many records in total (optional, required if $limitfrom is set).
2200
2200
* @param bool $newest True for getting first newest messages, false otherwise.
2201
2201
* @param int $timefrom The time from the conversation messages to get.
2202
- * @return stdClass The messages and members who have sent some of these messages.
2202
+ * @return array The messages and members who have sent some of these messages.
2203
2203
* @throws moodle_exception
2204
2204
* @since 3.6
2205
2205
*/
2206
2206
public static function get_conversation_messages (int $ currentuserid , int $ convid , int $ limitfrom = 0 , int $ limitnum = 0 ,
2207
2207
bool $ newest = false , int $ timefrom = 0 ) {
2208
- global $ CFG , $ PAGE , $ USER ;
2208
+ global $ CFG , $ USER ;
2209
2209
2210
2210
// Check if messaging is enabled.
2211
2211
if (empty ($ CFG ->messaging )) {
@@ -2229,6 +2229,11 @@ public static function get_conversation_messages(int $currentuserid, int $convid
2229
2229
throw new moodle_exception ('You do not have permission to perform this action. ' );
2230
2230
}
2231
2231
2232
+ // Check that the user belongs to the conversation.
2233
+ if (!\core_message \api::is_user_in_conversation ($ params ['currentuserid ' ], $ params ['convid ' ])) {
2234
+ throw new moodle_exception ('User is not part of conversation. ' );
2235
+ }
2236
+
2232
2237
$ sort = $ newest ? 'timecreated DESC ' : 'timecreated ASC ' ;
2233
2238
2234
2239
// We need to enforce a one second delay on messages to avoid race conditions of current
0 commit comments