9
This commit is contained in:
+6
-5
@@ -153,11 +153,12 @@ class Jwt
|
||||
return false;
|
||||
}
|
||||
if($verifyType == 'password'){
|
||||
//if ($user->username!='' && !\plugin\admin\app\common\Util::passwordVerify($password,$user->password)) {
|
||||
if (!\plugin\admin\app\common\Util::passwordVerify($password,$user->password)) {
|
||||
self::setError('Password is incorrect');
|
||||
return false;
|
||||
}
|
||||
//if ($user->username!='' && $user->id!='100703') {
|
||||
if (!\plugin\admin\app\common\Util::passwordVerify($password,$user->password)) {
|
||||
self::setError('Password is incorrect');
|
||||
return false;
|
||||
}
|
||||
//}
|
||||
}else{
|
||||
captcha_verfiy($type,'login',$account);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class Auth
|
||||
* @param string $platformID 平台ID,默认为android
|
||||
* @return array
|
||||
*/
|
||||
public function forceLogout(string $userID, string $platformID = 'android'): array
|
||||
public function forceLogout(string $userID, string $platformID = 'android'): array|bool
|
||||
{
|
||||
// 获取管理员token
|
||||
$adminToken = Utils::getAdminToken();
|
||||
|
||||
@@ -33,11 +33,18 @@ class Conversation
|
||||
* @param string $userID 用户ID
|
||||
* @return array
|
||||
*/
|
||||
public function getSortedConversationList(string $userID): array
|
||||
public function getSortedConversationList(string $userID,$conversationIDs='',int $page=1,int $pagesize=10): array
|
||||
{
|
||||
// 获取管理员token
|
||||
$adminToken = Utils::getAdminToken();
|
||||
return Utils::send(Url::$getSortedConversationList, ['userID' => $userID], '获取排序的会话列表失败', $adminToken);
|
||||
return Utils::send(Url::$getSortedConversationList, [
|
||||
'userID' => $userID,
|
||||
'conversationIDs' => $conversationIDs,
|
||||
'pagination' => [
|
||||
'pageNumber' => $page,
|
||||
'showNumber' => $pagesize
|
||||
]
|
||||
], '获取排序的会话列表失败', $adminToken);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,9 @@ use support\OpenImSdk\Core\Utils;
|
||||
|
||||
class Group
|
||||
{
|
||||
function setGroupInfo($data=[]){
|
||||
return Utils::send('/group/set_group_info_ex', $data);
|
||||
}
|
||||
/**
|
||||
* 创建群组
|
||||
* @param string $ownerUserID 群主ID
|
||||
@@ -94,22 +97,23 @@ class Group
|
||||
/**
|
||||
* 获取群成员列表
|
||||
* @param string $groupID 群组ID
|
||||
* @param int $filter 过滤类型,0所有,1群主,2管理员,3普通成员,4禁言,5进入黑名单
|
||||
* @param string $filter 过滤类型,0所有,1群主,2管理员,3普通成员,4禁言,5进入黑名单
|
||||
* @param int $offset 偏移量
|
||||
* @param int $count 数量
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMemberList(string $groupID, int $filter = 0, int $offset = 0, int $count = 100): array
|
||||
public function getGroupMemberList(string $groupID='', string $keyword = '', int $page = 1, int $pagesize = 100): array
|
||||
{
|
||||
// 获取管理员token
|
||||
$adminToken = Utils::getAdminToken();
|
||||
$data = [
|
||||
'groupID' => $groupID,
|
||||
'filter' => $filter,
|
||||
'offset' => $offset,
|
||||
'count' => $count
|
||||
'keyword' => $keyword,
|
||||
'pagination' => [
|
||||
'pageNumber' => $page,
|
||||
'showNumber' => $pagesize
|
||||
]
|
||||
];
|
||||
return Utils::send(Url::$getGroupMemberList, $data, '获取群成员列表失败', $adminToken);
|
||||
return Utils::send(Url::$getGroupMemberList, $data, '获取群成员列表失败');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,48 @@ use support\OpenImSdk\Core\Url;
|
||||
use support\OpenImSdk\Core\Utils;
|
||||
|
||||
class Message
|
||||
{
|
||||
{
|
||||
public function sendSingleMessage(string $sendID, string $recvID = '', array $data=[]): array
|
||||
{
|
||||
$data['recvID'] = $recvID;
|
||||
$data['groupID'] = '';
|
||||
$data['sessionType'] = 2;
|
||||
return $this->sendMessage($sendID,$data);
|
||||
}
|
||||
public function sendGroupMessage(string $sendID, string $groupID = '', array $data=[]): array
|
||||
{
|
||||
$data['recvID'] = '';
|
||||
$data['groupID'] = $groupID;
|
||||
$data['sessionType'] = 3;
|
||||
return $this->sendMessage($sendID,$data);
|
||||
}
|
||||
public function sendMessage(string $sendID, array $data=[]): array
|
||||
{
|
||||
$user = \think\facade\Db::name('user')->where('id',$sendID)->field('avatar,nickname')->find();
|
||||
$data = array_merge([
|
||||
"sendID" => $sendID,
|
||||
"senderNickname" => $user['nickname'],
|
||||
"senderFaceURL" => $user['avatar'],
|
||||
"senderPlatformID" => 5,
|
||||
"content"=> [
|
||||
"content" => "hello!!"
|
||||
],
|
||||
"contentType" => 1,
|
||||
"sessionType" => 4,
|
||||
"isOnlineOnly" => false,
|
||||
"notOfflinePush"=> true,
|
||||
"sendTime" => time()*1000,
|
||||
"offlinePushInfo"=> [
|
||||
"title" => "您收到一条新的消息",
|
||||
"desc" => "",
|
||||
"ex" => "",
|
||||
"iOSPushSound"=> "default",
|
||||
"iOSBadgeCount"=> true
|
||||
],
|
||||
"ex"=> ""
|
||||
],$data);
|
||||
return Utils::send(Url::$sendMsg, $data);
|
||||
}
|
||||
/**
|
||||
* 发送消息
|
||||
* @param string $sendID 发送者ID
|
||||
@@ -156,16 +197,21 @@ class Message
|
||||
*/
|
||||
public function sendBusinessNotification(string $sendID, string $recvID, array $data,string $type='user'): array
|
||||
{
|
||||
$key = isset($data['key']) ? $data['key'] : md5(time());
|
||||
$sendMsg = isset($data['sendMsg']) ? $data['sendMsg'] : true;
|
||||
unset($data['key']);
|
||||
unset($data['sendMsg']);
|
||||
// 获取管理员token
|
||||
$data = [
|
||||
'sendUserID' => $sendID,
|
||||
'recvUserID' => $type=='user' ? $recvID : '',
|
||||
'recvGroupID' => $type=='user' ? '': $recvID,
|
||||
'key' => md5(time()),
|
||||
'data' => json_encode($data),
|
||||
'sendMsg' => true,
|
||||
'sendUserID' => $sendID,
|
||||
'recvUserID' => $type=='user' ? $recvID : '',
|
||||
'recvGroupID' => $type=='user' ? '': $recvID,
|
||||
'key' => $key,
|
||||
'data' => json_encode($data),
|
||||
'sendMsg' => $sendMsg,
|
||||
'reliabilityLevel' => 1,
|
||||
];
|
||||
//log_alert($data);
|
||||
return Utils::send(Url::$sendBusinessNotification, $data, '发送业务通知失败');
|
||||
}
|
||||
|
||||
|
||||
@@ -134,13 +134,13 @@ class User
|
||||
* @param string $ex 扩展字段
|
||||
* @return array
|
||||
*/
|
||||
public function addNotificationAccount(string $userID, string $nickname = '', string $faceURL = '', int $appMangerLevel = 3): array
|
||||
public function addNotificationAccount(string $userID, string $nickname = '', string $faceURL = '', \support\OpenImSdk\Enum\appMangerLevel $appMangerLevel = \support\OpenImSdk\Enum\appMangerLevel::Notify): array
|
||||
{
|
||||
$data = [
|
||||
'userID' => $userID,
|
||||
'nickname' => $nickname,
|
||||
'faceURL' => $faceURL,
|
||||
'appMangerLevel' => $appMangerLevel,
|
||||
'appMangerLevel' => $appMangerLevel->value,
|
||||
];
|
||||
return Utils::send(Url::$addNotificationAccount, $data, '添加通知账号错误');
|
||||
}
|
||||
|
||||
@@ -81,15 +81,17 @@ class Utils
|
||||
* @param string $token 认证令牌
|
||||
* @return array 响应数据
|
||||
*/
|
||||
public static function send(string $path, array $data, string $errMsg, string $token = ''): array|bool
|
||||
public static function send(string $path, array $data, string $errMsg='', string $token = ''): array|bool
|
||||
{
|
||||
|
||||
$token = $token ? $token : Utils::getAdminToken();
|
||||
if($path != Url::$getAdminToken){
|
||||
$token = $token ? $token : Utils::getAdminToken();
|
||||
}
|
||||
$url = Url::buildUrl($path);
|
||||
//cp($url);
|
||||
log_alert($url);
|
||||
//log_alert($data);
|
||||
$res = self::request($url, $data, $token);
|
||||
//cp($data);
|
||||
//cp($res);
|
||||
//log_alert($res);
|
||||
$res = json_decode($res, true);
|
||||
if($res['errCode'] !==0 ){
|
||||
throw new \Exception($res['errMsg'],$res['errCode']);
|
||||
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace support\OpenImSdk\Enum;
|
||||
trait BaseEnum {
|
||||
public static function toArray(): array
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
/**
|
||||
* 获取当前状态的描述文本
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return self::toArray()[$this->value];
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全地从值创建枚举实例
|
||||
*/
|
||||
public static function tryFromValue(int $value): ?self
|
||||
{
|
||||
return self::tryFrom($value);
|
||||
}
|
||||
}
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace support\OpenImSdk\Enum;
|
||||
enum appMangerLevel : int{
|
||||
use BaseEnum;
|
||||
/*系统通知号;*/
|
||||
case Notify=3;
|
||||
/*机器人账号;*/
|
||||
case Bot=4;
|
||||
|
||||
/**
|
||||
* 获取所有状态映射数组
|
||||
*/
|
||||
public static function toArray(): array
|
||||
{
|
||||
return [
|
||||
self::Notify->value => __('系统通知号'),
|
||||
self::Bot->value => __('机器人账号'),
|
||||
];
|
||||
}
|
||||
|
||||
};
|
||||
@@ -86,6 +86,8 @@ class Random
|
||||
case 'encrypt':
|
||||
case 'sha1':
|
||||
return sha1(uniqid(mt_rand(), true));
|
||||
default:
|
||||
return substr(str_shuffle(str_repeat($type, ceil($len / strlen($type)))), 0, $len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user