将评论取消精选
@param $msg_data_id
@param $user_comment_id
@param null $index
@return bool
@throws Exception
540185
public function unMarkComment($msg_data_id, $user_comment_id, $index = null) {
        $args = $this->getUnMarkComment()->parameters(
            compact('msg_data_id', 'user_comment_id', 'index'))->json();
        return $args['errcode'] == 0;
    }
1229761
public function archive(string $userId, string $threadId): \Google_Service_Gmail_Thread
    {
        $postBody = new \Google_Service_Gmail_ModifyThreadRequest();
        $postBody->setRemoveLabelIds(['INBOX']);

        return $this->modifyThread($userId, $threadId, $postBody);
    }
57733
public function deleteMassMessage($msg_id){
        if (!$this->access_token && !$this->checkAuth()) return false;
        $result = $this->http_post(self::API_URL_PREFIX.self::MASS_DELETE_URL.'access_token='.$this->access_token,self::json_encode(array('msg_id'=>$msg_id)));
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            }
            return true;
        }
        return false;
    }
533183
public function moveMessage($index = -1, $to = '')
    {
        if (empty($to)) {
            return false;
        }

        $msgId = 0;

        if (is_array($this->messages) == true) {
            foreach($this ->messages as $msg) {
                if ($msg['index'] == $index) {
                    $msgId = $msg['index'];
                    break;
                }
            }
        }


        if ($msgId >= 0) {
            $to = imap_utf7_encode($to);

            imap_mail_move($this->conn, $msgId, "INBOX.".$to);
            imap_expunge($this->conn);
        }

        return false;
    }
1111099
public function getMsg($lastid=0,$offset=0,$perpage=20,$day=7,$today=0,$star=0){
		$send_snoopy = new Snoopy; 
		$send_snoopy->rawheaders['Cookie']= $this->cookie;
		$send_snoopy->referer = "https://mp.weixin.qq.com/cgi-bin/message?t=message/list&lang=zh_CN&count=50&token=".$this->_token;
		$lastid = $lastid===0 ? '':$lastid;
		$addstar = $star?'&action=star':'';
		$submit = "https://mp.weixin.qq.com/cgi-bin/message?t=message/list&f=json&lang=zh_CN{$addstar}&count=$perpage&timeline=$today&day=$day&frommsgid=$lastid&offset=$offset&token=".$this->_token;
		$send_snoopy->fetch($submit);
		$this->log($send_snoopy->results);
		$result = $send_snoopy->results;
		$json = json_decode($result,true);
		if (isset($json['msg_items'])) {
			$json = json_decode($json['msg_items'],true);
			if(isset($json['msg_item']))
				return $json['msg_item'];
		}
		return false;
	}
1094567
protected boolean postDatagram (PresentsConnection conn, Message msg)
        throws Exception
    {
        _flattener.reset();

        // flatten the message using the connection's sequencer
        DatagramSequencer sequencer = conn.getDatagramSequencer();
        sequencer.writeDatagram(msg);

        // if the message is too big, we must fall back to sending it through the stream channel
        if (_flattener.size() > Client.MAX_DATAGRAM_SIZE) {
            return false;
        }

        // note the actual transport
        msg.noteActualTransport(Transport.UNRELIABLE_UNORDERED);

        // extract as a byte array
        byte[] data = _flattener.toByteArray();

        // slap it on the queue
        _dataq.append(Tuple.newTuple(conn, data));

        return true;
    }
697849
public function parseRelationship(string $index, string $name, array $jsonData): bool
    {
        $this->resetAggregators();

        $isFoundInToOne  = array_key_exists($name, $this->getSerializer()::readRulesIndexes($this->getToOneRules()));
        $isFoundInToMany = $isFoundInToOne === false &&
            array_key_exists($name, $this->getSerializer()::readRulesIndexes($this->getToManyRules()));

        if ($isFoundInToOne === false && $isFoundInToMany === false) {
            $title   = $this->formatMessage(Messages::INVALID_VALUE);
            $details = $this->formatMessage(Messages::UNKNOWN_RELATIONSHIP);
            $status  = JsonApiResponse::HTTP_UNPROCESSABLE_ENTITY;
            $this->getJsonApiErrorCollection()->addRelationshipError($name, $title, $details, (string)$status);
            $this->addErrorStatus($status);
        } else {
            assert($isFoundInToOne xor $isFoundInToMany);
            $ruleIndexes = $this->getSerializer()::readSingleRuleIndexes(
                $isFoundInToOne === true ? $this->getToOneRules() : $this->getToManyRules(),
                $name
            );

            // now execute validation rules
            $this->executeStarts($this->getSerializer()::readRuleStartIndexes($ruleIndexes));
            $ruleIndex = $this->getSerializer()::readRuleIndex($ruleIndexes);
            $isFoundInToOne === true ?
                $this->validateAsToOneRelationship($ruleIndex, $name, $jsonData) :
                $this->validateAsToManyRelationship($ruleIndex, $name, $jsonData);
            $this->executeEnds($this->getSerializer()::readRuleEndIndexes($ruleIndexes));

            if (count($this->getErrorAggregator()) > 0) {
                $status  = JsonApiResponse::HTTP_CONFLICT;
                foreach ($this->getErrorAggregator()->get() as $error) {
                    $this->getJsonApiErrorCollection()->addValidationRelationshipError($error, $status);
                    $this->addErrorStatus($status);
                }
                $this->getErrorAggregator()->clear();
            }
        }

        $hasNoErrors = count($this->getJsonApiErrorCollection()) <= 0;

        return $hasNoErrors;
    }
785322
public function markUnread(string $userId, string $threadId): \Google_Service_Gmail_Thread
    {
        $postBody = new \Google_Service_Gmail_ModifyThreadRequest();
        $postBody->setAddLabelIds(['UNREAD']);

        return $this->modifyThread($userId, $threadId, $postBody);
    }
230484
public function list(string $msgId, int $index, int $begin, int $count, int $type = 0)
    {
        $params = [
            'msg_data_id' => $msgId,
            'index' => $index,
            'begin' => $begin,
            'count' => $count,
            'type' => $type,
        ];

        return $this->httpPostJson('cgi-bin/comment/list', $params);
    }
628389
public function indexComments($userId, EncodingParametersInterface $parameters)
    {
        $this->getLogger()->debug('Index user comments started.', [User::FIELD_ID => $userId]);

        $result = $this->indexRelationship($userId, User::REL_COMMENTS, $parameters);

        $this->getLogger()->debug('Index user comments completed.');

        return $result;
    }
752522
public function sendToUser($user_id, array $msg) {
        //检查redis ping 防止掉线
        $fid = $this->userIdToFid($user_id);
        if (!$fid) {
            return null;
        }
        $fid_server = explode('@', $fid);
        $host_name = $fid_server[ 0 ];
        $fid = $fid_server[ 1 ];
        if ($host_name == $this->host_name) {
            if (!$this->server->exist($fid)) {
                //断开
                $this->server->close($fid);
                $redis = Cache::redis();
                $redis->hDel('user_id_#_fid', $user_id);
                $redis->hDel('fid_#_user_id', $fid);
                Cache::release();
                return false;
            }
            $this->server->push($fid, json_encode($msg));
        } else {
            try {
                //通过集群中的其他服务器推送
                Http::put('http://' . $host_name . ':' . $this->config[ 'port' ] . '/open/push', [], ['fid' => $fid,
                                                                                                      'msg' => json_encode($msg),
                                                                                                      'secret' => $this->config[ 'secret' ]]);
            } catch (\Exception $exception) {
            } catch (\Error $exception) {
            }
        }
        return null;
    }
839255
public function massDelete($msg_id, $article_idx = null)
    {
        $data = ['msg_id' => $msg_id];
        is_null($article_idx) || $data['article_idx'] = $article_idx;
        $url = "https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
626662
def check_user_can_send_comments(user_info, recid):
    
    # First can we find an authorization for this case, action + collection
    record_primary_collection = guess_primary_collection_of_a_record(recid)
    return acc_authorize_action(
        user_info,
        'sendcomment',
        authorized_if_no_roles=True,
        collection=record_primary_collection)
1171880
public static function checkTelegram(int $chat_id)
    {
        $user_meta = static::findOne(['notification_telegram' => $chat_id]);
        if ($user_meta) {
            return $user_meta->notification_telegram;
        }
        return null;
    }
923886
public static function data_for_messagearea_contacts($userid, $limitfrom = 0, $limitnum = 0) {
        global $CFG, $PAGE, $USER;

        // Check if messaging is enabled.
        if (empty($CFG->messaging)) {
            throw new moodle_exception('disabled', 'message');
        }

        $systemcontext = context_system::instance();

        $params = array(
            'userid' => $userid,
            'limitfrom' => $limitfrom,
            'limitnum' => $limitnum
        );
        $params = self::validate_parameters(self::data_for_messagearea_contacts_parameters(), $params);
        self::validate_context($systemcontext);

        if (($USER->id != $params['userid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
            throw new moodle_exception('You do not have permission to perform this action.');
        }

        $contacts = \core_message\api::get_contacts($params['userid'], $params['limitfrom'], $params['limitnum']);
        $contacts = new \core_message\output\messagearea\contacts(null, $contacts);

        $renderer = $PAGE->get_renderer('core_message');
        return $contacts->export_for_template($renderer);
    }
597851
public function updateForeverArticles($media_id,$data,$index=0){
        if (!$this->access_token && !$this->checkAuth()) return false;
        if (!isset($data['media_id'])) $data['media_id'] = $media_id;
        if (!isset($data['index'])) $data['index'] = $index;
        $result = $this->http_post(self::API_URL_PREFIX.self::MEDIA_FOREVER_NEWS_UPDATE_URL.'access_token='.$this->access_token,self::json_encode($data));
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            }
            return $json;
        }
        return false;
    }
555245
public function deleteReplyComment($msg_data_id, $user_comment_id, $index = null) {
        $args = $this->getDeleteReplyComment()->parameters(
            compact('msg_data_id', 'user_comment_id', 'index'))->json();
        return $args['errcode'] == 0;
    }