public static function is_user_blocked($recipientid, $senderid = null) {
        debugging('\core_message\api::is_user_blocked is deprecated and should not be used.',
            DEBUG_DEVELOPER);

        global $USER;

        if (is_null($senderid)) {
            // The message is from the logged in user, unless otherwise specified.
            $senderid = $USER->id;
        }

        $systemcontext = \context_system::instance();
        if (has_capability('moodle/site:readallmessages', $systemcontext, $senderid)) {
            return false;
        }

        if (self::is_blocked($recipientid, $senderid)) {
            return true;
        }

        return false;
    }