src/Biz/IM/Service/Impl/ConversationServiceImpl.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace Biz\IM\Service\Impl;

use Biz\BaseService;
use AppBundle\Common\ArrayToolkit;
use Biz\CloudPlatform\IMAPIFactory;
use Biz\IM\ConversationException;
use Biz\IM\Service\ConversationService;

class ConversationServiceImpl extends BaseService implements ConversationService
{
    private $imApi;

    public function getConversation($id)
    {
        return $this->getConversationDao()->get($id);
    }

    public function getConversationByConvNo($convNo)
    {
        return $this->getConversationDao()->getByConvNo($convNo);
    }

    public function getConversationByMemberIds(array $memberIds)
    {
        sort($memberIds);
        $memberHash = $this->buildMemberHash($memberIds);

        return $this->getConversationDao()->getByMemberHash($memberHash);
    }

    public function getConversationByTarget($targetId, $targetType)
    {
        return $this->getConversationDao()->getByTargetIdAndTargetType($targetId, $targetType);
    }

    public function createConversation($title, $targetType, $targetId, $members)
    {
        $conversation = array();
        $conversation['title'] = $title;
        $conversation['targetType'] = $targetType;
        $conversation['targetId'] = empty($targetId) ? 0 : intval($targetId);

        $memberIds = ArrayToolkit::column($members, 'id');
        if ($targetType == 'private') {
            $conversation['title'] = join(ArrayToolkit::column($members, 'nickname'), '-').'的私聊';
            $conversation['memberIds'] = $memberIds;
        } else {
            $conversation['memberIds'] = array();
        }

        $lockName = "im_{$conversation['targetType']}{$conversation['targetId']}";
        if ($targetType == 'global') {
            $lockName = "im_{$conversation['targetType']}0";
        }

        $lockResult = $this->getLock()->get($lockName, 50);
        if (!$lockResult) {
            $this->createNewException(ConversationException::CREATE_FAILED());

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。