新增im回调
This commit is contained in:
@@ -13,6 +13,9 @@ use App\Utils\Log;
|
||||
use Extend\TencentIm\Account;
|
||||
use Extend\TencentIm\Profile;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Hyperf\Redis\Redis;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class ImService extends BaseService
|
||||
{
|
||||
@@ -120,4 +123,45 @@ class ImService extends BaseService
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证回调签名
|
||||
* @param string $request_time 签名时间戳
|
||||
* @param string $sign 签名
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSign(string $request_time,string $sign): bool
|
||||
{
|
||||
$token = config('im.token');
|
||||
if (empty($token)){
|
||||
throw new BusinessException("Im Token Config Error");
|
||||
}
|
||||
|
||||
$sys_sign = hash("sha256", $token . $request_time);
|
||||
if ($sign != $sys_sign){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加最近联系人会话记录缓存
|
||||
* @param string $doctor_id 医生id
|
||||
* @param string $inquiry_type 订单类型(自定义字段 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
* @param string $patient_user_id 患者用户id
|
||||
* @param array $content 内容
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function addRecentContactRecordCache(string $doctor_id,string $inquiry_type,string $patient_user_id,array $content): void
|
||||
{
|
||||
$redis_key = "recentContact" . $doctor_id . $inquiry_type;
|
||||
|
||||
$hash_key = $patient_user_id;
|
||||
|
||||
$redis = $this->container->get(Redis::class);
|
||||
|
||||
$redis->hSet($redis_key,$hash_key,json_encode($content,JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user