-
Notifications
You must be signed in to change notification settings - Fork 12
/
Blacklist.php
126 lines (117 loc) · 3.47 KB
/
Blacklist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
/**
* 用户关系 黑名单
* User: hejinyu
* Date: 2018/7/23
* Time: 11:41
*/
namespace RongCloud\Lib\User\Blacklist;
use RongCloud\Lib\Request;
use RongCloud\Lib\Utils;
class Blacklist {
/**
* 用户模块黑名单路径
*
* @var string
*/
private $jsonPath = 'Lib/User/Blacklist/';
/**
* 请求配置文件
*
* @var string
*/
private $conf = "";
/**
* 校验配置文件
*
* @var string
*/
private $verify = "";
/**
* User constructor.
*/
function __construct()
{
//初始化请求配置和校验文件路径
$this->conf = Utils::getJson($this->jsonPath.'api.json');
$this->verify = Utils::getJson($this->jsonPath.'../verify.json');
}
/**
* @param $User array 添加黑名单
* @param
* $user = [
'id'=> 'ujadk90ha',//用户 id
'blacklist'=> ['kkj9o01'] //需要添加黑名单的人员列表
];
* @return array
*/
public function add(array $User=[]){
$conf = $this->conf['add'];
$error = (new Utils())->check([
'api'=> $conf,
'model'=> 'user',
'data'=> $User,
'verify'=> $this->verify['user']
]);
if($error) return $error;
$User = (new Utils())->rename($User, [
'id'=> 'userId',
'blacklist'=> 'blackUserId'
]);
$result = (new Request())->Request($conf['url'],$User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* @param $User array 移除黑名单
* @param
* $user = [
'id'=> 'ujadk90ha',//用户 id
'blacklist'=> ['kkj9o01'] //需要移除黑名单的人员列表
];
* @return array
*/
public function remove(array $User=[]){
$conf = $this->conf['remove'];
$error = (new Utils())->check([
'api'=> $conf,
'model'=> 'user',
'data'=> $User,
'verify'=> $this->verify['user']
]);
if($error) return $error;
$User = (new Utils())->rename($User, [
'id'=> 'userId',
'blacklist'=> 'blackUserId'
]);
$result = (new Request())->Request($conf['url'],$User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* @param $User array 获取某个用户的黑名单列表
* @param
* $user = [
'id'=> 'ujadk90ha',//用户 id
'size'=> 1000,//分页获取黑名单用户列表时每页行数,不传时默认为 1000条,最大不超过 1000 条
'pageToken'=> ''//分页信息,上一次请求返回 next ,不传时不做分页处理,默认获取前 1000 个用户列表,按加入黑名单时间倒序排序。
];
* @return array
*/
public function getList(array $User=[]){
$conf = $this->conf['getList'];
$error = (new Utils())->check([
'api'=> $conf,
'model'=> 'user',
'data'=> $User,
'verify'=> $this->verify['user']
]);
if($error) return $error;
$User = (new Utils())->rename($User, [
'id'=> 'userId',
]);
$result = (new Request())->Request($conf['url'],$User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
}