Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9300e8ecc | ||
|
|
368388e7bd | ||
|
|
969de83e1f | ||
|
|
8f74e54c88 | ||
|
|
efd9d5519f | ||
|
|
97b6ccb910 | ||
|
|
c51f523d6e | ||
|
|
298ce69db7 | ||
|
|
15c2d8f59e | ||
|
|
8322134e18 | ||
|
|
52b624f25e | ||
|
|
d90bab53ad | ||
|
|
4d60231c8c | ||
|
|
d08d6f0c49 | ||
|
|
effa30b546 | ||
|
|
0f688ff1df | ||
|
|
daa4767ed8 | ||
|
|
44a916892b | ||
|
|
51dd94d3a7 | ||
|
|
2609a4251c | ||
|
|
7d36775c27 | ||
|
|
6c9df5c071 | ||
|
|
2f9c4e028c | ||
|
|
a9b83a14ed | ||
|
|
919b81139d | ||
|
|
52959a5e63 | ||
|
|
31dad28fde | ||
|
|
3094089658 | ||
|
|
24d24fe1e9 | ||
|
|
47039f53b2 | ||
|
|
554243d553 | ||
|
|
b65282f8e2 | ||
|
|
a5f64df2de | ||
|
|
c7f1ea57dc | ||
|
|
c9b2de076d | ||
|
|
552fadaa87 | ||
|
|
765572db36 | ||
|
|
a5f194b385 | ||
|
|
c74cd7e290 | ||
|
|
70cf65f0c0 | ||
|
|
3bb23f92c4 | ||
|
|
804c12845e | ||
|
|
fe15a32499 | ||
|
|
06d168935d | ||
|
|
c1984d27b3 | ||
|
|
29ef46b7a0 | ||
|
|
0bdff3fd89 | ||
|
|
cd03583dab | ||
|
|
3f8fd7e5e0 | ||
|
|
fdfe71f700 | ||
|
|
35ecf7ccc6 | ||
|
|
8f798742c3 | ||
|
|
f4ea8b184c | ||
|
|
2d7f344b1a | ||
|
|
bee03cd2f8 | ||
|
|
59b1c3180f |
@@ -158,6 +158,14 @@ mvn clean package
|
||||
## 服务对象
|
||||
因为野火的使用范围比较广,难免被一些不法分子利用,国内反诈反赌力度很大,所以国内多地警方都跟我们都有过联系。***为了预防我们的产品被用于非法目的,试用及购买只能支持境内法人单位,不接受个人或者境外团体。如果我们发现产品被用于非法目的,我们会立即停止技术支持服务并且报警和配合警方调查。请用于非法目的用户绕行!***
|
||||
|
||||
## 群的性能问题
|
||||
群的大小和性能不是线性相关的,而是O(N²)的关系,这是群的特性决定的。所以社区版IM服务很难支持很大的群人数,我们建议最大群不要超过500人,像微信的群大小一样。修改方法是修改数据库中```t_settings```表中的群最大人数。
|
||||
|
||||
如果是专业版IM服务,普通群性能会有些加强,但也不会提高太多,所以我们就开发了超级群,可以支持上万群成员。关于超级群,请参考[野火超级群组](https://mp.weixin.qq.com/s/ov5ZiaEIUZuvgFBXOrcjbg)。现有客户有接近10W的群组成员能够流畅稳定地运行。
|
||||
|
||||
## 网络问题
|
||||
如果是自建机房或者私有网络,可能会有跨运营商瓶颈,详情请参考[《从野火 IM 的网络踩坑经历,聊聊跨运营商访问的那些坑》](https://mp.weixin.qq.com/s/Pa8b93oMk58fjMgwtwmePQ)。
|
||||
|
||||
## 常见问题
|
||||
请参考文档[常见问题](https://docs.wildfirechat.cn/faq/server.html)
|
||||
|
||||
|
||||
@@ -170,6 +170,16 @@ robot.callback_with_sender_info false
|
||||
## 机器人回调信息是否带上目标的信息,单聊时是对方用户信息,群聊时是群组信息,频道时是频道信息
|
||||
robot.callback_with_target_info false
|
||||
|
||||
## 是否允许@会话外的机器人。如果为true,单聊或者群聊时,可以@不在会话中的机器人。当机器人收到消息后,可以回复消息。
|
||||
## 如果为false,不能@不在会话中的机器人。机器人不在会话中时,也不能回复消息。
|
||||
robot.mention_external_robot true
|
||||
|
||||
## 机器人获取信息允许的字段,可以获取userId/displayName/portrait,其他需要这里配置允许。
|
||||
## 第一位(1)是name, 第二位(2)是mobile,第三(4)位是email,第四位(8)是address,第五位(16)是company,第六位(32)是extra,
|
||||
## 第七位(64)是updateDt,第八位(128)是gender,第九位(256)是social,第十位(512)是type。
|
||||
## 比如允许获取name和email就是5(1+4),允许获取name和mobile和company和type就是531(1+2+16+512),允许全部是1023(1+2+...+512)
|
||||
#robot.get_user_info_mask 1023
|
||||
|
||||
## 频道回调信息是否带上用户clientId和平台类型。
|
||||
channel.callback_with_client_info false
|
||||
|
||||
@@ -189,8 +199,8 @@ friend.disable_search false
|
||||
##禁止按照昵称搜索用户。
|
||||
friend.disable_nick_name_search false
|
||||
|
||||
##禁止按照用户id搜索用户,默认为true。
|
||||
friend.disable_user_id_search true
|
||||
##禁止按照用户id搜索用户,默认为false。
|
||||
friend.disable_user_id_search false
|
||||
|
||||
##禁止发送好友邀请,通过server api添加好友不受此限制(force参数需要为true)
|
||||
friend.disable_friend_request false
|
||||
@@ -207,6 +217,12 @@ friend.request_expiration_duration 604800000
|
||||
##好友请求限制频率,一个用户24小时之内允许请求好友的次数,默认不限频。
|
||||
friend.request_rate_limit 30
|
||||
|
||||
##如果搜索电话号码,24小时内搜索错误号码几次就不再允许电话号码搜素。防止有人遍历搜索电话号码
|
||||
friend.search_mobile_empty_rate_limit 5
|
||||
|
||||
##如果搜索用户,24小时内搜索次数。防止有人遍历用户名或者用户ID乱加好友。另外可以禁止ID搜索friend.disable_user_id_search
|
||||
friend.search_rate_limit 100
|
||||
|
||||
##请求添加机器人为好友时,机器人是否自动接受,默认为true
|
||||
friend.robot_auto_accept true
|
||||
|
||||
@@ -263,6 +279,16 @@ group.enable_mark_deletion true
|
||||
## 销毁用户时,用户信息会被清空,deleted字段设置为1,这个开关控制是否保留用户昵称,默认为true。
|
||||
user.keep_display_name_when_destroy true
|
||||
|
||||
## 销毁用户时deleted字段设置为1,这个开关控制是否保留其他信息,默认是false。
|
||||
user.keep_full_info_when_destroy false
|
||||
|
||||
## 销毁用户时,如果user.keep_full_info_when_destroy为true,会保留所有信息,这个开关控制是否保留这个用户信息的电话号码,默认为false。
|
||||
## 当保留所有信息且保留电话号码时,用户如果再注册会用到原来的UID,能够看到原来用户的消息,需要考虑一下是否让已删除用户再次注册登录看到之前的消息。
|
||||
user.keep_mobile_when_destroy false
|
||||
|
||||
## 销毁用户时是否保留归属于这个用户的所有消息记录,默认为false。
|
||||
user.keep_messages_when_destroy false
|
||||
|
||||
# 好友/好友请求/用户设置 这三类数据同步的最大条目数。之前是客户第一次登录时,会把所有的对应数据一次下载到客户端,但如果有特别多的信息,会导致无法同步到客户端,
|
||||
# 因此需要分段多次同步,此开关定义了每次同步的数据的条数。此需要客户端支持,客户端SDK在2021.5.25日后支持此功能。如果确认所有客户端都在这个日志之后才可以打开此设置。
|
||||
#sync.data_part_size 1000
|
||||
@@ -314,6 +340,13 @@ qiniu.bucket_portrait_name storage
|
||||
qiniu.bucket_portrait_domain http://cdn2.wildfirechat.cn
|
||||
qiniu.bucket_favorite_name storage
|
||||
qiniu.bucket_favorite_domain http://cdn2.wildfirechat.cn
|
||||
## custom的桶是给客户预留的,客户可以上传自己的文件到这3个桶中,野火不会用到这几个桶。如果不需要,可以忽略这几个配置
|
||||
qiniu.bucket_custom1_name temp1
|
||||
qiniu.bucket_custom1_domain http://temp1.wildfirechat.cn
|
||||
qiniu.bucket_custom2_name temp2
|
||||
qiniu.bucket_custom2_domain http://temp2.wildfirechat.cn
|
||||
qiniu.bucket_custom3_name temp3
|
||||
qiniu.bucket_custom3_domain http://temp3.wildfirechat.cn
|
||||
|
||||
##媒体类型分类
|
||||
#Media_Type_GENERAL = 0,
|
||||
@@ -448,6 +481,10 @@ push.harmony.server.address http://localhost:8085/harmony/push
|
||||
## 如果开启 message.sensitive.forward.url 配置,命中敏感词的消息还会被回调到这个地址
|
||||
sensitive.filter.type 2
|
||||
|
||||
## 敏感词是否只处理消息。如果为true,只过滤消息;如果为false,会同时过滤用户昵称、群组名和群昵称。
|
||||
## 除了消息之外的信息只支持内部敏感词处理,不支持外置审核。
|
||||
sensitive.only_message false
|
||||
|
||||
## 敏感词添加或者删除有2种方式,一种是通过Server API进行,这种方式会立即生效。另外一种方法是修改数据库,直接中数据库的t_sensitive_word表中处理
|
||||
## 修改数据库的方法不会立即生效,IM服务会2个小时重新加载一次敏感词。所以如果直接修改敏感词表,需要等2个小时,或者重启才能生效。
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
CREATE INDEX `user_gid_mid_dt_index` ON `t_group_member` (`_gid`, `_mid`, `_dt`);
|
||||
CREATE INDEX `user_gid_dt_index` ON `t_group_member` (`_gid`, `_dt`);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
insert into t_settings(`id`, `_value`,`_desc`) values (2, '文件传输助手,客服,官方', '禁止使用名称,如果有多个,以英文逗号隔开。直接修改数据库,不用重启IM服务');
|
||||
+1
@@ -0,0 +1 @@
|
||||
alter table `t_messages` modify column `_target` varchar(129) NOT NULL;
|
||||
+1
@@ -0,0 +1 @@
|
||||
ALTER TABLE `t_user_session` ADD COLUMN `_ip` varchar(40) DEFAULT '';
|
||||
+1
@@ -0,0 +1 @@
|
||||
CREATE INDEX `user_gid_type_index` ON `t_group_member` (`_gid`, `_type`);
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_conference`;
|
||||
CREATE TABLE `t_conference` (
|
||||
`_id` varchar(64) NOT NULL PRIMARY KEY,
|
||||
`_des` varchar(64) NOT NULL,
|
||||
`_pin` varchar(16) NOT NULL,
|
||||
`_max_publishers` int(11) NOT NULL DEFAULT 0,
|
||||
`_bitrate` int(11) NOT NULL DEFAULT 0,
|
||||
`_advance` tinyint NOT NULL DEFAULT 0,
|
||||
`_recording` tinyint NOT NULL DEFAULT 0,
|
||||
`_create_dt` bigint(20) NOT NULL
|
||||
);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
DROP TABLE IF EXISTS `t_join_group_request`;
|
||||
CREATE TABLE `t_join_group_request` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`_uid` varchar(64) NOT NULL,
|
||||
`_gid` varchar(64) NOT NULL,
|
||||
`_mid` varchar(64) NOT NULL,
|
||||
`_request_uid` varchar(64) NOT NULL,
|
||||
`_accept_uid` varchar(64) DEFAULT NULL,
|
||||
`_reason` TEXT DEFAULT NULL,
|
||||
`_extra` TEXT DEFAULT NULL,
|
||||
`_status` tinyint NOT NULL DEFAULT 0,
|
||||
`_dt` bigint(20) NOT NULL,
|
||||
`_read_status` tinyint DEFAULT 0,
|
||||
UNIQUE INDEX `join_group_request_key_index` (`_uid` DESC, `_gid` DESC, `_mid` DESC, `_request_uid` DESC),
|
||||
INDEX `join_group_request_gm_index` (`_gid` DESC, `_mid` DESC),
|
||||
INDEX `join_group_request_sync_index` (`_uid` DESC, `_dt` DESC)
|
||||
);
|
||||
+1
@@ -0,0 +1 @@
|
||||
alter table t_friend add index `friend_uid_index` (`_friend_uid`);
|
||||
@@ -0,0 +1,2 @@
|
||||
DROP INDEX `user_gid_mid_dt_index` ON `t_group_member`;
|
||||
CREATE INDEX `user_gid_dt_index` ON `t_group_member` (`_gid`, `_dt`);
|
||||
@@ -0,0 +1 @@
|
||||
insert into t_settings(`id`, `_value`,`_desc`) values (2, '文件传输助手,客服,官方', '禁止使用名称,如果有多个,以英文逗号隔开。直接修改数据库,不用重启IM服务');
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
alter table `t_messages` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_0` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_1` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_2` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_3` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_4` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_5` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_6` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_7` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_8` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_9` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_10` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_11` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_12` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_13` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_14` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_15` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_16` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_17` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_18` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_19` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_20` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_21` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_22` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_23` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_24` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_25` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_26` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_27` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_28` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_29` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_30` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_31` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_32` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_33` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_34` modify column `_target` varchar(129) NOT NULL;
|
||||
alter table `t_messages_35` modify column `_target` varchar(129) NOT NULL;
|
||||
+1
@@ -0,0 +1 @@
|
||||
ALTER TABLE `t_user_session` ADD COLUMN `_ip` varchar(40) DEFAULT '';
|
||||
@@ -0,0 +1 @@
|
||||
CREATE INDEX `user_gid_type_index` ON `t_group_member` (`_gid`, `_type`);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_conference`;
|
||||
CREATE TABLE `t_conference` (
|
||||
`_id` varchar(64) NOT NULL PRIMARY KEY,
|
||||
`_des` varchar(64) NOT NULL,
|
||||
`_pin` varchar(16) NOT NULL,
|
||||
`_max_publishers` int(11) NOT NULL DEFAULT 0,
|
||||
`_bitrate` int(11) NOT NULL DEFAULT 0,
|
||||
`_advance` tinyint NOT NULL DEFAULT 0,
|
||||
`_recording` tinyint NOT NULL DEFAULT 0,
|
||||
`_create_dt` bigint(20) NOT NULL
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_join_group_request`;
|
||||
CREATE TABLE `t_join_group_request` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`_uid` varchar(64) NOT NULL,
|
||||
`_gid` varchar(64) NOT NULL,
|
||||
`_mid` varchar(64) NOT NULL,
|
||||
`_request_uid` varchar(64) NOT NULL,
|
||||
`_accept_uid` varchar(64) DEFAULT NULL,
|
||||
`_reason` TEXT DEFAULT NULL,
|
||||
`_extra` TEXT DEFAULT NULL,
|
||||
`_status` tinyint NOT NULL DEFAULT 0,
|
||||
`_dt` bigint(20) NOT NULL,
|
||||
`_read_status` tinyint DEFAULT 0,
|
||||
UNIQUE INDEX `join_group_request_key_index` (`_uid` DESC, `_gid` DESC, `_mid` DESC, `_request_uid` DESC),
|
||||
INDEX `join_group_request_gm_index` (`_gid` DESC, `_mid` DESC),
|
||||
INDEX `join_group_request_sync_index` (`_uid` DESC, `_dt` DESC)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
+1
@@ -0,0 +1 @@
|
||||
alter table t_friend add index `friend_uid_index` (`_friend_uid`);
|
||||
+1
-55
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>1.3.7</version>
|
||||
<version>1.4.5</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>moquette-broker</artifactId>
|
||||
@@ -211,60 +211,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Generate the test-jar -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Includes to generate OSGi headers -->
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>bundle-manifest</id>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>manifest</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
|
||||
@@ -35,6 +35,9 @@ public class ThreadPoolExecutorWrapper {
|
||||
executor.execute(() -> {
|
||||
try {
|
||||
task.run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOG.info("execute error = {}", e.toString());
|
||||
} finally {
|
||||
int endCount = runCounter.decrementAndGet();
|
||||
LOG.debug("Finish task and current task count {} use time {}", endCount, System.currentTimeMillis()-startTime);
|
||||
|
||||
@@ -11,6 +11,7 @@ package com.xiaoleilu.loServer.action;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
@@ -28,7 +29,9 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Base64;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route("/route")
|
||||
@@ -111,6 +114,12 @@ public class RouteAction extends Action {
|
||||
WFCMessage.IMHttpWrapper wrapper = WFCMessage.IMHttpWrapper.parseFrom(bytes);
|
||||
String token = wrapper.getToken();
|
||||
String userId = Tokenor.getUserId(token.getBytes());
|
||||
|
||||
String remote = ((InetSocketAddress) ctx.channel().remoteAddress())
|
||||
.getAddress().getHostAddress();
|
||||
String ip = computeRealIp(request.getHeaders(), remote);
|
||||
|
||||
|
||||
LOG.info("RouteAction token={}, userId={}", token, userId);
|
||||
if (userId == null) {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TOKEN_ERROR, null);
|
||||
@@ -119,6 +128,8 @@ public class RouteAction extends Action {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
sendResponse(response, null, result);
|
||||
//save ip after success response.
|
||||
sessionsStore.updateSessionIp(userId, wrapper.getClientId(), ip);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,6 +158,20 @@ public class RouteAction extends Action {
|
||||
return true;
|
||||
}
|
||||
|
||||
private String computeRealIp(Map<String, String> h, String remote) {
|
||||
String xff = h.get("X-Forwarded-For");
|
||||
if (xff != null && !xff.isEmpty() && !"unknown".equalsIgnoreCase(xff)) {
|
||||
int idx = xff.indexOf(',');
|
||||
String first = (idx > 0 ? xff.substring(0, idx) : xff).trim();
|
||||
return first;
|
||||
}
|
||||
String xri = h.get("X-Real-IP");
|
||||
if (xri != null && !xri.isEmpty() && !"unknown".equalsIgnoreCase(xri)) {
|
||||
return xri;
|
||||
}
|
||||
return remote;
|
||||
}
|
||||
|
||||
private void sendResponse(Response response, ErrorCode errorCode, byte[] contents) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
if (contents == null) {
|
||||
|
||||
@@ -24,6 +24,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
@@ -213,7 +215,7 @@ public class UploadFileAction extends Action {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
remoteFileName = getSafeFileName(remoteFileName);
|
||||
|
||||
String remoteFileExt = "";
|
||||
if (remoteFileName.lastIndexOf(".") == -1) {
|
||||
@@ -339,6 +341,15 @@ public class UploadFileAction extends Action {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String getSafeFileName(String originalFilename) {
|
||||
// Paths.get() 会解析路径,getFileName() 只取最后一部分(纯文件名)
|
||||
Path filenamePath = Paths.get(originalFilename.trim());
|
||||
String safeFilename = filenamePath.getFileName().toString();
|
||||
// 额外过滤特殊字符(可选,根据业务需要)
|
||||
safeFilename = safeFilename.replaceAll("[\\\\/:*?\"<>|]", "_");
|
||||
return safeFilename.isEmpty() ? "default_file_" + System.currentTimeMillis() : safeFilename;
|
||||
}
|
||||
|
||||
public static void put(File file, long pos, byte[] data) throws Exception {
|
||||
RandomAccessFile raf = null;
|
||||
try {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class CreateUserAction extends AdminAction {
|
||||
if (inputCreateUser.getName() != null)
|
||||
newUserBuilder.setName(inputCreateUser.getName());
|
||||
if (inputCreateUser.getDisplayName() != null)
|
||||
newUserBuilder.setDisplayName(StringUtil.isNullOrEmpty(inputCreateUser.getDisplayName()) ? inputCreateUser.getName() : inputCreateUser.getDisplayName());
|
||||
newUserBuilder.setDisplayName(inputCreateUser.getDisplayName());
|
||||
if (inputCreateUser.getPortrait() != null)
|
||||
newUserBuilder.setPortrait(inputCreateUser.getPortrait());
|
||||
if (inputCreateUser.getEmail() != null)
|
||||
@@ -65,11 +65,8 @@ public class CreateUserAction extends AdminAction {
|
||||
newUserBuilder.setAddress(inputCreateUser.getAddress());
|
||||
if (inputCreateUser.getCompany() != null)
|
||||
newUserBuilder.setCompany(inputCreateUser.getCompany());
|
||||
|
||||
if (inputCreateUser.getSocial() != null)
|
||||
newUserBuilder.setSocial(inputCreateUser.getSocial());
|
||||
|
||||
|
||||
if (inputCreateUser.getMobile() != null)
|
||||
newUserBuilder.setMobile(inputCreateUser.getMobile());
|
||||
newUserBuilder.setGender(inputCreateUser.getGender());
|
||||
|
||||
@@ -11,12 +11,17 @@ package com.xiaoleilu.loServer.action.admin;
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputUpdateFriendExtra;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
@Route(APIPath.Friend_Set_Extra)
|
||||
@HttpMethod("POST")
|
||||
@@ -31,8 +36,17 @@ public class FriendExtraPutAction extends AdminAction {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputUpdateFriendExtra input = getRequestBody(request.getNettyRequest(), InputUpdateFriendExtra.class);
|
||||
ErrorCode errorCode = messagesStore.setFriendExtraRequest(input.getOperator(), input.getTargetId(), input.getExtra(), new long[1]);
|
||||
setResponseContent(RestResult.resultOf(errorCode), response);
|
||||
if (input != null && !StringUtil.isNullOrEmpty(input.getOperator()) && !StringUtil.isNullOrEmpty(input.getTargetId())) {
|
||||
sendApiMessage(response, input.getOperator(), IMTopic.SetFriendExtraTopic, WFCMessage.StringPair.newBuilder().setKey(input.getTargetId()).setValue(input.getExtra()==null?"":input.getExtra()).build().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class GetUserAction extends AdminAction {
|
||||
}
|
||||
|
||||
RestResult result;
|
||||
if (user == null || user.getDeleted() > 0) {
|
||||
if (user == null || (user.getDeleted() > 0 && !inputUserId.isIncludeDeleted())) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
} else {
|
||||
result = RestResult.ok(InputOutputUserInfo.fromPbUser(user));
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputRobotId;
|
||||
import cn.wildfirechat.pojos.InputUserId;
|
||||
import cn.wildfirechat.pojos.OutputRobot;
|
||||
import cn.wildfirechat.pojos.OutputStringList;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
@Route(APIPath.User_Get_User_Robots)
|
||||
@HttpMethod("POST")
|
||||
public class GetUserRobotsAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputUserId inputUserId = getRequestBody(request.getNettyRequest(), InputUserId.class);
|
||||
if (inputUserId != null
|
||||
&& (!StringUtil.isNullOrEmpty(inputUserId.getUserId()))) {
|
||||
RestResult result = RestResult.ok(new OutputStringList(messagesStore.getUserRobotIds(inputUserId.getUserId())));
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class SendMessageAction extends AdminAction {
|
||||
} else {
|
||||
return new Result(errorCode);
|
||||
}
|
||||
});
|
||||
}, sendMessageData.isUserMessage());
|
||||
return false;
|
||||
} else {
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
|
||||
@@ -47,7 +47,39 @@ public class GetUserAction extends RobotAction {
|
||||
if (user == null || user.getDeleted() > 0) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
} else {
|
||||
result = RestResult.ok(InputOutputUserInfo.fromPbUser(user));
|
||||
InputOutputUserInfo outputUserInfo = InputOutputUserInfo.fromPbUser(user);
|
||||
int mask = messagesStore.getRobotGetUserInfoMask();
|
||||
if((mask & 1) == 0) {
|
||||
outputUserInfo.setName(null);
|
||||
}
|
||||
if((mask & 2) == 0) {
|
||||
outputUserInfo.setMobile(null);
|
||||
}
|
||||
if((mask & 4) == 0) {
|
||||
outputUserInfo.setEmail(null);
|
||||
}
|
||||
if((mask & 8) == 0) {
|
||||
outputUserInfo.setAddress(null);
|
||||
}
|
||||
if((mask & 16) == 0) {
|
||||
outputUserInfo.setCompany(null);
|
||||
}
|
||||
if((mask & 32) == 0) {
|
||||
outputUserInfo.setExtra(null);
|
||||
}
|
||||
if((mask & 64) == 0) {
|
||||
outputUserInfo.setUpdateDt(0);
|
||||
}
|
||||
if((mask & 128) == 0) {
|
||||
outputUserInfo.setGender(0);
|
||||
}
|
||||
if((mask & 256) == 0) {
|
||||
outputUserInfo.setSocial(null);
|
||||
}
|
||||
if((mask & 512) == 0) {
|
||||
outputUserInfo.setType(0);
|
||||
}
|
||||
result = RestResult.ok(outputUserInfo);
|
||||
}
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.robot;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.Conversation;
|
||||
import cn.wildfirechat.pojos.ReplyMessageData;
|
||||
import cn.wildfirechat.pojos.SendMessageData;
|
||||
import cn.wildfirechat.pojos.SendMessageResult;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Route(APIPath.Robot_Message_Reply)
|
||||
@HttpMethod("POST")
|
||||
public class ReplyMessageAction extends RobotAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
ReplyMessageData replyMessageData = getRequestBody(request.getNettyRequest(), ReplyMessageData.class);
|
||||
if (ReplyMessageData.isValide(replyMessageData)) {
|
||||
WFCMessage.Message message = messagesStore.getMessage(replyMessageData.getMessageUid());
|
||||
ErrorCode errorCode = null;
|
||||
if(message == null) {
|
||||
errorCode = ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
} else if(!message.getContent().getMentionedTargetList().contains(robot.getUid())) {
|
||||
errorCode = ErrorCode.ERROR_CODE_INVALID_MESSAGE;
|
||||
} else if(message.getConversation().getType() != ProtoConstants.ConversationType.ConversationType_Private && message.getConversation().getType() != ProtoConstants.ConversationType.ConversationType_Group) {
|
||||
errorCode = ErrorCode.ERROR_CODE_NOT_IMPLEMENT;
|
||||
} else if(System.currentTimeMillis() - message.getServerTimestamp() > 15*60*1000) {
|
||||
errorCode = ErrorCode.ERROR_CODE_RECALL_TIME_EXPIRED;
|
||||
} else if(!messagesStore.isRobotMentionExternalRobot()) {
|
||||
if(message.getConversation().getType() != ProtoConstants.ConversationType.ConversationType_Group) {
|
||||
errorCode = ErrorCode.ERROR_CODE_NOT_IMPLEMENT;
|
||||
} else {
|
||||
WFCMessage.GroupMember member = messagesStore.getGroupMember(message.getConversation().getTarget(), robot.getUid());
|
||||
if(member == null || member.getType() == ProtoConstants.GroupMemberType.GroupMemberType_Removed) {
|
||||
errorCode = ErrorCode.ERROR_CODE_NOT_IMPLEMENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(errorCode != null) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(errorCode);
|
||||
response.setContent(gson.toJson(result));
|
||||
return true;
|
||||
}
|
||||
|
||||
SendMessageData sendMessageData = getSendMessageData(message, replyMessageData);
|
||||
WFCMessage.Message newMsg = sendMessageData.toProtoMessage().toBuilder().setMessageId(message.getMessageId()).build();
|
||||
sendApiRequest(response, IMTopic.RobotReplyMessageTopic, newMsg.toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode ec = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (ec == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long timestamp = byteBuf.readLong();
|
||||
sendResponse(response, null, new SendMessageResult(messageId, timestamp));
|
||||
} else {
|
||||
sendResponse(response, ec, null);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private @NotNull SendMessageData getSendMessageData(WFCMessage.Message message, ReplyMessageData replyMessageData) {
|
||||
SendMessageData sendMessageData = new SendMessageData();
|
||||
sendMessageData.setSender(robot.getUid());
|
||||
Conversation conversation = new Conversation();
|
||||
conversation.setType(message.getConversation().getType());
|
||||
conversation.setLine(message.getConversation().getLine());
|
||||
conversation.setTarget(message.getConversation().getTarget());
|
||||
sendMessageData.setConv(conversation);
|
||||
sendMessageData.setPayload(replyMessageData.getPayload());
|
||||
if(replyMessageData.isOnly2Sender()) {
|
||||
sendMessageData.setToUsers(Arrays.asList(message.getFromUser()));
|
||||
}
|
||||
return sendMessageData;
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,13 @@ public final class BrokerConstants {
|
||||
public static final String QINIU_BUCKET_PORTRAIT_DOMAIN = "qiniu.bucket_portrait_domain";
|
||||
public static final String QINIU_BUCKET_FAVORITE_NAME= "qiniu.bucket_favorite_name";
|
||||
public static final String QINIU_BUCKET_FAVORITE_DOMAIN = "qiniu.bucket_favorite_domain";
|
||||
public static final String QINIU_BUCKET_CUSTOM1_NAME= "qiniu.bucket_custom1_name";
|
||||
public static final String QINIU_BUCKET_CUSTOM1_DOMAIN = "qiniu.bucket_custom1_domain";
|
||||
public static final String QINIU_BUCKET_CUSTOM2_NAME= "qiniu.bucket_custom2_name";
|
||||
public static final String QINIU_BUCKET_CUSTOM2_DOMAIN = "qiniu.bucket_custom2_domain";
|
||||
public static final String QINIU_BUCKET_CUSTOM3_NAME= "qiniu.bucket_custom3_name";
|
||||
public static final String QINIU_BUCKET_CUSTOM3_DOMAIN = "qiniu.bucket_custom3_domain";
|
||||
|
||||
|
||||
public static final String FILE_STORAGE_ROOT = "local.media.storage.root";
|
||||
public static final String FILE_STORAGE_REMOTE_SERVER_URL = "local.media.storage.remote_server_url";
|
||||
@@ -124,7 +131,7 @@ public final class BrokerConstants {
|
||||
|
||||
|
||||
public static final String SENSITIVE_Filter_Type = "sensitive.filter.type";
|
||||
|
||||
public static final String SENSITIVE_Only_Message = "sensitive.only_message";
|
||||
public static final String SENSITIVE_Remote_Server_URL = "sensitive.remote_server_url";
|
||||
public static final String SENSITIVE_Remote_Message_Type = "sensitive.remote_sensitive_message_type";
|
||||
public static final String SENSITIVE_Remote_Fail_When_Matched = "sensitive.remote_fail_when_matched";
|
||||
@@ -173,6 +180,8 @@ public final class BrokerConstants {
|
||||
public static final String ROBOT_Callback_With_Client_Info = "robot.callback_with_client_info";
|
||||
public static final String ROBOT_Callback_With_Sender_Info = "robot.callback_with_sender_info";
|
||||
public static final String ROBOT_Callback_With_Target_Info = "robot.callback_with_target_info";
|
||||
public static final String ROBOT_Mention_External_Robot = "robot.mention_external_robot";
|
||||
public static final String ROBOT_Get_User_Info_Mask = "robot.get_user_info_mask";
|
||||
|
||||
public static final String CHANNEL_Callback_With_Client_Info = "channel.callback_with_client_info";
|
||||
public static final String CHANNEL_Callback_With_Sender_Info = "channel.callback_with_sender_info";
|
||||
@@ -188,6 +197,8 @@ public final class BrokerConstants {
|
||||
public static final String FRIEND_Reject_Request_Duration = "friend.reject_request_duration";
|
||||
public static final String FRIEND_Request_Expiration_Duration = "friend.request_expiration_duration";
|
||||
public static final String FRIEND_Request_Rate_Limit = "friend.request_rate_limit";
|
||||
public static final String FRIEND_Search_Mobile_Empty_Rate_Limit = "friend.search_mobile_empty_rate_limit";
|
||||
public static final String FRIEND_Search_Rate_Limit = "friend.search_rate_limit";
|
||||
public static final String FRIEND_Request_Robot_Auto_Accept = "friend.robot_auto_accept";
|
||||
|
||||
|
||||
@@ -211,6 +222,9 @@ public final class BrokerConstants {
|
||||
|
||||
public static final String USER_HIDE_PROPERTIES = "user.hide_properties";
|
||||
public static final String USER_KEEP_DISPLAY_NAME_WHEN_DESTROY = "user.keep_display_name_when_destroy";
|
||||
public static final String USER_KEEP_FULL_INFO_WHEN_DESTROY = "user.keep_full_info_when_destroy";
|
||||
public static final String USER_KEEP_MOBILE_WHEN_DESTROY = "user.keep_mobile_when_destroy";
|
||||
public static final String USER_KEEP_MESSAGES_WHEN_DESTROY = "user.keep_messages_when_destroy";
|
||||
|
||||
public static final String SYNC_Data_Part_Size = "sync.data_part_size";
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Handler(value = IMTopic.CreateGroupTopic)
|
||||
public class CreateGroupHandler extends GroupHandler<WFCMessage.CreateGroupRequest> {
|
||||
@@ -68,6 +69,19 @@ public class CreateGroupHandler extends GroupHandler<WFCMessage.CreateGroupReque
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if(!isAdmin && !StringUtil.isNullOrEmpty(request.getGroup().getGroupInfo().getName())) {
|
||||
if(!m_messagesStore.isSensitiveOnlyMessage()) {
|
||||
Set<String> matched = m_messagesStore.handleSensitiveWord(request.getGroup().getGroupInfo().getName());
|
||||
if (matched != null && !matched.isEmpty()) {
|
||||
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||
}
|
||||
}
|
||||
|
||||
if(!m_messagesStore.isAllowName(request.getGroup().getGroupInfo().getName())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
WFCMessage.GroupInfo groupInfo = m_messagesStore.createGroup(fromUser, request.getGroup().getGroupInfo(), request.getGroup().getMembersList(), request.getMemberExtra(), isAdmin, failedMembers);
|
||||
if (groupInfo != null && groupInfo.getDeleted() == 0) {
|
||||
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
|
||||
@@ -32,7 +32,6 @@ public class GetMediaUploadTokenHandler extends IMHandler<WFCMessage.GetUploadTo
|
||||
if (MediaServerConfig.USER_QINIU) {
|
||||
Auth auth = Auth.create(MediaServerConfig.QINIU_ACCESS_KEY, MediaServerConfig.QINIU_SECRET_KEY);
|
||||
|
||||
|
||||
String bucketName;
|
||||
String bucketDomain;
|
||||
switch (type) {
|
||||
@@ -72,6 +71,18 @@ public class GetMediaUploadTokenHandler extends IMHandler<WFCMessage.GetUploadTo
|
||||
bucketName = MediaServerConfig.QINIU_BUCKET_MOMENTS_NAME;
|
||||
bucketDomain = MediaServerConfig.QINIU_BUCKET_MOMENTS_DOMAIN;
|
||||
break;
|
||||
case 9:
|
||||
bucketName = MediaServerConfig.QINIU_BUCKET_CUSTOM1_NAME;
|
||||
bucketDomain = MediaServerConfig.QINIU_BUCKET_CUSTOM1_DOMAIN;
|
||||
break;
|
||||
case 10:
|
||||
bucketName = MediaServerConfig.QINIU_BUCKET_CUSTOM2_NAME;
|
||||
bucketDomain = MediaServerConfig.QINIU_BUCKET_CUSTOM2_DOMAIN;
|
||||
break;
|
||||
case 11:
|
||||
bucketName = MediaServerConfig.QINIU_BUCKET_CUSTOM3_NAME;
|
||||
bucketDomain = MediaServerConfig.QINIU_BUCKET_CUSTOM3_DOMAIN;
|
||||
break;
|
||||
default:
|
||||
bucketName = MediaServerConfig.QINIU_BUCKET_GENERAL_NAME;
|
||||
bucketDomain = MediaServerConfig.QINIU_BUCKET_GENERAL_DOMAIN;
|
||||
|
||||
@@ -77,6 +77,18 @@ public class GetQiniuUploadTokenHandler extends IMHandler<Byte> {
|
||||
bucketName = MediaServerConfig.QINIU_BUCKET_MOMENTS_NAME;
|
||||
bucketDomain = MediaServerConfig.QINIU_BUCKET_MOMENTS_DOMAIN;
|
||||
break;
|
||||
case 9:
|
||||
bucketName = MediaServerConfig.QINIU_BUCKET_CUSTOM1_NAME;
|
||||
bucketDomain = MediaServerConfig.QINIU_BUCKET_CUSTOM1_DOMAIN;
|
||||
break;
|
||||
case 10:
|
||||
bucketName = MediaServerConfig.QINIU_BUCKET_CUSTOM2_NAME;
|
||||
bucketDomain = MediaServerConfig.QINIU_BUCKET_CUSTOM2_DOMAIN;
|
||||
break;
|
||||
case 11:
|
||||
bucketName = MediaServerConfig.QINIU_BUCKET_CUSTOM3_NAME;
|
||||
bucketDomain = MediaServerConfig.QINIU_BUCKET_CUSTOM3_DOMAIN;
|
||||
break;
|
||||
default:
|
||||
bucketName = MediaServerConfig.QINIU_BUCKET_GENERAL_NAME;
|
||||
bucketDomain = MediaServerConfig.QINIU_BUCKET_GENERAL_DOMAIN;
|
||||
|
||||
@@ -16,6 +16,7 @@ import io.moquette.spi.impl.security.TokenAuthenticator;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
import win.liyufan.im.UserSettingScope;
|
||||
|
||||
@Handler(IMTopic.GetTokenTopic)
|
||||
public class GetTokenHandler extends IMHandler<WFCMessage.GetTokenRequest> {
|
||||
@@ -26,6 +27,11 @@ public class GetTokenHandler extends IMHandler<WFCMessage.GetTokenRequest> {
|
||||
if(userInfo != null && userInfo.getType() == 1) {
|
||||
return ErrorCode.ERROR_CODE_ROBOT_NO_TOKEN;
|
||||
}
|
||||
if((session.isPcClient() || session.isPadClient())) {
|
||||
if(m_messagesStore.isLocked(session.getUsername(), session.getClientID())) {
|
||||
m_messagesStore.updateUserSettings(session.getUsername(), WFCMessage.ModifyUserSettingReq.newBuilder().setScope(UserSettingScope.UserSettingScopeLockPC).setKey(session.getClientID()).setValue("0").build(), null);
|
||||
}
|
||||
}
|
||||
|
||||
TokenAuthenticator authenticator = new TokenAuthenticator();
|
||||
String strToken = authenticator.generateToken(fromUser);
|
||||
|
||||
@@ -45,20 +45,20 @@ public class HandleFriendRequestHandler extends IMHandler<WFCMessage.HandleFrien
|
||||
contentBuilder.setType(92);
|
||||
|
||||
builder = WFCMessage.Message.newBuilder();
|
||||
builder.setFromUser(request.getTargetUid());
|
||||
builder.setConversation(WFCMessage.Conversation.newBuilder().setTarget(fromUser).setLine(0).setType(ProtoConstants.ConversationType.ConversationType_Private).build());
|
||||
builder.setFromUser(fromUser);
|
||||
builder.setConversation(WFCMessage.Conversation.newBuilder().setTarget(request.getTargetUid()).setLine(0).setType(ProtoConstants.ConversationType.ConversationType_Private).build());
|
||||
builder.setContent(contentBuilder);
|
||||
builder.setServerTimestamp(++timestamp);
|
||||
|
||||
messageId = MessageShardingUtil.generateId();
|
||||
builder.setMessageId(messageId);
|
||||
saveAndPublish(request.getTargetUid(), null, builder.build(), requestSourceType);
|
||||
saveAndPublish(fromUser, null, builder.build(), requestSourceType);
|
||||
contentBuilder.setType(93);
|
||||
builder.setContent(contentBuilder);
|
||||
messageId = MessageShardingUtil.generateId();
|
||||
builder.setMessageId(messageId);
|
||||
builder.setServerTimestamp(++timestamp);
|
||||
saveAndPublish(request.getTargetUid(), null, builder.build(), requestSourceType);
|
||||
saveAndPublish(fromUser, null, builder.build(), requestSourceType);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -11,11 +11,14 @@ package io.moquette.imhandler;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import cn.wildfirechat.pojos.GroupNotificationBinaryContent;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@Handler(IMTopic.ModifyGroupAliasTopic)
|
||||
@@ -26,10 +29,24 @@ public class ModifyGroupAliasHandler extends GroupHandler<WFCMessage.ModifyGroup
|
||||
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0 && requestSourceType == ProtoConstants.RequestSourceType.Request_From_User && !m_messagesStore.isAllowClientCustomGroupNotification()) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0 && requestSourceType == ProtoConstants.RequestSourceType.Request_From_Robot && !m_messagesStore.isAllowRobotCustomGroupNotification()) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
if (!isAdmin && !StringUtil.isNullOrEmpty(request.getAlias())) {
|
||||
if(!m_messagesStore.isSensitiveOnlyMessage()) {
|
||||
Set<String> matched = m_messagesStore.handleSensitiveWord(request.getAlias());
|
||||
if (matched != null && !matched.isEmpty()) {
|
||||
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||
}
|
||||
}
|
||||
|
||||
if(!m_messagesStore.isAllowName(request.getAlias())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
ErrorCode errorCode = m_messagesStore.modifyGroupMemberAlias(fromUser, request.getGroupId(), request.getAlias(), null, isAdmin);
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
if (request.hasNotifyContent()&& request.getNotifyContent().getType() > 0) {
|
||||
|
||||
@@ -12,10 +12,13 @@ import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.GroupNotificationBinaryContent;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@Handler(IMTopic.ModifyGroupMemberAliasTopic)
|
||||
@@ -29,6 +32,18 @@ public class ModifyGroupMemberAliasHandler extends GroupHandler<WFCMessage.Modif
|
||||
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0 && requestSourceType == ProtoConstants.RequestSourceType.Request_From_Robot && !m_messagesStore.isAllowRobotCustomGroupNotification()) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
if (!isAdmin && !StringUtil.isNullOrEmpty(request.getAlias())) {
|
||||
if(!m_messagesStore.isSensitiveOnlyMessage()) {
|
||||
Set<String> matched = m_messagesStore.handleSensitiveWord(request.getAlias());
|
||||
if (matched != null && !matched.isEmpty()) {
|
||||
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||
}
|
||||
}
|
||||
|
||||
if(!m_messagesStore.isAllowName(request.getAlias())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
ErrorCode errorCode = m_messagesStore.modifyGroupMemberAlias(fromUser, request.getGroupId(), request.getAlias(), request.getMemberId(), isAdmin);
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.MessagePayload;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import io.moquette.BrokerConstants;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import win.liyufan.im.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@Handler(value = IMTopic.RobotReplyMessageTopic)
|
||||
public class ReplyMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
private int mSensitiveType = 0; //命中敏感词时,0 失败,1 吞掉, 2 敏感词替换成*。
|
||||
private String mForwardUrl = null;
|
||||
private String mSensitiveMessageForwardUrl = null;
|
||||
private Set<Integer> mForwardMessageTypes = new HashSet<>();
|
||||
private Set<Integer> mForwardExcludeMessageTypes = new HashSet<>();
|
||||
private String mMentionForwardUrl = null;
|
||||
private int mBlacklistStrategy = 0; //黑名单中时,0失败,1吞掉。
|
||||
private boolean mBlacklistAllowSend2Black = true;
|
||||
private boolean mNoForwardAdminMessage = false;
|
||||
private boolean mAllowSend2ForbiddenUser = false;
|
||||
|
||||
private String mRemoteSensitiveServerUrl = null;
|
||||
private Set<Integer> mRemoteSensitiveMessageTypes;
|
||||
private boolean mWaitRemoteSensitiveServerResponse = false;
|
||||
|
||||
public ReplyMessageHandler() {
|
||||
super();
|
||||
|
||||
mForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Url);
|
||||
if (!StringUtil.isNullOrEmpty(mForwardUrl)) {
|
||||
String forwardTypes = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Types);
|
||||
parseTypes(mForwardMessageTypes, forwardTypes);
|
||||
String excludeTypes = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Exclude_Types);
|
||||
parseTypes(mForwardExcludeMessageTypes, excludeTypes);
|
||||
}
|
||||
mSensitiveMessageForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Sensitive_Forward_Url);
|
||||
mMentionForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_MentionMsg_Forward_Url);
|
||||
|
||||
try {
|
||||
mSensitiveType = Integer.parseInt(mServer.getConfig().getProperty(BrokerConstants.SENSITIVE_Filter_Type));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
}
|
||||
|
||||
try {
|
||||
mBlacklistStrategy = Integer.parseInt(mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Blacklist_Strategy));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
}
|
||||
|
||||
try {
|
||||
mBlacklistAllowSend2Black = Boolean.parseBoolean(mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Blacklist_Allow_Send, "true"));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
try {
|
||||
mRemoteSensitiveServerUrl = mServer.getConfig().getProperty(BrokerConstants.SENSITIVE_Remote_Server_URL);
|
||||
if(!StringUtil.isNullOrEmpty(mRemoteSensitiveServerUrl)) {
|
||||
mWaitRemoteSensitiveServerResponse = Boolean.parseBoolean(mServer.getConfig().getProperty(BrokerConstants.SENSITIVE_Remote_Fail_When_Matched, "false"));
|
||||
String types = mServer.getConfig().getProperty(BrokerConstants.SENSITIVE_Remote_Message_Type, "");
|
||||
mRemoteSensitiveMessageTypes = new HashSet<>();
|
||||
if(!StringUtil.isNullOrEmpty(types)) {
|
||||
String[] ts = types.split(",");
|
||||
for (String t:ts) {
|
||||
mRemoteSensitiveMessageTypes.add(Integer.parseInt(t.trim()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
}
|
||||
|
||||
try {
|
||||
mNoForwardAdminMessage = Boolean.parseBoolean(mServer.getConfig().getProperty(BrokerConstants.MESSAGE_NO_Forward_Admin_Message, "false"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
}
|
||||
|
||||
try {
|
||||
mAllowSend2ForbiddenUser = Boolean.parseBoolean(mServer.getConfig().getProperty(BrokerConstants.MESSAGES_ALLOW_SEND_TO_FORBIDDEN_USER, "false"));
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
private void parseTypes(Collection<Integer> collection, String types) {
|
||||
try {
|
||||
if (!StringUtil.isNullOrEmpty(types)) {
|
||||
String[] tss = types.split(",");
|
||||
for (String ts:tss) {
|
||||
if(ts.contains("-")) {
|
||||
String[] ss = ts.split("-");
|
||||
if(ss.length == 2) {
|
||||
int begin = Integer.parseInt(ss[0]);
|
||||
int end = Integer.parseInt(ss[1]);
|
||||
for (int i = begin; i <= end ; i++) {
|
||||
collection.add(i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
collection.add(Integer.parseInt(ts.trim()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.Message message, Qos1PublishHandler.IMCallback callback) {
|
||||
if(requestSourceType != ProtoConstants.RequestSourceType.Request_From_Robot) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IMPLEMENT;
|
||||
}
|
||||
|
||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
if (message != null) {
|
||||
if(message.getContent().getContent().length() +
|
||||
message.getContent().getSearchableContent().length() +
|
||||
message.getContent().getData().size() +
|
||||
message.getContent().getExtra().length() +
|
||||
message.getContent().getPushContent().length() +
|
||||
message.getContent().getPushData().length() > 64 * 1024) {
|
||||
return ErrorCode.ERROR_CODE_MESSAGE_TOO_LARGE;
|
||||
}
|
||||
|
||||
boolean ignoreMsg = false;
|
||||
|
||||
// 不能在端上直接发送撤回和群通知
|
||||
if (message.getContent().getType() == 80 || message.getContent().getType() == 81 || (message.getContent().getType() >= 100 && message.getContent().getType() < 200)) {
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if(m_messagesStore.getClientForbiddenSendTypes().contains(message.getContent().getType())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
int userStatus = m_messagesStore.getUserStatus(fromUser);
|
||||
if (userStatus == ProtoConstants.UserStatus.Muted || userStatus == ProtoConstants.UserStatus.Forbidden) {
|
||||
if(!m_messagesStore.getGlobalMuteExceptionTypes().contains(message.getContent().getType())) {
|
||||
return ErrorCode.ERROR_CODE_FORBIDDEN_SEND_MSG;
|
||||
}
|
||||
}
|
||||
|
||||
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Private) {
|
||||
if(!m_messagesStore.getBlackListExceptionTypes().contains(message.getContent().getType())) {
|
||||
errorCode = m_messagesStore.isAllowUserMessage(message.getConversation().getTarget(), fromUser, message.getConversation().getLine());
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (errorCode == ErrorCode.ERROR_CODE_IN_BLACK_LIST && mBlacklistStrategy != ProtoConstants.BlacklistStrategy.Message_Reject) {
|
||||
ignoreMsg = true;
|
||||
errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
} else {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
|
||||
if(!mBlacklistAllowSend2Black) {
|
||||
errorCode = m_messagesStore.isBlacked(fromUser, message.getConversation().getTarget());
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!mAllowSend2ForbiddenUser) {
|
||||
userStatus = m_messagesStore.getUserStatus(message.getConversation().getTarget());
|
||||
if (userStatus == ProtoConstants.UserStatus.Forbidden) {
|
||||
return ErrorCode.ERROR_CODE_USER_FORBIDDEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group ) {
|
||||
if(!m_messagesStore.getGroupMuteExceptionTypes().contains(message.getContent().getType())) {
|
||||
errorCode = m_messagesStore.canSendMessageInGroup(fromUser, message.getConversation().getTarget());
|
||||
if(errorCode == ERROR_CODE_NOT_IN_GROUP) {
|
||||
errorCode = ERROR_CODE_SUCCESS;
|
||||
}
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_ChatRoom) {
|
||||
if(!m_messagesStore.getGroupMuteExceptionTypes().contains(message.getContent().getType())) {
|
||||
if (!m_messagesStore.checkUserClientInChatroom(fromUser, clientID, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHATROOM;
|
||||
}
|
||||
}
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel) {
|
||||
if(!m_messagesStore.getGroupMuteExceptionTypes().contains(message.getContent().getType())) {
|
||||
if (!m_messagesStore.canSendMessageInChannel(fromUser, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHANNEL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Private) {
|
||||
long beforeMessageId = message.getMessageId();
|
||||
WFCMessage.Message replyMsg = m_messagesStore.getMessage(beforeMessageId);
|
||||
message = message.toBuilder().setConversation(message.getConversation().toBuilder().setTarget(replyMsg.getFromUser() + "|" + replyMsg.getConversation().getTarget())).build();
|
||||
}
|
||||
|
||||
long timestamp = System.currentTimeMillis();
|
||||
final long messageId;
|
||||
try {
|
||||
messageId = MessageShardingUtil.generateId();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ErrorCode.ERROR_CODE_SERVER_ERROR;
|
||||
}
|
||||
message = message.toBuilder().setFromUser(fromUser).setMessageId(messageId).setServerTimestamp(timestamp).build();
|
||||
|
||||
|
||||
if (!StringUtil.isNullOrEmpty(mForwardUrl) && (mForwardMessageTypes.isEmpty() || mForwardMessageTypes.contains(message.getContent().getType())) && !mForwardExcludeMessageTypes.contains(message.getContent().getType())) {
|
||||
publisher.forwardMessage(message, mForwardUrl, clientID);
|
||||
}
|
||||
|
||||
if(!StringUtil.isNullOrEmpty(mMentionForwardUrl) && message.hasContent() && message.getContent().getMentionedType() != 0) {
|
||||
publisher.forwardMessage(message, mMentionForwardUrl, clientID);
|
||||
}
|
||||
|
||||
|
||||
if(StringUtil.isNullOrEmpty(mRemoteSensitiveServerUrl)) {
|
||||
Set<String> matched = m_messagesStore.handleSensitiveWord(message.getContent().getSearchableContent());
|
||||
if (matched != null && !matched.isEmpty()) {
|
||||
m_messagesStore.storeSensitiveMessage(message);
|
||||
if (!StringUtil.isNullOrEmpty(mSensitiveMessageForwardUrl)) {
|
||||
publisher.forwardMessage(message, mSensitiveMessageForwardUrl, clientID);
|
||||
}
|
||||
if (mSensitiveType == 0) {
|
||||
errorCode = ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||
} else if (mSensitiveType == 1) {
|
||||
ignoreMsg = true;
|
||||
} else if (mSensitiveType == 2) {
|
||||
String text = message.getContent().getSearchableContent();
|
||||
for (String word : matched) {
|
||||
text = text.replace(word, "***");
|
||||
}
|
||||
message = message.toBuilder().setContent(message.getContent().toBuilder().setSearchableContent(text).build()).build();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(mRemoteSensitiveMessageTypes.contains(message.getContent().getType())) {
|
||||
final WFCMessage.Message finalMsg = message;
|
||||
publisher.forwardMessageWithCallback(message, clientID, mRemoteSensitiveServerUrl, new HttpUtils.HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(String content) {
|
||||
if(StringUtil.isNullOrEmpty(content)) {
|
||||
saveAndPublish(fromUser, clientID, finalMsg, requestSourceType);
|
||||
} else {
|
||||
MessagePayload payload = GsonUtil.gson.fromJson(content, MessagePayload.class);
|
||||
if (payload != null && payload.getType() > 0) {
|
||||
WFCMessage.Message newMsg = finalMsg.toBuilder().setContent(payload.toProtoMessageContent()).build();
|
||||
saveAndPublish(fromUser, clientID, newMsg, requestSourceType);
|
||||
} else {
|
||||
LOG.error("Response content {} from censor is invalid payload, ignore response and send original message", content);
|
||||
saveAndPublish(fromUser, clientID, finalMsg, requestSourceType);
|
||||
}
|
||||
}
|
||||
if(mWaitRemoteSensitiveServerResponse) {
|
||||
ByteBuf ackPayload = Unpooled.buffer(21);
|
||||
ErrorCode errorCode = ERROR_CODE_SUCCESS;
|
||||
ackPayload.writeByte(errorCode.getCode());
|
||||
ackPayload.writeLong(messageId);
|
||||
ackPayload.writeLong(timestamp);
|
||||
callback.onIMHandled(ErrorCode.ERROR_CODE_SUCCESS, ackPayload);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int statusCode, String errorMessage) {
|
||||
ByteBuf ackPayload = null;
|
||||
ErrorCode errorCode = ERROR_CODE_SUCCESS;
|
||||
if(statusCode == 403) {
|
||||
if(mWaitRemoteSensitiveServerResponse) {
|
||||
errorCode = ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||
ackPayload = Unpooled.buffer(1);
|
||||
ackPayload.writeByte(errorCode.getCode());
|
||||
}
|
||||
} else {
|
||||
LOG.warn("Failed to censor message with status {}, errorMessage {}. Send the original message", statusCode, errorMessage);
|
||||
saveAndPublish(fromUser, clientID, finalMsg, requestSourceType);
|
||||
|
||||
if(mWaitRemoteSensitiveServerResponse) {
|
||||
errorCode = ERROR_CODE_SUCCESS;
|
||||
ackPayload = Unpooled.buffer(21);
|
||||
ackPayload.writeByte(errorCode.getCode());
|
||||
ackPayload.writeLong(messageId);
|
||||
ackPayload.writeLong(timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
if(mWaitRemoteSensitiveServerResponse) {
|
||||
callback.onIMHandled(errorCode, ackPayload);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(mWaitRemoteSensitiveServerResponse) {
|
||||
ackPayload.clear();
|
||||
return ErrorCode.INVALID_ASYNC_HANDLING;
|
||||
} else {
|
||||
ackPayload = ackPayload.capacity(20);
|
||||
ackPayload.writeLong(messageId);
|
||||
ackPayload.writeLong(timestamp);
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if(!ignoreMsg) {
|
||||
saveAndPublish(fromUser, clientID, message, requestSourceType);
|
||||
}
|
||||
ackPayload = ackPayload.capacity(20);
|
||||
ackPayload.writeLong(messageId);
|
||||
ackPayload.writeLong(timestamp);
|
||||
}
|
||||
} else {
|
||||
errorCode = ErrorCode.ERROR_CODE_INVALID_MESSAGE;
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -136,6 +136,15 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
boolean isAdmin = requestSourceType == ProtoConstants.RequestSourceType.Request_From_Admin;
|
||||
if (message != null) {
|
||||
if(message.getContent().getContent().length() +
|
||||
message.getContent().getSearchableContent().length() +
|
||||
message.getContent().getData().size() +
|
||||
message.getContent().getExtra().length() +
|
||||
message.getContent().getPushContent().length() +
|
||||
message.getContent().getPushData().length() > 64 * 1024) {
|
||||
return ErrorCode.ERROR_CODE_MESSAGE_TOO_LARGE;
|
||||
}
|
||||
|
||||
boolean ignoreMsg = false;
|
||||
if (!isAdmin) { //admin do not check the right
|
||||
// 不能在端上直接发送撤回和群通知
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.IMTopic;
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@Handler(IMTopic.SetFriendExtraTopic)
|
||||
public class SetFriendExtraHandler extends IMHandler<WFCMessage.StringPair> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.StringPair request, Qos1PublishHandler.IMCallback callback) {
|
||||
long[] heads = new long[1];
|
||||
ErrorCode errorCode = m_messagesStore.setFriendExtraRequest(fromUser, request.getKey(), request.getValue(), heads);
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
publisher.publishNotification(IMTopic.NotifyFriendTopic, fromUser, heads[0], clientID);
|
||||
}
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,18 @@ import io.netty.buffer.ByteBuf;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Handler(IMTopic.UserSearchTopic)
|
||||
public class UserSearchHandler extends IMHandler<WFCMessage.SearchUserRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.SearchUserRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
List<WFCMessage.User> users = m_messagesStore.searchUser(request.getKeyword(), request.getFuzzy(), request.getType(), request.getPage());
|
||||
List<WFCMessage.User> users = new ArrayList<>();
|
||||
ErrorCode errorCode = m_messagesStore.searchUser(fromUser, request.getKeyword(), request.getFuzzy(), request.getType(), request.getPage(), users);
|
||||
if(errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
return errorCode;
|
||||
}
|
||||
WFCMessage.SearchUserResult.Builder builder = WFCMessage.SearchUserResult.newBuilder();
|
||||
builder.addAllEntry(users);
|
||||
byte[] data = builder.build().toByteArray();
|
||||
|
||||
@@ -1832,6 +1832,31 @@ public class DatabaseStore {
|
||||
});
|
||||
}
|
||||
|
||||
void updateSessionIp(String uid, String cid, String ip) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "update t_user_session set _ip = ? where `_uid` = ? and `_cid` = ?";
|
||||
statement = connection.prepareStatement(sql);
|
||||
int index = 1;
|
||||
statement.setString(index++, ip);
|
||||
statement.setString(index++, uid);
|
||||
statement.setString(index++, cid);
|
||||
|
||||
int c = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", c);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e, RDBS_Exception);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void clearMultiEndpoint(String uid, String clientId, int platform) {
|
||||
LOG.info("clearMultiEndpoint {}, {}", uid, clientId);
|
||||
Connection connection = null;
|
||||
@@ -3152,6 +3177,34 @@ public class DatabaseStore {
|
||||
return outList;
|
||||
}
|
||||
|
||||
List<String> getUserRobotIds(String userId) {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
ResultSet rs = null;
|
||||
List<String> outList = new ArrayList<>();
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "select _uid from t_robot where _owner = ? and _state = 0";
|
||||
statement = connection.prepareStatement(sql);
|
||||
|
||||
int index = 1;
|
||||
statement.setString(1, userId);
|
||||
|
||||
rs = statement.executeQuery();
|
||||
while (rs.next()) {
|
||||
outList.add(rs.getString(1));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e, RDBS_Exception);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement, rs);
|
||||
}
|
||||
return outList;
|
||||
}
|
||||
|
||||
|
||||
Set<String> getAllEnds(boolean fromUserTable) {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
|
||||
@@ -58,6 +58,8 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static cn.wildfirechat.common.IMExceptionEvent.EventType.EVENT_CALLBACK_Exception;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ChannelState.*;
|
||||
@@ -76,8 +78,7 @@ import static io.moquette.BrokerConstants.*;
|
||||
import static io.moquette.server.Constants.MAX_CHATROOM_MESSAGE_QUEUE;
|
||||
import static io.moquette.server.Constants.MAX_MESSAGE_QUEUE;
|
||||
import static cn.wildfirechat.pojos.MyInfoType.*;
|
||||
import static win.liyufan.im.UserSettingScope.kUserSettingAddFriendStrategy;
|
||||
import static win.liyufan.im.UserSettingScope.kUserSettingPCOnline;
|
||||
import static win.liyufan.im.UserSettingScope.*;
|
||||
|
||||
public class MemoryMessagesStore implements IMessagesStore {
|
||||
private static final String MESSAGES_MAP = "messages_map";
|
||||
@@ -157,6 +158,8 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private long mFriendRejectDuration = 30 * 24 * 60 * 60 * 1000;
|
||||
private long mFriendRequestExpiration = 7 * 24 * 60 * 60 * 1000;
|
||||
private RateLimiter mFriendRateLimiter;
|
||||
private RateLimiter mFriendSearchEmpthMobileRateLimiter;
|
||||
private RateLimiter mFriendSearchRateLimiter;
|
||||
private boolean mFriendRobotAutoAccept = true;
|
||||
|
||||
private long mPushExpiredTimes = 604800000L;
|
||||
@@ -171,7 +174,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private boolean mGroupAllowPartSuccess = false;
|
||||
|
||||
private boolean mIDUseUUID = true;
|
||||
|
||||
private boolean mSensitiveOnlyMessage = true;
|
||||
private Set<String> mClientSignatureSet = new HashSet<>();
|
||||
private boolean mRejectEmptySignature = true;
|
||||
|
||||
@@ -202,6 +205,10 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private int mGroupForbiddenClientOperation;
|
||||
private int mSyncDataPartSize = 0;
|
||||
private boolean keepDisplayNameWhenDestroyUser = true;
|
||||
private boolean keepFullInfoWhenDestroyUser = false;
|
||||
private boolean keepMobileWhenDestroyUser = false;
|
||||
private boolean keepMessagesWhenDestroyUser = false;
|
||||
|
||||
private String mRecallForwardUrl = null;
|
||||
|
||||
private boolean mBroadcastTargetFromUserTable = false;
|
||||
@@ -213,6 +220,8 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private boolean mRobotCallbackWithClientInfo = false;
|
||||
private boolean mRobotCallbackWithSenderInfo = false;
|
||||
private boolean mRobotCallbackWithTargetInfo = false;
|
||||
private boolean mRobotMentionExternalRobot = false;
|
||||
private int mRobotGetUserInfoMask = 0;
|
||||
|
||||
private boolean mChannelCallbackWithClientInfo = false;
|
||||
private boolean mChannelCallbackWithSenderInfo = false;
|
||||
@@ -331,7 +340,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
printMissConfigLog(FRIEND_Disable_NickName_Search, mDisableNicknameSearch + "");
|
||||
}
|
||||
try {
|
||||
mDisableUserIdSearch = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.FRIEND_Disable_UserId_Search, "true"));
|
||||
mDisableUserIdSearch = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.FRIEND_Disable_UserId_Search, "false"));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
@@ -375,6 +384,21 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
int rateLimit = Integer.parseInt(m_Server.getConfig().getProperty(FRIEND_Search_Mobile_Empty_Rate_Limit, "0"));
|
||||
if(rateLimit > 0) {
|
||||
mFriendSearchEmpthMobileRateLimiter = new RateLimiter(86400, rateLimit);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
try {
|
||||
int rateLimit = Integer.parseInt(m_Server.getConfig().getProperty(FRIEND_Search_Rate_Limit, "0"));
|
||||
if(rateLimit > 0) {
|
||||
mFriendSearchRateLimiter = new RateLimiter(86400, rateLimit);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
try {
|
||||
mFriendRobotAutoAccept = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.FRIEND_Request_Robot_Auto_Accept, "true"));
|
||||
@@ -599,6 +623,17 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
try {
|
||||
keepFullInfoWhenDestroyUser = "true".equals(server.getConfig().getProperty(USER_KEEP_FULL_INFO_WHEN_DESTROY));
|
||||
} catch (Exception e) {}
|
||||
|
||||
try {
|
||||
keepMobileWhenDestroyUser = "true".equals(server.getConfig().getProperty(USER_KEEP_MOBILE_WHEN_DESTROY));
|
||||
} catch (Exception e) {}
|
||||
|
||||
try {
|
||||
keepMessagesWhenDestroyUser = "true".equals(server.getConfig().getProperty(USER_KEEP_MESSAGES_WHEN_DESTROY));
|
||||
} catch (Exception e) {}
|
||||
|
||||
|
||||
try {
|
||||
@@ -646,6 +681,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
try {
|
||||
mRobotCallbackWithTargetInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.ROBOT_Callback_With_Target_Info, "false"));
|
||||
} catch (Exception e) {}
|
||||
try {
|
||||
mRobotMentionExternalRobot = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.ROBOT_Mention_External_Robot, "false"));
|
||||
} catch (Exception e) {}
|
||||
try {
|
||||
mRobotGetUserInfoMask = Integer.parseInt(server.getConfig().getProperty(BrokerConstants.ROBOT_Get_User_Info_Mask, "0"));
|
||||
} catch (Exception e) {}
|
||||
|
||||
try {
|
||||
mChannelCallbackWithClientInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.CHANNEL_Callback_With_Client_Info, "false"));
|
||||
@@ -671,6 +712,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
mIDUseUUID = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.ID_USE_UUID, "false"));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
try {
|
||||
mSensitiveOnlyMessage = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SENSITIVE_Only_Message, "true"));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
private void printMissConfigLog(String config, String defaultValue) {
|
||||
@@ -737,13 +783,34 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
int pullType = ProtoConstants.PullType.Pull_Normal;
|
||||
|
||||
if (type == ProtoConstants.ConversationType.ConversationType_Private) {
|
||||
notifyReceivers.add(fromUser);
|
||||
if(message.getToCount() > 0) {
|
||||
if(message.getToList().contains(message.getConversation().getTarget())) {
|
||||
notifyReceivers.add(message.getConversation().getTarget());
|
||||
if(mRobotMentionExternalRobot && message.getConversation().getTarget().contains("|")) {
|
||||
String[] ss = message.getConversation().getTarget().split("\\|");
|
||||
notifyReceivers.add(ss[0]);
|
||||
notifyReceivers.add(ss[1]);
|
||||
if(!message.getToList().isEmpty()) {
|
||||
notifyReceivers.addAll(message.getToList());
|
||||
} else if(!StringUtil.isNullOrEmpty(message.getToUser())) {
|
||||
notifyReceivers.add(message.getToUser());
|
||||
}
|
||||
} else {
|
||||
notifyReceivers.add(message.getConversation().getTarget());
|
||||
notifyReceivers.add(fromUser);
|
||||
if (message.getToCount() > 0) {
|
||||
if (message.getToList().contains(message.getConversation().getTarget())) {
|
||||
notifyReceivers.add(message.getConversation().getTarget());
|
||||
}
|
||||
} else {
|
||||
notifyReceivers.add(message.getConversation().getTarget());
|
||||
}
|
||||
}
|
||||
if (mRobotMentionExternalRobot && message.getContent().getMentionedTargetCount() > 0) {
|
||||
for (String mentioned : message.getContent().getMentionedTargetList()) {
|
||||
if (!notifyReceivers.contains(mentioned)) {
|
||||
WFCMessage.User user = getUserInfo(mentioned);
|
||||
if(user != null && user.getType() == ProtoConstants.UserType.UserType_Robot) {
|
||||
notifyReceivers.add(mentioned);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pullType = ProtoConstants.PullType.Pull_Normal;
|
||||
} else if (type == ProtoConstants.ConversationType.ConversationType_Group) {
|
||||
@@ -773,6 +840,16 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mRobotMentionExternalRobot && message.getContent().getMentionedTargetCount() > 0) {
|
||||
for (String mentioned : message.getContent().getMentionedTargetList()) {
|
||||
if (!notifyReceivers.contains(mentioned)) {
|
||||
WFCMessage.User user = getUserInfo(mentioned);
|
||||
if(user != null && user.getType() == ProtoConstants.UserType.UserType_Robot) {
|
||||
notifyReceivers.add(mentioned);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pullType = ProtoConstants.PullType.Pull_Normal;
|
||||
} else if (type == ProtoConstants.ConversationType.ConversationType_ChatRoom) {
|
||||
boolean isDirect = !StringUtil.isNullOrEmpty(message.getToUser()) || !message.getToList().isEmpty();
|
||||
@@ -1974,6 +2051,19 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if (!isAllow) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
if (modifyType == Modify_Group_Name && !StringUtil.isNullOrEmpty(value)) {
|
||||
if(!mSensitiveOnlyMessage) {
|
||||
Set<String> matched = handleSensitiveWord(value);
|
||||
if (matched != null && !matched.isEmpty()) {
|
||||
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isAllowName(value)) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (oldInfo.getType() == ProtoConstants.GroupType.GroupType_Normal) {
|
||||
@@ -2705,8 +2795,9 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
} finally {
|
||||
mWriteLock.unlock();
|
||||
}
|
||||
|
||||
databaseStore.clearUserMessage(userId);
|
||||
if(!keepMessagesWhenDestroyUser) {
|
||||
databaseStore.clearUserMessage(userId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2810,6 +2901,19 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
) {
|
||||
switch (entry.getType()) {
|
||||
case Modify_DisplayName:
|
||||
if(!StringUtil.isNullOrEmpty(entry.getValue())) {
|
||||
if (!mSensitiveOnlyMessage) {
|
||||
Set<String> matched = handleSensitiveWord(entry.getValue());
|
||||
if (matched != null && !matched.isEmpty()) {
|
||||
return ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isAllowName(entry.getValue())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
builder.setDisplayName(entry.getValue());
|
||||
modified = true;
|
||||
break;
|
||||
@@ -3071,37 +3175,29 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
IMap<String, WFCMessage.User> mUserMap = hzInstance.getMap(USERS);
|
||||
WFCMessage.User us = mUserMap.get(userId);
|
||||
if (us != null) {
|
||||
if (keepDisplayNameWhenDestroyUser) {
|
||||
us = WFCMessage.User.newBuilder()
|
||||
.setUid(userId)
|
||||
.setUpdateDt(System.currentTimeMillis())
|
||||
.setName(userId)
|
||||
.setDeleted(1)
|
||||
.clearAddress()
|
||||
.clearCompany()
|
||||
.clearEmail()
|
||||
.clearExtra()
|
||||
.clearMobile()
|
||||
.clearPortrait()
|
||||
.clearSocial()
|
||||
.build();
|
||||
WFCMessage.User.Builder builder = us.toBuilder().setUpdateDt(System.currentTimeMillis()).setDeleted(1);
|
||||
|
||||
if(keepFullInfoWhenDestroyUser) {
|
||||
if(!keepMobileWhenDestroyUser) {
|
||||
builder.clearMobile();
|
||||
}
|
||||
} else {
|
||||
us = WFCMessage.User.newBuilder()
|
||||
.setUid(userId)
|
||||
.setUpdateDt(System.currentTimeMillis())
|
||||
builder.setUid(userId)
|
||||
.setName(userId)
|
||||
.setDeleted(1)
|
||||
.clearDisplayName()
|
||||
.clearAddress()
|
||||
.clearCompany()
|
||||
.clearEmail()
|
||||
.clearExtra()
|
||||
.clearMobile()
|
||||
.clearPortrait()
|
||||
.clearSocial()
|
||||
.build();
|
||||
.clearGender()
|
||||
.clearSocial();
|
||||
if (!keepDisplayNameWhenDestroyUser) {
|
||||
builder.clearDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
us = builder.build();
|
||||
try {
|
||||
databaseStore.updateUser(us);
|
||||
} catch (Exception e) {
|
||||
@@ -3110,8 +3206,8 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
mUserMap.put(userId, us);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserInfo(WFCMessage.User user) throws Exception {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
@@ -3157,9 +3253,46 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WFCMessage.User> searchUser(String keyword, int searchType, int userType, int page) {
|
||||
public List<String> getUserRobotIds(String userId) {
|
||||
return databaseStore.getUserRobotIds(userId);
|
||||
}
|
||||
|
||||
// 电话号码校验正则表达式(支持中国大陆手机号和固话)
|
||||
private static final String PHONE_REGEX = "^\\s*" + // 允许开头空白
|
||||
"(?:" +
|
||||
"(1[0-9])\\d{9}" +
|
||||
"|" +
|
||||
"((0\\d{2,3})|(\\(0\\d{2,3}\\)))" +
|
||||
"[-\\s.]?" +
|
||||
"\\d{7,8}" +
|
||||
"|" +
|
||||
"\\d{7,8}" +
|
||||
")\\s*$";
|
||||
|
||||
private static final Pattern PHONE_PATTERN = Pattern.compile(PHONE_REGEX);
|
||||
private static final Pattern PHONE_PART_PATTERN = Pattern.compile("^1\\d{0,10}$");
|
||||
|
||||
public static boolean isPhoneNumber(String phone) {
|
||||
if (phone == null || phone.trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Matcher matcher = PHONE_PATTERN.matcher(phone);
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
public static boolean isPhoneNumberPart(String str) {
|
||||
if (str == null || str.trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Matcher matcher = PHONE_PART_PATTERN.matcher(str);
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode searchUser(String userId, String keyword, int searchType, int userType, int page, List<WFCMessage.User> users) {
|
||||
if (mDisableSearch) {
|
||||
return new ArrayList<>();
|
||||
return ErrorCode.ERROR_CODE_NOT_IMPLEMENT;
|
||||
}
|
||||
|
||||
if (mDisableNicknameSearch && searchType == ProtoConstants.SearchUserType.SearchUserType_General) {
|
||||
@@ -3175,10 +3308,29 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
if(mDisableUserIdSearch && searchType == ProtoConstants.SearchUserType.SearchUserType_UserId) {
|
||||
return new ArrayList<>();
|
||||
return ErrorCode.ERROR_CODE_NOT_IMPLEMENT;
|
||||
}
|
||||
|
||||
return databaseStore.searchUserFromDB(keyword, searchType, userType, page);
|
||||
if(mFriendSearchRateLimiter != null && !isPhoneNumberPart(keyword)) {
|
||||
//非电话号码,允许多少次搜索。
|
||||
if(!mFriendSearchRateLimiter.isGranted(userId)) {
|
||||
LOG.error("User {} search user mobile over frequency, keyword {}, searchType {}", userId, keyword, searchType);
|
||||
return ErrorCode.ERROR_CODE_OVER_FREQUENCY;
|
||||
}
|
||||
}
|
||||
|
||||
List<WFCMessage.User> matchedUsers = databaseStore.searchUserFromDB(keyword, searchType, userType, page);
|
||||
if(mFriendSearchEmpthMobileRateLimiter != null && matchedUsers.isEmpty() && isPhoneNumber(keyword)) {
|
||||
//查电话号码为空
|
||||
if(!mFriendSearchEmpthMobileRateLimiter.isGranted(userId)) {
|
||||
LOG.error("User {} search user over frequency, keyword {}, searchType {}", userId, keyword, searchType);
|
||||
return ErrorCode.ERROR_CODE_OVER_FREQUENCY;
|
||||
}
|
||||
}
|
||||
|
||||
users.addAll(matchedUsers);
|
||||
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3901,6 +4053,25 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowName(String name) {
|
||||
if(StringUtil.isNullOrEmpty(name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
name = name.trim();
|
||||
SystemSettingPojo notAllowNameSetting = getSystemSetting(ProtoConstants.SystemSettingType.NOT_ALLOW_USER_NAMES);
|
||||
if (notAllowNameSetting != null && !StringUtil.isNullOrEmpty(notAllowNameSetting.value)) {
|
||||
String[] ss = notAllowNameSetting.value.split(",");
|
||||
for (String s : ss) {
|
||||
if(name.contains(s.trim())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId) {
|
||||
IMap<String, WFCMessage.ChatroomInfo> chatroomInfoMap = m_Server.getHazelcastInstance().getMap(CHATROOMS);
|
||||
@@ -4374,6 +4545,15 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocked(String userId, String clientId) {
|
||||
WFCMessage.UserSettingEntry lockSetting = getUserSetting(userId, UserSettingScopeLockPC, clientId);
|
||||
if(lockSetting != null && "1".equals(lockSetting.getValue())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUserGlobalSilent(String userId) {
|
||||
Boolean slient = userGlobalSlientMap.get(userId);
|
||||
@@ -4770,6 +4950,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
return new ArrayList<>(databaseStore.getSensitiveWord());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSensitiveOnlyMessage() {
|
||||
return mSensitiveOnlyMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WFCMessage.Message getMessage(long messageId) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
@@ -4836,6 +5021,16 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
return mRobotCallbackWithTargetInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRobotMentionExternalRobot() {
|
||||
return mRobotMentionExternalRobot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRobotGetUserInfoMask() {
|
||||
return mRobotGetUserInfoMask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChannelCallbackWithClientInfo() {
|
||||
return mChannelCallbackWithClientInfo;
|
||||
|
||||
@@ -61,6 +61,7 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
private int deleted;
|
||||
|
||||
private boolean pullHistoryMsg;
|
||||
private String ip;
|
||||
|
||||
public int getDeleted() {
|
||||
return deleted;
|
||||
@@ -92,6 +93,15 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
return unReceivedMsgs;
|
||||
}
|
||||
|
||||
public boolean isPcClient() {
|
||||
return platform == ProtoConstants.Platform.Platform_Windows || platform == ProtoConstants.Platform.Platform_OSX || platform == ProtoConstants.Platform.Platform_LINUX;
|
||||
}
|
||||
|
||||
public boolean isPadClient() {
|
||||
return platform == ProtoConstants.Platform.Platform_iPad || platform == ProtoConstants.Platform.Platform_APad || platform == ProtoConstants.Platform.Platform_HarmonyPad;
|
||||
}
|
||||
|
||||
|
||||
public int getPushType() {
|
||||
return pushType;
|
||||
}
|
||||
@@ -159,6 +169,14 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
}
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
private int pushType;
|
||||
private int platform;
|
||||
|
||||
@@ -544,6 +562,15 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
return session.clientSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSessionIp(String username, String clientID, String ip) {
|
||||
Session session = getSession(clientID);
|
||||
if(session != null && session.getDeleted() == 0) {
|
||||
session.setIp(ip);
|
||||
databaseStore.updateSessionIp(username, clientID, ip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Session sessionForClientAndUser(String username, String clientID) {
|
||||
Session session = sessions.get(clientID);
|
||||
|
||||
@@ -331,6 +331,14 @@ public class Server {
|
||||
MediaServerConfig.QINIU_BUCKET_FAVORITE_NAME = config.getProperty(BrokerConstants.QINIU_BUCKET_FAVORITE_NAME);
|
||||
MediaServerConfig.QINIU_BUCKET_FAVORITE_DOMAIN = config.getProperty(BrokerConstants.QINIU_BUCKET_FAVORITE_DOMAIN);
|
||||
|
||||
MediaServerConfig.QINIU_BUCKET_CUSTOM1_NAME = config.getProperty(BrokerConstants.QINIU_BUCKET_CUSTOM1_NAME);
|
||||
MediaServerConfig.QINIU_BUCKET_CUSTOM1_DOMAIN = config.getProperty(BrokerConstants.QINIU_BUCKET_CUSTOM1_DOMAIN);
|
||||
|
||||
MediaServerConfig.QINIU_BUCKET_CUSTOM2_NAME = config.getProperty(BrokerConstants.QINIU_BUCKET_CUSTOM2_NAME);
|
||||
MediaServerConfig.QINIU_BUCKET_CUSTOM2_DOMAIN = config.getProperty(BrokerConstants.QINIU_BUCKET_CUSTOM2_DOMAIN);
|
||||
|
||||
MediaServerConfig.QINIU_BUCKET_CUSTOM3_NAME = config.getProperty(BrokerConstants.QINIU_BUCKET_CUSTOM3_NAME);
|
||||
MediaServerConfig.QINIU_BUCKET_CUSTOM3_DOMAIN = config.getProperty(BrokerConstants.QINIU_BUCKET_CUSTOM3_DOMAIN);
|
||||
|
||||
MediaServerConfig.SERVER_IP = getServerIp(config);
|
||||
|
||||
|
||||
@@ -23,7 +23,14 @@ public class MediaServerConfig {
|
||||
public static String QINIU_BUCKET_PORTRAIT_DOMAIN;
|
||||
public static String QINIU_BUCKET_FAVORITE_NAME;
|
||||
public static String QINIU_BUCKET_FAVORITE_DOMAIN;
|
||||
|
||||
public static String QINIU_BUCKET_CUSTOM1_NAME;
|
||||
public static String QINIU_BUCKET_CUSTOM1_DOMAIN;
|
||||
public static String QINIU_BUCKET_CUSTOM2_NAME;
|
||||
public static String QINIU_BUCKET_CUSTOM2_DOMAIN;
|
||||
public static String QINIU_BUCKET_CUSTOM3_NAME;
|
||||
public static String QINIU_BUCKET_CUSTOM3_DOMAIN;
|
||||
|
||||
|
||||
public static String SERVER_IP = "localhost";
|
||||
public static int HTTP_SERVER_PORT = 8080;
|
||||
public static String FILE_STROAGE_ROOT = "fs";
|
||||
|
||||
@@ -154,9 +154,10 @@ public interface IMessagesStore {
|
||||
WFCMessage.User getUserInfoByName(String name);
|
||||
WFCMessage.User getUserInfoByMobile(String mobile);
|
||||
List<WFCMessage.User> getUserInfosByEmail(String email);
|
||||
List<WFCMessage.User> searchUser(String keyword, int searchType, int userType, int page);
|
||||
ErrorCode searchUser(String userId, String keyword, int searchType, int userType, int page, List<WFCMessage.User> users);
|
||||
|
||||
List<WFCMessage.User> getUserInfoList(int count, int offset);
|
||||
List<String> getUserRobotIds(String userId);
|
||||
|
||||
boolean updateSystemSetting(int id, String value, String desc);
|
||||
SystemSettingPojo getSystemSetting(int id);
|
||||
@@ -190,6 +191,8 @@ public interface IMessagesStore {
|
||||
ErrorCode setFriendAliasRequest(String fromUser, String targetUserId, String alias, long[] head);
|
||||
ErrorCode setFriendExtraRequest(String fromUser, String targetUserId, String extra, long[] head);
|
||||
|
||||
boolean isAllowName(String name);
|
||||
|
||||
ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId);
|
||||
ErrorCode handleQuitChatroom(String userId, String clientId, String chatroomId);
|
||||
|
||||
@@ -205,6 +208,9 @@ public interface IMessagesStore {
|
||||
List<WFCMessage.UserSettingEntry> getUserSetting(String userId, int scope);
|
||||
long updateUserSettings(String userId, WFCMessage.ModifyUserSettingReq request, String clientId);
|
||||
void clearUserSettings(String userId);
|
||||
|
||||
boolean isLocked(String userId, String clientId);
|
||||
|
||||
boolean getUserGlobalSilent(String userId);
|
||||
boolean getUserVoipSilent(String userId);
|
||||
|
||||
@@ -232,6 +238,7 @@ public interface IMessagesStore {
|
||||
boolean addSensitiveWords(List<String> words);
|
||||
boolean removeSensitiveWords(List<String> words);
|
||||
List<String> getAllSensitiveWords();
|
||||
boolean isSensitiveOnlyMessage();
|
||||
|
||||
WFCMessage.Message getMessage(long messageId);
|
||||
|
||||
@@ -251,6 +258,8 @@ public interface IMessagesStore {
|
||||
boolean isRobotCallbackWithClientInfo();
|
||||
boolean isRobotCallbackWithSenderInfo();
|
||||
boolean isRobotCallbackWithTargetInfo();
|
||||
boolean isRobotMentionExternalRobot();
|
||||
int getRobotGetUserInfoMask();
|
||||
|
||||
boolean isChannelCallbackWithClientInfo();
|
||||
boolean isChannelCallbackWithSenderInfo();
|
||||
|
||||
@@ -43,7 +43,7 @@ public interface ISessionsStore {
|
||||
ErrorCode loadActiveSession(String username, String clientID);
|
||||
|
||||
ClientSession updateExistSession(String username, String clientID, WFCMessage.RouteRequest endpoint, boolean cleanSession);
|
||||
|
||||
void updateSessionIp(String username, String clientID, String ip);
|
||||
Session getSession(String clientID);
|
||||
|
||||
void cleanDuplatedToken(String cid, int pushType, String token, boolean isVoip, String packageName);
|
||||
|
||||
@@ -179,6 +179,7 @@ public class MessagesPublisher {
|
||||
message = m_messagesStore.getMessage(messageId);
|
||||
}
|
||||
OutputMessageData outputMessageData = getOutputMessageWithExtraInfo(message, exceptClientId, m_messagesStore.isRobotCallbackWithClientInfo() , m_messagesStore.isRobotCallbackWithSenderInfo(), m_messagesStore.isRobotCallbackWithTargetInfo());
|
||||
outputMessageData.setToRobotId(robot.getUid());
|
||||
Server.getServer().getCallbackScheduler().execute(() -> {
|
||||
try {
|
||||
HttpUtils.httpJsonPost(robot.getCallback(), GsonUtil.gson.toJson(outputMessageData, OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Robot_Message_Callback);
|
||||
@@ -230,6 +231,7 @@ public class MessagesPublisher {
|
||||
}
|
||||
}
|
||||
|
||||
boolean unreadCountIncreased = false;
|
||||
for (Session targetSession : sessions) {
|
||||
//超过7天不活跃的用户忽略
|
||||
if(System.currentTimeMillis() - targetSession.getLastActiveTime() > m_messagesStore.getPushExpiredTimes()) {
|
||||
@@ -314,8 +316,9 @@ public class MessagesPublisher {
|
||||
}
|
||||
|
||||
if (!StringUtil.isNullOrEmpty(pushContent) || messageContentType == 400) {
|
||||
if (!isConvSilent && (persistFlag & 0x02) > 0) {
|
||||
if (!isConvSilent && (persistFlag & 0x02) > 0 && !unreadCountIncreased) {
|
||||
m_messagesStore.increaseUnreceivedMsgCount(user);
|
||||
unreadCountIncreased = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ public class ProtocolProcessor {
|
||||
sessionstatus = 0;
|
||||
}
|
||||
|
||||
userOnlineStatus.sessions.add(new OutputCheckUserOnline.Session(userId, session.getClientID(), session.getPlatform(), sessionstatus, session.getLastActiveTime(), session.getAppName()));
|
||||
userOnlineStatus.sessions.add(new OutputCheckUserOnline.Session(userId, session.getClientID(), session.getPlatform(), sessionstatus, session.getLastActiveTime(), session.getAppName(), session.getIp()));
|
||||
}
|
||||
|
||||
HttpUtils.httpJsonPost(mUserOnlineStatusCallback, GsonUtil.gson.toJson(userOnlineStatus), HttpUtils.HttpPostType.POST_TYPE_User_Online_Event_Callback);
|
||||
|
||||
@@ -141,7 +141,7 @@ public class Qos1PublishHandler extends QosPublishHandler {
|
||||
status = 0;
|
||||
}
|
||||
|
||||
out.addSession(userId, session.getClientID(), session.getPlatform(), status, session.getLastActiveTime(), session.getAppName());
|
||||
out.addSession(userId, session.getClientID(), session.getPlatform(), status, session.getLastActiveTime(), session.getAppName(), session.getIp());
|
||||
}
|
||||
|
||||
callback.onRouteHandled(GsonUtil.gson.toJson(out).getBytes());
|
||||
|
||||
-6
@@ -3,18 +3,12 @@ package io.moquette.spi.impl.security;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.DESKeySpec;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
@@ -10,6 +10,7 @@ package win.liyufan.im;
|
||||
|
||||
public interface IMTopic {
|
||||
String SendMessageTopic = "MS";
|
||||
String RobotReplyMessageTopic = "RRM";
|
||||
String MultiCastMessageTopic = "MMC";
|
||||
String RecallMessageTopic = "MR";
|
||||
String RecallMultiCastMessageTopic = "MRMC";
|
||||
@@ -51,6 +52,7 @@ public interface IMTopic {
|
||||
String FriendRequestPullTopic = "FRP";
|
||||
String NotifyFriendRequestTopic = "FRN";
|
||||
String RriendRequestUnreadSyncTopic = "FRUS";
|
||||
String SetFriendExtraTopic = "FES";
|
||||
|
||||
String DeleteFriendTopic = "FDL";
|
||||
String FriendPullTopic = "FP";
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package win.liyufan.im;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class SensitiveFilter {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SensitiveFilter.class);
|
||||
public enum MatchType {
|
||||
MIN_MATCH("最小匹配规则"),MAX_MATCH("最大匹配规则");
|
||||
|
||||
@@ -71,6 +75,9 @@ public class SensitiveFilter {
|
||||
i=i+sensitiveWordLength-1;
|
||||
}
|
||||
}
|
||||
if(!sensitiveWords.isEmpty()) {
|
||||
LOG.info("Text {} matched sensitive word {}", originalText, sensitiveWords);
|
||||
}
|
||||
return sensitiveWords;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,4 +22,5 @@ public interface UserSettingScope {
|
||||
int kUserSettingPrivacySearchable = 27;
|
||||
int kUserSettingAddFriendStrategy = 28;
|
||||
int kUserSettingScopeSyncBadge = 29;
|
||||
int UserSettingScopeLockPC = 30;
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>1.3.7</version>
|
||||
<version>1.4.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package cn.wildfirechat.common;
|
||||
|
||||
/**
|
||||
* API路径接口
|
||||
* <p>
|
||||
* 定义了野火IM服务器所有管理接口的API路径。
|
||||
* 包括聊天室、敏感词、域、用户、好友、黑名单、消息、群组、会议、频道等模块的接口路径。
|
||||
* </p>
|
||||
*/
|
||||
public interface APIPath {
|
||||
String Create_Chatroom = "/admin/chatroom/create";
|
||||
String Chatroom_Destroy = "/admin/chatroom/del";
|
||||
@@ -21,6 +28,7 @@ public interface APIPath {
|
||||
String Get_Domain = "/admin/domain/get";
|
||||
String Destroy_Domain = "/admin/domain/destroy";
|
||||
String List_Domain = "/admin/domain/list";
|
||||
String Ping_Domain = "/admin/domain/ping";
|
||||
|
||||
String Create_User = "/admin/user/create";
|
||||
String Update_User = "/admin/user/update";
|
||||
@@ -37,6 +45,7 @@ public interface APIPath {
|
||||
String User_Get_Email_Info = "/admin/user/get_info_by_email";
|
||||
String User_Get_All = "/admin/user/all";
|
||||
String User_Get_Robot_Info = "/admin/user/get_robot_info";
|
||||
String User_Get_User_Robots = "/admin/user/get_user_robots";
|
||||
String User_Get_Blocked_List = "/admin/user/get_blocked_list";
|
||||
String User_Check_Block_Status = "/admin/user/check_block_status";
|
||||
String User_Get_Online_Status = "/admin/user/onlinestatus";
|
||||
@@ -94,6 +103,7 @@ public interface APIPath {
|
||||
String Group_Set_Manager = "/admin/group/manager/set";
|
||||
String Group_Mute_Member = "/admin/group/manager/mute";
|
||||
String Group_Allow_Member = "/admin/group/manager/allow";
|
||||
String Group_Join_Request_Add = "/admin/group/join_request/add";
|
||||
String Get_User_Groups = "/admin/group/of_user";
|
||||
String Get_User_Groups_By_Type = "/admin/group/of_user_by_type";
|
||||
String Group_Set_Member_Alias = "/admin/group/member/set_alias";
|
||||
@@ -113,6 +123,9 @@ public interface APIPath {
|
||||
String Put_System_Setting = "/admin/system/put_setting";
|
||||
String GET_CUSTOMER = "/admin/customer";
|
||||
String Health = "/admin/health";
|
||||
String Get_Conversation_Files = "/admin/file/conversation_files";
|
||||
String Get_User_Files = "/admin/file/user_files";
|
||||
String Get_Message_File = "/admin/file/message_file";
|
||||
|
||||
String Conference_List = "/admin/conference/list";
|
||||
String Conference_Exist = "/admin/conference/exist";
|
||||
@@ -128,6 +141,8 @@ public interface APIPath {
|
||||
String Channel_Update_Profile = "/channel/update_profile";
|
||||
String Channel_Get_Profile = "/channel/get_profile";
|
||||
String Channel_Message_Send = "/channel/message/send";
|
||||
String Channel_Msg_Recall = "/channel/message/recall";
|
||||
String Channel_Msg_Republish = "/channel/message/republish";
|
||||
String Channel_Subscribe = "/channel/subscribe";
|
||||
String Channel_Subscriber_List = "/channel/subscriber_list";
|
||||
String Channel_Is_Subscriber = "/channel/is_subscriber";
|
||||
@@ -136,6 +151,7 @@ public interface APIPath {
|
||||
String Robot_User_Info = "/robot/user_info";
|
||||
String Robot_Get_Profile = "/robot/profile";
|
||||
String Robot_Message_Send = "/robot/message/send";
|
||||
String Robot_Message_Reply = "/robot/message/reply";
|
||||
String Robot_Message_Recall = "/robot/message/recall";
|
||||
String Robot_Message_Update = "/robot/message/update";
|
||||
String Robot_Set_Callback = "/robot/set_callback";
|
||||
|
||||
@@ -8,6 +8,25 @@
|
||||
|
||||
package cn.wildfirechat.common;
|
||||
|
||||
/**
|
||||
* 错误码枚举
|
||||
* <p>
|
||||
* 定义了野火IM系统中所有可能的错误码,包括:
|
||||
* <ul>
|
||||
* <li>通用错误(0-5)</li>
|
||||
* <li>认证错误(6-8)</li>
|
||||
* <li>消息错误(9-10)</li>
|
||||
* <li>群组错误(11-12)</li>
|
||||
* <li>用户错误(16-19)</li>
|
||||
* <li>聊天室错误(20)</li>
|
||||
* <li>频道错误(21-25)</li>
|
||||
* <li>会议错误(60-61)</li>
|
||||
* <li>应用错误(70)</li>
|
||||
* <li>密聊错误(81-87)</li>
|
||||
* <li>其他错误(90-255)</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public enum ErrorCode {
|
||||
//General error
|
||||
ERROR_CODE_SUCCESS(0, "success"),
|
||||
@@ -49,6 +68,7 @@ public enum ErrorCode {
|
||||
ERROR_CODE_ROBOT_NO_TOKEN(27, "robot no token"),
|
||||
ERROR_CODE_WS_NOT_CONFIGURED_CORRECTLY(28, "ws not configured correctly"),
|
||||
ERROR_CODE_TIME_INCONSISTENT(30, "time inconsistent"),
|
||||
ERROR_CODE_MESSAGE_TOO_LARGE(35, "message too large"),
|
||||
ERROR_CODE_CONFERENCE_ROOM_NOT_EXIST(60, "conference room not exist"),
|
||||
ERROR_CODE_CONFERENCE_SERVICE_NOT_AVAILABLE(61, "conference service not available"),
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
package cn.wildfirechat.common;
|
||||
|
||||
/**
|
||||
* IM异常事件类
|
||||
* <p>
|
||||
* 用于记录和传递IM系统中的异常事件信息。
|
||||
* </p>
|
||||
*/
|
||||
public class IMExceptionEvent {
|
||||
/**
|
||||
* 事件类型接口
|
||||
* <p>
|
||||
* 定义了各种异常事件的类型常量。
|
||||
* </p>
|
||||
*/
|
||||
public interface EventType {
|
||||
int RDBS_Exception = 1;
|
||||
int MONGO_Exception = 2;
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
/**
|
||||
* 会话类
|
||||
* <p>
|
||||
* 表示一个会话对象,包含会话类型、目标ID和线路信息。
|
||||
* 用于标识消息发送或接收的目标会话。
|
||||
* </p>
|
||||
*/
|
||||
public class Conversation {
|
||||
private int type;
|
||||
private String target;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FilesPojo {
|
||||
public int total;
|
||||
public List<FilePojo> files;
|
||||
public static class FilePojo {
|
||||
public long messageId;
|
||||
public String sender;
|
||||
public int conversationType;
|
||||
public String target;
|
||||
public int line;
|
||||
public String name;
|
||||
public String url;
|
||||
public int size;
|
||||
public int downloadCount;
|
||||
public long timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class GetConversationFilesPojo {
|
||||
public int conversationType;
|
||||
public String target;
|
||||
public int line;
|
||||
public String userId;
|
||||
public int offset;
|
||||
public boolean desc;
|
||||
public int count;
|
||||
}
|
||||
@@ -7,6 +7,7 @@ public class GetOnlineUserResult {
|
||||
public String userId;
|
||||
public String clientId;
|
||||
public int platform;
|
||||
public String ip;
|
||||
}
|
||||
|
||||
public ArrayList<GetOnlineUserResult.UserClient> userClients;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class GetUserFilesPojo {
|
||||
public String userId;
|
||||
public int offset;
|
||||
public boolean desc;
|
||||
public int count;
|
||||
}
|
||||
@@ -14,6 +14,12 @@ import io.netty.util.internal.StringUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 添加群组成员输入参数类
|
||||
* <p>
|
||||
* 封装添加群组成员的输入参数,包括群组ID、成员列表、成员额外信息等。
|
||||
* </p>
|
||||
*/
|
||||
public class InputAddGroupMember extends InputGroupBase {
|
||||
private String group_id;
|
||||
private List<PojoGroupMember> members;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class InputCountOffset {
|
||||
public int count;
|
||||
public int offset;
|
||||
}
|
||||
@@ -14,6 +14,12 @@ import io.netty.util.internal.StringUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 创建群组输入参数类
|
||||
* <p>
|
||||
* 封装创建群组的输入参数,包括群组信息、成员列表、成员额外信息等。
|
||||
* </p>
|
||||
*/
|
||||
public class InputCreateGroup extends InputGroupBase {
|
||||
private PojoGroup group;
|
||||
private String member_extra;
|
||||
|
||||
@@ -12,6 +12,7 @@ public class InputGetUserInfo {
|
||||
private String userId;
|
||||
private String name;
|
||||
private String mobile;
|
||||
private boolean includeDeleted;
|
||||
|
||||
public InputGetUserInfo() {
|
||||
}
|
||||
@@ -22,6 +23,13 @@ public class InputGetUserInfo {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public InputGetUserInfo(String userId, String name, String mobile, boolean includeDeleted) {
|
||||
this.userId = userId;
|
||||
this.name = name;
|
||||
this.mobile = mobile;
|
||||
this.includeDeleted = includeDeleted;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
@@ -45,4 +53,12 @@ public class InputGetUserInfo {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isIncludeDeleted() {
|
||||
return includeDeleted;
|
||||
}
|
||||
|
||||
public void setIncludeDeleted(boolean includeDeleted) {
|
||||
this.includeDeleted = includeDeleted;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,21 @@ package cn.wildfirechat.pojos;
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
|
||||
/**
|
||||
* 用户信息类
|
||||
* <p>
|
||||
* 封装用户的所有信息,包括:
|
||||
* <ul>
|
||||
* <li>用户ID、用户名、显示名称</li>
|
||||
* <li>头像、性别</li>
|
||||
* <li>手机号、邮箱、地址</li>
|
||||
* <li>公司、社交信息</li>
|
||||
* <li>用户类型、删除状态</li>
|
||||
* <li>更新时间</li>
|
||||
* <li>额外扩展信息</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class InputOutputUserInfo {
|
||||
private String userId;
|
||||
private String name;
|
||||
@@ -25,6 +40,7 @@ public class InputOutputUserInfo {
|
||||
private String social;
|
||||
private String extra;
|
||||
private int type;
|
||||
private int deleted;
|
||||
private long updateDt;
|
||||
|
||||
public static InputOutputUserInfo fromPbUser(WFCMessage.User pbUser) {
|
||||
@@ -42,6 +58,7 @@ public class InputOutputUserInfo {
|
||||
inputCreateUser.extra = pbUser.getExtra();
|
||||
inputCreateUser.type = pbUser.getType();
|
||||
inputCreateUser.updateDt = pbUser.getUpdateDt();
|
||||
inputCreateUser.deleted = pbUser.getDeleted();
|
||||
return inputCreateUser;
|
||||
}
|
||||
|
||||
@@ -77,6 +94,7 @@ public class InputOutputUserInfo {
|
||||
newUserBuilder.setExtra(getExtra());
|
||||
newUserBuilder.setGender(gender);
|
||||
newUserBuilder.setType(type);
|
||||
newUserBuilder.setDeleted(deleted);
|
||||
|
||||
newUserBuilder.setUpdateDt(System.currentTimeMillis());
|
||||
return newUserBuilder.build();
|
||||
@@ -185,4 +203,24 @@ public class InputOutputUserInfo {
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(int deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" +
|
||||
"userId='" + userId + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", displayName='" + displayName + '\'' +
|
||||
", portrait='" + portrait + '\'' +
|
||||
", mobile='" + mobile + '\'' +
|
||||
", updateDt=" + updateDt +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class LongPojo {
|
||||
public long value;
|
||||
}
|
||||
@@ -16,6 +16,22 @@ import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息内容负载类
|
||||
* <p>
|
||||
* 封装消息的所有内容信息,包括:
|
||||
* <ul>
|
||||
* <li>消息类型</li>
|
||||
* <li>可搜索内容(文本消息的文本)</li>
|
||||
* <li>推送内容和推送数据</li>
|
||||
* <li>消息内容(二进制数据)</li>
|
||||
* <li>媒体类型和远程URL</li>
|
||||
* <li>持久化标志和过期时间</li>
|
||||
* <li>@提及信息</li>
|
||||
* <li>额外数据</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class MessagePayload {
|
||||
private int type;
|
||||
private String searchableContent;
|
||||
|
||||
@@ -20,22 +20,24 @@ public class OutputCheckUserOnline {
|
||||
public int status; //0 online, 1 have session offline
|
||||
public long lastSeen;
|
||||
public String packageName;
|
||||
public String ip;
|
||||
|
||||
public Session() {
|
||||
}
|
||||
|
||||
public Session(String clientId, String userId, int platform, int status, long lastSeen, String packageName) {
|
||||
public Session(String clientId, String userId, int platform, int status, long lastSeen, String packageName, String ip) {
|
||||
this.clientId = clientId;
|
||||
this.userId = userId;
|
||||
this.platform = platform;
|
||||
this.status = status;
|
||||
this.lastSeen = lastSeen;
|
||||
this.packageName = packageName;
|
||||
this.ip = ip;
|
||||
}
|
||||
}
|
||||
|
||||
public void addSession(String userId, String clientId, int platform, int status, long lastSeen, String packageName) {
|
||||
Session session = new Session(clientId, userId, platform, status, lastSeen, packageName);
|
||||
public void addSession(String userId, String clientId, int platform, int status, long lastSeen, String packageName, String ip) {
|
||||
Session session = new Session(clientId, userId, platform, status, lastSeen, packageName, ip);
|
||||
sessions.add(session);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ public class OutputMessageData {
|
||||
private PojoGroupInfo targetGroupInfo;
|
||||
private OutputGetChannelInfo targetChannelInfo;
|
||||
|
||||
private String toRobotId;
|
||||
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
@@ -119,6 +121,14 @@ public class OutputMessageData {
|
||||
return fromProtoMessage(protoMessage, null);
|
||||
}
|
||||
|
||||
public String getToRobotId() {
|
||||
return toRobotId;
|
||||
}
|
||||
|
||||
public void setToRobotId(String toRobotId) {
|
||||
this.toRobotId = toRobotId;
|
||||
}
|
||||
|
||||
public static OutputMessageData fromProtoMessage(WFCMessage.Message protoMessage, OutputClient fromClient) {
|
||||
OutputMessageData data = new OutputMessageData();
|
||||
data.messageId = protoMessage.getMessageId();
|
||||
|
||||
@@ -2,11 +2,8 @@ package cn.wildfirechat.pojos;
|
||||
|
||||
public class PojoConferenceInfo {
|
||||
public String roomId;
|
||||
public String serverId;
|
||||
public String description;
|
||||
public int max_publishers;
|
||||
public int num_publishers;
|
||||
public int bitrate;
|
||||
public boolean advance;
|
||||
public boolean recording;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,12 @@ package cn.wildfirechat.pojos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 群组对象类
|
||||
* <p>
|
||||
* 封装创建群组时使用的参数,包含群组信息和成员列表。
|
||||
* </p>
|
||||
*/
|
||||
public class PojoGroup {
|
||||
private PojoGroupInfo group_info;
|
||||
private List<PojoGroupMember> members;
|
||||
|
||||
@@ -8,6 +8,19 @@
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
/**
|
||||
* 群组信息类
|
||||
* <p>
|
||||
* 封装群组的信息,包括:
|
||||
* <ul>
|
||||
* <li>群组ID、名称、头像、所有者</li>
|
||||
* <li>群组类型、成员数量、最大成员数</li>
|
||||
* <li>群组设置(禁言、加群方式、私聊、可搜索、历史消息)</li>
|
||||
* <li>是否超级群、是否已删除</li>
|
||||
* <li>更新时间</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class PojoGroupInfo {
|
||||
String target_id;
|
||||
String name;
|
||||
|
||||
@@ -8,6 +8,19 @@
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
/**
|
||||
* 群组成员类
|
||||
* <p>
|
||||
* 封装群组成员的信息,包括:
|
||||
* <ul>
|
||||
* <li>成员ID</li>
|
||||
* <li>群组内别名</li>
|
||||
* <li>成员类型</li>
|
||||
* <li>扩展信息</li>
|
||||
* <li>更新时间和创建时间</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class PojoGroupMember {
|
||||
String member_id;
|
||||
String alias;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReplyMessageData {
|
||||
private long messageUid;
|
||||
private MessagePayload payload;
|
||||
private boolean only2Sender;
|
||||
|
||||
public long getMessageUid() {
|
||||
return messageUid;
|
||||
}
|
||||
|
||||
public void setMessageUid(long messageUid) {
|
||||
this.messageUid = messageUid;
|
||||
}
|
||||
|
||||
public MessagePayload getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public void setPayload(MessagePayload payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public boolean isOnly2Sender() {
|
||||
return only2Sender;
|
||||
}
|
||||
|
||||
public void setOnly2Sender(boolean only2Sender) {
|
||||
this.only2Sender = only2Sender;
|
||||
}
|
||||
|
||||
public static boolean isValide(ReplyMessageData sendMessageData) {
|
||||
if(sendMessageData.messageUid <=0 ||
|
||||
sendMessageData.getPayload() == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RepublishChannelMessageData {
|
||||
private List<String> targets;
|
||||
private long messageId;
|
||||
|
||||
public List<String> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void setTargets(List<String> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
public long getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public void setMessageId(long messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ public class SendMessageData {
|
||||
private MessagePayload payload;
|
||||
private List<String> toUsers;
|
||||
private boolean isMeshMessage;
|
||||
private boolean isUserMessage;
|
||||
|
||||
public String getSender() {
|
||||
return sender;
|
||||
@@ -61,6 +62,14 @@ public class SendMessageData {
|
||||
isMeshMessage = meshMessage;
|
||||
}
|
||||
|
||||
public boolean isUserMessage() {
|
||||
return isUserMessage;
|
||||
}
|
||||
|
||||
public void setUserMessage(boolean userMessage) {
|
||||
isUserMessage = userMessage;
|
||||
}
|
||||
|
||||
public static boolean isValide(SendMessageData sendMessageData) {
|
||||
if(sendMessageData == null ||
|
||||
sendMessageData.getConv() == null ||
|
||||
|
||||
@@ -11,6 +11,12 @@ package cn.wildfirechat.pojos;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
/**
|
||||
* 发送消息结果类
|
||||
* <p>
|
||||
* 封装发送消息后的返回结果,包含消息UID和时间戳。
|
||||
* </p>
|
||||
*/
|
||||
public class SendMessageResult {
|
||||
private long messageUid;
|
||||
private long timestamp;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.wildfirechat.pojos.mesh;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PojoAddJoinGroupRequest {
|
||||
public String domainId;
|
||||
public String operator;
|
||||
public String group_id;
|
||||
public List<String> userIds;
|
||||
public String reason;
|
||||
public String extra;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos.mesh;
|
||||
|
||||
|
||||
public class PojoDomainPingRequest {
|
||||
public String domainId;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos.mesh;
|
||||
|
||||
|
||||
public class PojoDomainPingResponse {
|
||||
public boolean success;
|
||||
public String errorMessage;
|
||||
public String myDomainName;
|
||||
}
|
||||
@@ -226,6 +226,7 @@ public class ProtoConstants {
|
||||
|
||||
public interface SystemSettingType {
|
||||
int Group_Max_Member_Count = 1;
|
||||
int NOT_ALLOW_USER_NAMES = 2;
|
||||
}
|
||||
|
||||
public interface SearchUserType {
|
||||
|
||||
@@ -67311,6 +67311,641 @@ public final class WFCMessage {
|
||||
// @@protoc_insertion_point(class_scope:ApplicationConfigRequest)
|
||||
}
|
||||
|
||||
public interface StringPairOrBuilder
|
||||
extends com.google.protobuf.MessageOrBuilder {
|
||||
|
||||
// required string key = 1;
|
||||
/**
|
||||
* <code>required string key = 1;</code>
|
||||
*/
|
||||
boolean hasKey();
|
||||
/**
|
||||
* <code>required string key = 1;</code>
|
||||
*/
|
||||
java.lang.String getKey();
|
||||
/**
|
||||
* <code>required string key = 1;</code>
|
||||
*/
|
||||
com.google.protobuf.ByteString
|
||||
getKeyBytes();
|
||||
|
||||
// optional string value = 2;
|
||||
/**
|
||||
* <code>optional string value = 2;</code>
|
||||
*/
|
||||
boolean hasValue();
|
||||
/**
|
||||
* <code>optional string value = 2;</code>
|
||||
*/
|
||||
java.lang.String getValue();
|
||||
/**
|
||||
* <code>optional string value = 2;</code>
|
||||
*/
|
||||
com.google.protobuf.ByteString
|
||||
getValueBytes();
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code StringPair}
|
||||
*/
|
||||
public static final class StringPair extends
|
||||
com.google.protobuf.GeneratedMessage
|
||||
implements StringPairOrBuilder {
|
||||
// Use StringPair.newBuilder() to construct.
|
||||
private StringPair(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
|
||||
super(builder);
|
||||
this.unknownFields = builder.getUnknownFields();
|
||||
}
|
||||
private StringPair(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
|
||||
|
||||
private static final StringPair defaultInstance;
|
||||
public static StringPair getDefaultInstance() {
|
||||
return defaultInstance;
|
||||
}
|
||||
|
||||
public StringPair getDefaultInstanceForType() {
|
||||
return defaultInstance;
|
||||
}
|
||||
|
||||
private final com.google.protobuf.UnknownFieldSet unknownFields;
|
||||
@java.lang.Override
|
||||
public final com.google.protobuf.UnknownFieldSet
|
||||
getUnknownFields() {
|
||||
return this.unknownFields;
|
||||
}
|
||||
private StringPair(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
initFields();
|
||||
int mutable_bitField0_ = 0;
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder();
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
default: {
|
||||
if (!parseUnknownField(input, unknownFields,
|
||||
extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 10: {
|
||||
bitField0_ |= 0x00000001;
|
||||
key_ = input.readBytes();
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
bitField0_ |= 0x00000002;
|
||||
value_ = input.readBytes();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(
|
||||
e.getMessage()).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
this.unknownFields = unknownFields.build();
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return cn.wildfirechat.proto.WFCMessage.internal_static_StringPair_descriptor;
|
||||
}
|
||||
|
||||
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return cn.wildfirechat.proto.WFCMessage.internal_static_StringPair_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
cn.wildfirechat.proto.WFCMessage.StringPair.class, cn.wildfirechat.proto.WFCMessage.StringPair.Builder.class);
|
||||
}
|
||||
|
||||
public static com.google.protobuf.Parser<StringPair> PARSER =
|
||||
new com.google.protobuf.AbstractParser<StringPair>() {
|
||||
public StringPair parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return new StringPair(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Parser<StringPair> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
private int bitField0_;
|
||||
// required string key = 1;
|
||||
public static final int KEY_FIELD_NUMBER = 1;
|
||||
private java.lang.Object key_;
|
||||
/**
|
||||
* <code>required string key = 1;</code>
|
||||
*/
|
||||
public boolean hasKey() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
}
|
||||
/**
|
||||
* <code>required string key = 1;</code>
|
||||
*/
|
||||
public java.lang.String getKey() {
|
||||
java.lang.Object ref = key_;
|
||||
if (ref instanceof java.lang.String) {
|
||||
return (java.lang.String) ref;
|
||||
} else {
|
||||
com.google.protobuf.ByteString bs =
|
||||
(com.google.protobuf.ByteString) ref;
|
||||
java.lang.String s = bs.toStringUtf8();
|
||||
if (bs.isValidUtf8()) {
|
||||
key_ = s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>required string key = 1;</code>
|
||||
*/
|
||||
public com.google.protobuf.ByteString
|
||||
getKeyBytes() {
|
||||
java.lang.Object ref = key_;
|
||||
if (ref instanceof java.lang.String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8(
|
||||
(java.lang.String) ref);
|
||||
key_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
|
||||
// optional string value = 2;
|
||||
public static final int VALUE_FIELD_NUMBER = 2;
|
||||
private java.lang.Object value_;
|
||||
/**
|
||||
* <code>optional string value = 2;</code>
|
||||
*/
|
||||
public boolean hasValue() {
|
||||
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||
}
|
||||
/**
|
||||
* <code>optional string value = 2;</code>
|
||||
*/
|
||||
public java.lang.String getValue() {
|
||||
java.lang.Object ref = value_;
|
||||
if (ref instanceof java.lang.String) {
|
||||
return (java.lang.String) ref;
|
||||
} else {
|
||||
com.google.protobuf.ByteString bs =
|
||||
(com.google.protobuf.ByteString) ref;
|
||||
java.lang.String s = bs.toStringUtf8();
|
||||
if (bs.isValidUtf8()) {
|
||||
value_ = s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>optional string value = 2;</code>
|
||||
*/
|
||||
public com.google.protobuf.ByteString
|
||||
getValueBytes() {
|
||||
java.lang.Object ref = value_;
|
||||
if (ref instanceof java.lang.String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8(
|
||||
(java.lang.String) ref);
|
||||
value_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
key_ = "";
|
||||
value_ = "";
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized != -1) return isInitialized == 1;
|
||||
|
||||
if (!hasKey()) {
|
||||
memoizedIsInitialized = 0;
|
||||
return false;
|
||||
}
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
getSerializedSize();
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
output.writeBytes(1, getKeyBytes());
|
||||
}
|
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
output.writeBytes(2, getValueBytes());
|
||||
}
|
||||
getUnknownFields().writeTo(output);
|
||||
}
|
||||
|
||||
private int memoizedSerializedSize = -1;
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSerializedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeBytesSize(1, getKeyBytes());
|
||||
}
|
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeBytesSize(2, getValueBytes());
|
||||
}
|
||||
size += getUnknownFields().getSerializedSize();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
@java.lang.Override
|
||||
protected java.lang.Object writeReplace()
|
||||
throws java.io.ObjectStreamException {
|
||||
return super.writeReplace();
|
||||
}
|
||||
|
||||
public static cn.wildfirechat.proto.WFCMessage.StringPair parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static cn.wildfirechat.proto.WFCMessage.StringPair parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static cn.wildfirechat.proto.WFCMessage.StringPair parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static cn.wildfirechat.proto.WFCMessage.StringPair parseFrom(
|
||||
byte[] data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static cn.wildfirechat.proto.WFCMessage.StringPair parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input);
|
||||
}
|
||||
public static cn.wildfirechat.proto.WFCMessage.StringPair parseFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input, extensionRegistry);
|
||||
}
|
||||
public static cn.wildfirechat.proto.WFCMessage.StringPair parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseDelimitedFrom(input);
|
||||
}
|
||||
public static cn.wildfirechat.proto.WFCMessage.StringPair parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseDelimitedFrom(input, extensionRegistry);
|
||||
}
|
||||
public static cn.wildfirechat.proto.WFCMessage.StringPair parseFrom(
|
||||
com.google.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input);
|
||||
}
|
||||
public static cn.wildfirechat.proto.WFCMessage.StringPair parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input, extensionRegistry);
|
||||
}
|
||||
|
||||
public static Builder newBuilder() { return Builder.create(); }
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder(cn.wildfirechat.proto.WFCMessage.StringPair prototype) {
|
||||
return newBuilder().mergeFrom(prototype);
|
||||
}
|
||||
public Builder toBuilder() { return newBuilder(this); }
|
||||
|
||||
@java.lang.Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessage.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code StringPair}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessage.Builder<Builder>
|
||||
implements cn.wildfirechat.proto.WFCMessage.StringPairOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return cn.wildfirechat.proto.WFCMessage.internal_static_StringPair_descriptor;
|
||||
}
|
||||
|
||||
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return cn.wildfirechat.proto.WFCMessage.internal_static_StringPair_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
cn.wildfirechat.proto.WFCMessage.StringPair.class, cn.wildfirechat.proto.WFCMessage.StringPair.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using cn.wildfirechat.proto.WFCMessage.StringPair.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private Builder(
|
||||
com.google.protobuf.GeneratedMessage.BuilderParent parent) {
|
||||
super(parent);
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
private void maybeForceBuilderInitialization() {
|
||||
if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
|
||||
}
|
||||
}
|
||||
private static Builder create() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
key_ = "";
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
value_ = "";
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder clone() {
|
||||
return create().mergeFrom(buildPartial());
|
||||
}
|
||||
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return cn.wildfirechat.proto.WFCMessage.internal_static_StringPair_descriptor;
|
||||
}
|
||||
|
||||
public cn.wildfirechat.proto.WFCMessage.StringPair getDefaultInstanceForType() {
|
||||
return cn.wildfirechat.proto.WFCMessage.StringPair.getDefaultInstance();
|
||||
}
|
||||
|
||||
public cn.wildfirechat.proto.WFCMessage.StringPair build() {
|
||||
cn.wildfirechat.proto.WFCMessage.StringPair result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public cn.wildfirechat.proto.WFCMessage.StringPair buildPartial() {
|
||||
cn.wildfirechat.proto.WFCMessage.StringPair result = new cn.wildfirechat.proto.WFCMessage.StringPair(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
int to_bitField0_ = 0;
|
||||
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
to_bitField0_ |= 0x00000001;
|
||||
}
|
||||
result.key_ = key_;
|
||||
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
to_bitField0_ |= 0x00000002;
|
||||
}
|
||||
result.value_ = value_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof cn.wildfirechat.proto.WFCMessage.StringPair) {
|
||||
return mergeFrom((cn.wildfirechat.proto.WFCMessage.StringPair)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(cn.wildfirechat.proto.WFCMessage.StringPair other) {
|
||||
if (other == cn.wildfirechat.proto.WFCMessage.StringPair.getDefaultInstance()) return this;
|
||||
if (other.hasKey()) {
|
||||
bitField0_ |= 0x00000001;
|
||||
key_ = other.key_;
|
||||
onChanged();
|
||||
}
|
||||
if (other.hasValue()) {
|
||||
bitField0_ |= 0x00000002;
|
||||
value_ = other.value_;
|
||||
onChanged();
|
||||
}
|
||||
this.mergeUnknownFields(other.getUnknownFields());
|
||||
return this;
|
||||
}
|
||||
|
||||
public final boolean isInitialized() {
|
||||
if (!hasKey()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
cn.wildfirechat.proto.WFCMessage.StringPair parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (cn.wildfirechat.proto.WFCMessage.StringPair) e.getUnfinishedMessage();
|
||||
throw e;
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private int bitField0_;
|
||||
|
||||
// required string key = 1;
|
||||
private java.lang.Object key_ = "";
|
||||
/**
|
||||
* <code>required string key = 1;</code>
|
||||
*/
|
||||
public boolean hasKey() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
}
|
||||
/**
|
||||
* <code>required string key = 1;</code>
|
||||
*/
|
||||
public java.lang.String getKey() {
|
||||
java.lang.Object ref = key_;
|
||||
if (!(ref instanceof java.lang.String)) {
|
||||
java.lang.String s = ((com.google.protobuf.ByteString) ref)
|
||||
.toStringUtf8();
|
||||
key_ = s;
|
||||
return s;
|
||||
} else {
|
||||
return (java.lang.String) ref;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>required string key = 1;</code>
|
||||
*/
|
||||
public com.google.protobuf.ByteString
|
||||
getKeyBytes() {
|
||||
java.lang.Object ref = key_;
|
||||
if (ref instanceof String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8(
|
||||
(java.lang.String) ref);
|
||||
key_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>required string key = 1;</code>
|
||||
*/
|
||||
public Builder setKey(
|
||||
java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
bitField0_ |= 0x00000001;
|
||||
key_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>required string key = 1;</code>
|
||||
*/
|
||||
public Builder clearKey() {
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
key_ = getDefaultInstance().getKey();
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>required string key = 1;</code>
|
||||
*/
|
||||
public Builder setKeyBytes(
|
||||
com.google.protobuf.ByteString value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
bitField0_ |= 0x00000001;
|
||||
key_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
// optional string value = 2;
|
||||
private java.lang.Object value_ = "";
|
||||
/**
|
||||
* <code>optional string value = 2;</code>
|
||||
*/
|
||||
public boolean hasValue() {
|
||||
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||
}
|
||||
/**
|
||||
* <code>optional string value = 2;</code>
|
||||
*/
|
||||
public java.lang.String getValue() {
|
||||
java.lang.Object ref = value_;
|
||||
if (!(ref instanceof java.lang.String)) {
|
||||
java.lang.String s = ((com.google.protobuf.ByteString) ref)
|
||||
.toStringUtf8();
|
||||
value_ = s;
|
||||
return s;
|
||||
} else {
|
||||
return (java.lang.String) ref;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>optional string value = 2;</code>
|
||||
*/
|
||||
public com.google.protobuf.ByteString
|
||||
getValueBytes() {
|
||||
java.lang.Object ref = value_;
|
||||
if (ref instanceof String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8(
|
||||
(java.lang.String) ref);
|
||||
value_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>optional string value = 2;</code>
|
||||
*/
|
||||
public Builder setValue(
|
||||
java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
bitField0_ |= 0x00000002;
|
||||
value_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional string value = 2;</code>
|
||||
*/
|
||||
public Builder clearValue() {
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
value_ = getDefaultInstance().getValue();
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional string value = 2;</code>
|
||||
*/
|
||||
public Builder setValueBytes(
|
||||
com.google.protobuf.ByteString value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
bitField0_ |= 0x00000002;
|
||||
value_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:StringPair)
|
||||
}
|
||||
|
||||
static {
|
||||
defaultInstance = new StringPair(true);
|
||||
defaultInstance.initFields();
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:StringPair)
|
||||
}
|
||||
|
||||
private static com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_AddFriendRequest_descriptor;
|
||||
private static
|
||||
@@ -67691,6 +68326,11 @@ public final class WFCMessage {
|
||||
private static
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable
|
||||
internal_static_ApplicationConfigRequest_fieldAccessorTable;
|
||||
private static com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_StringPair_descriptor;
|
||||
private static
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable
|
||||
internal_static_StringPair_fieldAccessorTable;
|
||||
|
||||
public static com.google.protobuf.Descriptors.FileDescriptor
|
||||
getDescriptor() {
|
||||
@@ -67877,9 +68517,10 @@ public final class WFCMessage {
|
||||
"rget_id\030\001 \002(\t\022\014\n\004type\030\002 \002(\005\022\014\n\004host\030\003 \002(" +
|
||||
"\t\"o\n\030ApplicationConfigRequest\022\r\n\005appId\030\001" +
|
||||
" \002(\t\022\017\n\007appType\030\002 \002(\005\022\021\n\ttimestamp\030\003 \002(\003" +
|
||||
"\022\r\n\005nonce\030\004 \002(\t\022\021\n\tsignature\030\005 \002(\tB/\n\025cn" +
|
||||
".wildfirechat.protoB\nWFCMessageZ\n./go;pr" +
|
||||
"oto"
|
||||
"\022\r\n\005nonce\030\004 \002(\t\022\021\n\tsignature\030\005 \002(\t\"(\n\nSt" +
|
||||
"ringPair\022\013\n\003key\030\001 \002(\t\022\r\n\005value\030\002 \001(\tB/\n\025" +
|
||||
"cn.wildfirechat.protoB\nWFCMessageZ\n./go;",
|
||||
"proto"
|
||||
};
|
||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
||||
@@ -68342,6 +68983,12 @@ public final class WFCMessage {
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_ApplicationConfigRequest_descriptor,
|
||||
new java.lang.String[] { "AppId", "AppType", "Timestamp", "Nonce", "Signature", });
|
||||
internal_static_StringPair_descriptor =
|
||||
getDescriptor().getMessageTypes().get(76);
|
||||
internal_static_StringPair_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_StringPair_descriptor,
|
||||
new java.lang.String[] { "Key", "Value", });
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.xiaoleilu.loServer.pojos;
|
||||
|
||||
|
||||
public class InputRoute {
|
||||
private String userId;
|
||||
private String token;
|
||||
private String clientId;
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
<!--<relativePath>../pom.xml</relativePath>-->
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>1.3.7</version>
|
||||
<version>1.4.5</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>distribution</artifactId>
|
||||
|
||||
@@ -167,6 +167,16 @@ robot.callback_with_sender_info false
|
||||
## 机器人回调信息是否带上目标的信息,单聊时是对方用户信息,群聊时是群组信息,频道时是频道信息
|
||||
robot.callback_with_target_info false
|
||||
|
||||
## 是否允许@会话外的机器人。如果为true,单聊或者群聊时,可以@不在会话中的机器人。当机器人收到消息后,可以回复消息。
|
||||
## 如果为false,不能@不在会话中的机器人。机器人不在会话中时,也不能回复消息。
|
||||
robot.mention_external_robot true
|
||||
|
||||
## 机器人获取信息允许的字段,可以获取userId/displayName/portrait,其他需要这里配置允许。
|
||||
## 第一位(1)是name, 第二位(2)是mobile,第三(4)位是email,第四位(8)是address,第五位(16)是company,第六位(32)是extra,
|
||||
## 第七位(64)是updateDt,第八位(128)是gender,第九位(256)是social,第十位(512)是type。
|
||||
## 比如允许获取name和email就是5(1+4),允许获取name和mobile和company和type就是531(1+2+16+512),允许全部是1023(1+2+...+512)
|
||||
#robot.get_user_info_mask 1023
|
||||
|
||||
## 频道回调信息是否带上用户clientId和平台类型。
|
||||
channel.callback_with_client_info false
|
||||
|
||||
@@ -186,8 +196,8 @@ friend.disable_search false
|
||||
##禁止按照昵称搜索用户。
|
||||
friend.disable_nick_name_search false
|
||||
|
||||
##禁止按照用户id搜索用户,默认为true。
|
||||
friend.disable_user_id_search true
|
||||
##禁止按照用户id搜索用户,默认为false。
|
||||
friend.disable_user_id_search false
|
||||
|
||||
##禁止发送好友邀请,通过server api添加好友不受此限制(force参数需要为true)
|
||||
friend.disable_friend_request false
|
||||
@@ -202,7 +212,13 @@ friend.reject_request_duration 2592000000
|
||||
friend.request_expiration_duration 604800000
|
||||
|
||||
##好友请求限制频率,一个用户24小时之内允许请求好友的次数,默认不限频。
|
||||
#friend.request_rate_limit 30
|
||||
friend.request_rate_limit 30
|
||||
|
||||
##如果搜索电话号码,24小时内搜索错误号码几次就不再允许电话号码搜素。防止有人遍历搜索电话号码
|
||||
friend.search_mobile_empty_rate_limit 5
|
||||
|
||||
##如果搜索用户,24小时内搜索次数。防止有人遍历用户名或者用户ID乱加好友。另外可以禁止ID搜索friend.disable_user_id_search
|
||||
friend.search_rate_limit 100
|
||||
|
||||
##请求添加机器人为好友时,机器人是否自动接受,默认为true
|
||||
friend.robot_auto_accept true
|
||||
@@ -258,6 +274,19 @@ group.enable_mark_deletion true
|
||||
## 注意,修改本配置不会对已经同步的信息产生影响。
|
||||
#user.hide_properties 3,4
|
||||
|
||||
## 销毁用户时,用户信息会被清空,deleted字段设置为1,这个开关控制是否保留用户昵称,默认为true。
|
||||
user.keep_display_name_when_destroy true
|
||||
|
||||
## 销毁用户时deleted字段设置为1,这个开关控制是否保留其他信息,默认是false。
|
||||
user.keep_full_info_when_destroy false
|
||||
|
||||
## 销毁用户时,如果user.keep_full_info_when_destroy为true,会保留所有信息,这个开关控制是否保留这个用户信息的电话号码,默认为false。
|
||||
## 当保留所有信息且保留电话号码时,用户如果再注册会用到原来的UID,能够看到原来用户的消息,需要考虑一下是否让已删除用户再次注册登录看到之前的消息。
|
||||
user.keep_mobile_when_destroy false
|
||||
|
||||
## 销毁用户时是否保留归属于这个用户的所有消息记录,默认为false。
|
||||
user.keep_messages_when_destroy false
|
||||
|
||||
# 好友/好友请求/用户设置 这三类数据同步的最大条目数。之前是客户第一次登录时,会把所有的对应数据一次下载到客户端,但如果有特别多的信息,会导致无法同步到客户端,
|
||||
# 因此需要分段多次同步,此开关定义了每次同步的数据的条数。此需要客户端支持,客户端SDK在2021.5.25日后支持此功能。如果确认所有客户端都在这个日志之后才可以打开此设置。
|
||||
#sync.data_part_size 1000
|
||||
@@ -311,6 +340,13 @@ qiniu.bucket_portrait_name storage
|
||||
qiniu.bucket_portrait_domain http://cdn2.wildfirechat.cn
|
||||
qiniu.bucket_favorite_name storage
|
||||
qiniu.bucket_favorite_domain http://cdn2.wildfirechat.cn
|
||||
## custom的桶是给客户预留的,客户可以上传自己的文件到这3个桶中,野火不会用到这几个桶。如果不需要,可以忽略这几个配置
|
||||
qiniu.bucket_custom1_name temp1
|
||||
qiniu.bucket_custom1_domain http://temp1.wildfirechat.cn
|
||||
qiniu.bucket_custom2_name temp2
|
||||
qiniu.bucket_custom2_domain http://temp2.wildfirechat.cn
|
||||
qiniu.bucket_custom3_name temp3
|
||||
qiniu.bucket_custom3_domain http://temp3.wildfirechat.cn
|
||||
|
||||
##媒体类型分类
|
||||
#Media_Type_GENERAL = 0,
|
||||
@@ -455,6 +491,10 @@ push.harmony.server.address http://localhost:8085/harmony/push
|
||||
## 如果开启 message.sensitive.forward.url 配置,命中敏感词的消息还会被回调到这个地址
|
||||
sensitive.filter.type 2
|
||||
|
||||
## 敏感词是否只处理消息。如果为true,只过滤消息;如果为false,会同时过滤用户昵称、群组名和群昵称。
|
||||
## 除了消息之外的信息只支持内部敏感词处理,不支持外置审核。
|
||||
sensitive.only_message false
|
||||
|
||||
## 敏感词添加或者删除有2种方式,一种是通过Server API进行,这种方式会立即生效。另外一种方法是修改数据库,直接中数据库的t_sensitive_word表中处理
|
||||
## 修改数据库的方法不会立即生效,IM服务会2个小时重新加载一次敏感词。所以如果直接修改敏感词表,需要等2个小时,或者重启才能生效。
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<version>1.3.7</version>
|
||||
<version>1.4.5</version>
|
||||
<name>Wildfire Chat</name>
|
||||
<description>Wildfire Chat Server</description>
|
||||
<inceptionYear>2019</inceptionYear>
|
||||
|
||||
@@ -9,8 +9,66 @@
|
||||
8. *** 从0.78 版本起把MySQL数据库中关键字都改为大小写敏感,另外生成id的方法也做了改变,只生成小写的id,避免出现id重复的问题,建议所有客户都升级 ***
|
||||
9. *** 从0.79 版本起把log4j升级到log4j2,因为log4j已经不再维护而且还有已知的漏洞,建议所有客户都升级,升级时注意更新log4j2的配置文件 ***
|
||||
10. *** 0.97版本更改了启动脚本```wildfirechat.sh```,如果是升级服务,请注意更新启动脚本。***
|
||||
11. *** 1.3.8版本添加了server api发送消息的限制,限制消息体最大内容不能超过64KB,如果升级请注意业务系统发送消息大小。***
|
||||
|
||||
# 更新记录
|
||||
--------------
|
||||
Release note 1.4.5:
|
||||
1. 解决删除用户时保留信息错误问题。
|
||||
2. Server API获取用户信息时,可以指定是否获取已删除用户。
|
||||
3. 好友关系表添加一个索引。
|
||||
4. 支持PC端锁定功能。
|
||||
|
||||
--------------
|
||||
Release note 1.4.4:
|
||||
1. Server SDK添加mesh相关修改
|
||||
2. 添加设置好友Extra的接口。
|
||||
3. 解决创建账户时,没有传昵称使用了账户的问题。
|
||||
4. 添加获取用户机器人列表的Server API。
|
||||
5. 机器人回调消息中加上目标机器人ID。
|
||||
6. 机器人获取用户信息添加配置确定能获取哪些字段。
|
||||
|
||||
--------------
|
||||
Release note 1.4.3:
|
||||
1. 添加内置存储上传文件文件名有效性检查。
|
||||
2. 接受好友请求通知的发送者改成接受者发送。
|
||||
3. 对象存储添加预留类型供扩展使用。
|
||||
4. 同步专业版数据库表格式。
|
||||
5. 解决server sdk有轻微内存泄漏的问题。
|
||||
|
||||
--------------
|
||||
Release note 1.4.2:
|
||||
1. 解决部分情况下Server SDK没有解析出文本消息的问题。
|
||||
|
||||
--------------
|
||||
Release note 1.4.1:
|
||||
1. 解决移动端和PAD同时存在时推送计数错误问题。
|
||||
2. 添加配置,当销毁用户时是否销毁用户信息和用户的消息。
|
||||
3. 添加配置,现在搜索用户的次数。
|
||||
|
||||
--------------
|
||||
Release note 1.4.0:
|
||||
1. 添加对用户IP来源的记录。
|
||||
2. 移除无用的plugin,可以在java8环境下编译通过。
|
||||
3. Server SDK解决某些Java版本下消息没有注册的问题。
|
||||
4. Server SDK解决解析图片缩略图不存在的错误问题。
|
||||
5. Server SDK解决发送带引用的消息客户端无法解析的问题。
|
||||
|
||||
--------------
|
||||
Release note 1.3.9:
|
||||
1. 解决server sdk反复初始化内存泄漏的问题。
|
||||
2. 群组支持用户@不在群组中的机器人。
|
||||
3. 单聊会话支持@机器人。
|
||||
4. 机器人支持回复消息,可以回复单聊或者群聊消息。
|
||||
|
||||
--------------
|
||||
Release note 1.3.8:
|
||||
1. 添加限制,server api发送消息,限制消息体不能大于64KB。
|
||||
2. 添加配置敏感词是否过滤用户信息群组信息昵称等。
|
||||
3. 配置文件可以设置不允许使用的用户名字群组名称群名片等。
|
||||
4. server api发送消息添加参数,可以以用户权限发送消息。
|
||||
5. server api添加群备注和收藏群组接口。
|
||||
|
||||
--------------
|
||||
Release note 1.3.7:
|
||||
1. 搜索用户可以指定搜索机器人、普通用户或者所有。
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>1.3.7</version>
|
||||
<version>1.4.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -2,7 +2,22 @@ package cn.wildfirechat.sdk;
|
||||
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
|
||||
/**
|
||||
* 管理员配置类
|
||||
* <p>
|
||||
* 用于初始化管理员SDK的配置,包括IM服务器URL和密钥。
|
||||
* 在使用任何Admin功能之前,必须先调用initAdmin方法进行初始化。
|
||||
* </p>
|
||||
*/
|
||||
public class AdminConfig {
|
||||
/**
|
||||
* 初始化管理员配置
|
||||
* <p>
|
||||
* 在使用任何Admin功能之前,必须先调用此方法进行初始化。
|
||||
* </p>
|
||||
* @param url IM服务器地址,例如: http://your-im-server.com
|
||||
* @param secret 管理员密钥,在服务器配置中设置
|
||||
*/
|
||||
public static void initAdmin(String url, String secret) {
|
||||
AdminHttpUtils.init(url, secret);
|
||||
}
|
||||
|
||||
@@ -5,36 +5,87 @@ import cn.wildfirechat.pojos.*;
|
||||
import cn.wildfirechat.sdk.model.IMResult;
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
|
||||
/**
|
||||
* 频道管理类
|
||||
* <p>
|
||||
* 提供频道管理相关的功能,包括:
|
||||
* <ul>
|
||||
* <li>创建和销毁频道</li>
|
||||
* <li>获取频道信息</li>
|
||||
* <li>用户订阅/取消订阅频道</li>
|
||||
* <li>检查用户是否订阅频道</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class ChannelAdmin {
|
||||
/**
|
||||
* 创建频道
|
||||
* @param inputCreateChannel 频道创建信息
|
||||
* @return 创建结果,包含频道ID
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputCreateChannel> createChannel(InputCreateChannel inputCreateChannel) throws Exception {
|
||||
String path = APIPath.Create_Channel;
|
||||
return AdminHttpUtils.httpJsonPost(path, inputCreateChannel, OutputCreateChannel.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁频道
|
||||
* @param channelId 频道ID
|
||||
* @return 销毁结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> destroyChannel(String channelId) throws Exception {
|
||||
String path = APIPath.Destroy_Channel;
|
||||
InputChannelId inputChannelId = new InputChannelId(channelId);
|
||||
return AdminHttpUtils.httpJsonPost(path, inputChannelId, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取频道信息
|
||||
* @param channelId 频道ID
|
||||
* @return 频道信息
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputGetChannelInfo> getChannelInfo(String channelId) throws Exception {
|
||||
String path = APIPath.Get_Channel_Info;
|
||||
InputChannelId inputChannelId = new InputChannelId(channelId);
|
||||
return AdminHttpUtils.httpJsonPost(path, inputChannelId, OutputGetChannelInfo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅频道
|
||||
* @param channelId 频道ID
|
||||
* @param userId 用户ID
|
||||
* @return 订阅结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> subscribeChannel(String channelId, String userId) throws Exception {
|
||||
String path = APIPath.Subscribe_Channel;
|
||||
InputSubscribeChannel input = new InputSubscribeChannel(channelId, userId, 1);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订阅频道
|
||||
* @param channelId 频道ID
|
||||
* @param userId 用户ID
|
||||
* @return 取消订阅结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> unsubscribeChannel(String channelId, String userId) throws Exception {
|
||||
String path = APIPath.Subscribe_Channel;
|
||||
InputSubscribeChannel input = new InputSubscribeChannel(channelId, userId, 0);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户是否订阅了频道
|
||||
* @param userId 用户ID
|
||||
* @param channelId 频道ID
|
||||
* @return true-已订阅,false-未订阅
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputBooleanValue> isUserSubscribedChannel(String userId, String channelId) throws Exception {
|
||||
String path = APIPath.Check_User_Subscribe_Channel;
|
||||
InputSubscribeChannel input = new InputSubscribeChannel(channelId, userId, 0);
|
||||
|
||||
@@ -4,18 +4,39 @@ import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.pojos.*;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.sdk.model.IMResult;
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
import cn.wildfirechat.sdk.utilities.ChannelHttpUtils;
|
||||
import com.google.gson.Gson;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ApplicationType.ApplicationType_Channel;
|
||||
|
||||
//仅专业版支持,社区版不支持
|
||||
public class ChannelServiceApi {
|
||||
/**
|
||||
* 频道服务类(仅专业版支持,社区版不支持)
|
||||
* <p>
|
||||
* 提供频道相关的功能,包括:
|
||||
* <ul>
|
||||
* <li>获取用户信息</li>
|
||||
* <li>修改频道信息</li>
|
||||
* <li>发送和撤回消息</li>
|
||||
* <li>用户订阅管理</li>
|
||||
* <li>订阅者列表查询</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class ChannelServiceApi implements Closeable {
|
||||
private final ChannelHttpUtils channelHttpUtils;
|
||||
|
||||
/**
|
||||
* 创建频道服务实例
|
||||
* @param imurl IM服务器地址
|
||||
* @param channelId 频道ID
|
||||
* @param secret 频道密钥
|
||||
*/
|
||||
public ChannelServiceApi(String imurl, String channelId, String secret) {
|
||||
channelHttpUtils = new ChannelHttpUtils(imurl, channelId, secret);
|
||||
}
|
||||
@@ -65,6 +86,21 @@ public class ChannelServiceApi {
|
||||
return channelHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
|
||||
}
|
||||
|
||||
public IMResult<String> recallMessage(long messageUid) throws Exception {
|
||||
String path = APIPath.Channel_Msg_Recall;
|
||||
RecallMessageData messageData = new RecallMessageData();
|
||||
messageData.setMessageUid(messageUid);
|
||||
return channelHttpUtils.httpJsonPost(path, messageData, String.class);
|
||||
}
|
||||
|
||||
public IMResult<Void> republishMessage(long messageUid, List<String> targets) throws Exception {
|
||||
String path = APIPath.Channel_Msg_Republish;
|
||||
RepublishChannelMessageData messageData = new RepublishChannelMessageData();
|
||||
messageData.setMessageId(messageUid);
|
||||
messageData.setTargets(targets);
|
||||
return channelHttpUtils.httpJsonPost(path, messageData, Void.class);
|
||||
}
|
||||
|
||||
public IMResult<Void> subscribe(String userId) throws Exception {
|
||||
String path = APIPath.Channel_Subscribe;
|
||||
InputChannelSubscribe input = new InputChannelSubscribe();
|
||||
@@ -113,4 +149,8 @@ public class ChannelServiceApi {
|
||||
return configData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
channelHttpUtils.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,32 @@ import cn.wildfirechat.pojos.*;
|
||||
import cn.wildfirechat.sdk.model.IMResult;
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
|
||||
/**
|
||||
* 聊天室管理类
|
||||
* <p>
|
||||
* 提供聊天室管理相关的功能,包括:
|
||||
* <ul>
|
||||
* <li>创建和销毁聊天室</li>
|
||||
* <li>获取聊天室信息</li>
|
||||
* <li>聊天室成员管理</li>
|
||||
* <li>聊天室黑名单管理(仅专业版)</li>
|
||||
* <li>聊天室管理员设置</li>
|
||||
* <li>聊天室全员禁言</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class ChatroomAdmin {
|
||||
/**
|
||||
* 创建聊天室
|
||||
* @param chatroomId 聊天室ID(为空时自动生成)
|
||||
* @param title 聊天室标题
|
||||
* @param desc 聊天室描述
|
||||
* @param portrait 聊天室头像
|
||||
* @param extra 额外信息
|
||||
* @param state 聊天室状态
|
||||
* @return 创建结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputCreateChatroom> createChatroom(String chatroomId, String title, String desc ,String portrait, String extra, Integer state) throws Exception {
|
||||
String path = APIPath.Create_Chatroom;
|
||||
InputCreateChatroom input = new InputCreateChatroom();
|
||||
@@ -18,6 +43,12 @@ public class ChatroomAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputCreateChatroom.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁聊天室
|
||||
* @param chatroomId 聊天室ID
|
||||
* @return 销毁结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> destroyChatroom(String chatroomId) throws Exception {
|
||||
String path = APIPath.Chatroom_Destroy;
|
||||
InputDestoryChatroom input = new InputDestoryChatroom();
|
||||
@@ -25,51 +56,103 @@ public class ChatroomAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天室信息
|
||||
* @param chatroomId 聊天室ID
|
||||
* @return 聊天室信息
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputGetChatroomInfo> getChatroomInfo(String chatroomId) throws Exception {
|
||||
String path = APIPath.Chatroom_Info;
|
||||
InputGetChatroomInfo input = new InputGetChatroomInfo(chatroomId);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputGetChatroomInfo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天室成员列表
|
||||
* @param chatroomId 聊天室ID
|
||||
* @return 成员ID列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputStringList> getChatroomMembers(String chatroomId) throws Exception {
|
||||
String path = APIPath.Chatroom_GetMembers;
|
||||
InputGetChatroomInfo input = new InputGetChatroomInfo(chatroomId);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputStringList.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户所在的聊天室
|
||||
* @param userId 用户ID
|
||||
* @return 用户所在的聊天室信息
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputUserChatroom> getUserChatroom(String userId) throws Exception {
|
||||
String path = APIPath.Chatroom_GetUserChatroom;
|
||||
InputUserId input = new InputUserId(userId);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputUserChatroom.class);
|
||||
}
|
||||
|
||||
//仅专业版支持
|
||||
//status:0,正常;1,禁言;2,禁止加入
|
||||
/**
|
||||
* 设置聊天室黑名单状态(仅专业版支持)
|
||||
* <p>status:0-正常;1-禁言;2-禁止加入</p>
|
||||
* @param chatroomId 聊天室ID
|
||||
* @param userId 用户ID
|
||||
* @param status 状态值
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> setChatroomBlacklist(String chatroomId, String userId, int status) throws Exception {
|
||||
String path = APIPath.Chatroom_SetBlacklist;
|
||||
InputSetChatroomBlacklist input = new InputSetChatroomBlacklist(chatroomId, userId, status, 0);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天室黑名单
|
||||
* @param chatroomId 聊天室ID
|
||||
* @return 黑名单信息
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputChatroomBlackInfos> getChatroomBlacklist(String chatroomId) throws Exception {
|
||||
String path = APIPath.Chatroom_GetBlacklist;
|
||||
InputChatroomId input = new InputChatroomId(chatroomId);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputChatroomBlackInfos.class);
|
||||
}
|
||||
|
||||
//status: 1 set; 0 unset
|
||||
/**
|
||||
* 设置聊天室管理员
|
||||
* <p>status:1-设置为管理员;0-取消管理员</p>
|
||||
* @param chatroomId 聊天室ID
|
||||
* @param userId 用户ID
|
||||
* @param status 状态值
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> setChatroomManager(String chatroomId, String userId, int status) throws Exception {
|
||||
String path = APIPath.Chatroom_SetManager;
|
||||
InputSetChatroomManager input = new InputSetChatroomManager(chatroomId, userId, status);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天室管理员列表
|
||||
* @param chatroomId 聊天室ID
|
||||
* @return 管理员ID列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputStringList> getChatroomManagerList(String chatroomId) throws Exception {
|
||||
String path = APIPath.Chatroom_GetManagerList;
|
||||
InputChatroomId input = new InputChatroomId(chatroomId);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputStringList.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置聊天室全员禁言
|
||||
* @param chatroomId 聊天室ID
|
||||
* @param mute true-全员禁言,false-取消全员禁言
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> setChatroomMute(String chatroomId, boolean mute) throws Exception {
|
||||
String path = APIPath.Chatroom_MuteAll;
|
||||
InputChatroomMute input = new InputChatroomMute(chatroomId, mute ? 1 : 0);
|
||||
|
||||
@@ -5,24 +5,73 @@ import cn.wildfirechat.pojos.*;
|
||||
import cn.wildfirechat.sdk.model.IMResult;
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
|
||||
/**
|
||||
* 会议管理类
|
||||
* <p>
|
||||
* 提供音视频会议管理相关的功能,包括:
|
||||
* <ul>
|
||||
* <li>会议列表查询</li>
|
||||
* <li>会议创建和销毁</li>
|
||||
* <li>会议参与者管理</li>
|
||||
* <li>会议录制控制</li>
|
||||
* <li>RTP转发管理</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class ConferenceAdmin {
|
||||
public static IMResult<PojoConferenceInfoList> listConferences() throws Exception {
|
||||
/**
|
||||
* 获取会议列表(分页)
|
||||
* @param count 每页数量
|
||||
* @param offset 偏移量
|
||||
* @return 会议信息列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<PojoConferenceInfoList> listConferences(int count, int offset) throws Exception {
|
||||
String path = APIPath.Conference_List;
|
||||
return AdminHttpUtils.httpJsonPost(path, null, PojoConferenceInfoList.class);
|
||||
InputCountOffset inputCountOffset = new InputCountOffset();
|
||||
inputCountOffset.count = count;
|
||||
inputCountOffset.offset = offset;
|
||||
return AdminHttpUtils.httpJsonPost(path, inputCountOffset, PojoConferenceInfoList.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查会议是否存在
|
||||
* @param conferenceId 会议ID
|
||||
* @return true-存在,false-不存在
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Boolean> existsConferences(String conferenceId) throws Exception {
|
||||
String path = APIPath.Conference_Exist;
|
||||
PojoConferenceRoomId data = new PojoConferenceRoomId(conferenceId, false);
|
||||
return AdminHttpUtils.httpJsonPost(path, data, Boolean.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会议参与者列表
|
||||
* @param roomId 房间ID
|
||||
* @param advance 是否使用高级模式
|
||||
* @return 参与者列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<PojoConferenceParticipantList> listParticipants(String roomId, boolean advance) throws Exception {
|
||||
String path = APIPath.Conference_List_Participant;
|
||||
PojoConferenceRoomId data = new PojoConferenceRoomId(roomId, advance);
|
||||
return AdminHttpUtils.httpJsonPost(path, data, PojoConferenceParticipantList.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建会议房间
|
||||
* @param roomId 房间ID
|
||||
* @param description 描述
|
||||
* @param pin 房间密码
|
||||
* @param maxPublisher 最大推流数
|
||||
* @param advance 是否使用高级模式
|
||||
* @param bitrate 比特率
|
||||
* @param recording 是否录制
|
||||
* @param permanent 是否永久房间
|
||||
* @return 创建结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> createRoom(String roomId, String description, String pin, int maxPublisher, boolean advance, int bitrate, boolean recording, boolean permanent) throws Exception {
|
||||
String path = APIPath.Conference_Create;
|
||||
PojoConferenceCreate create = new PojoConferenceCreate();
|
||||
@@ -37,6 +86,14 @@ public class ConferenceAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, create, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用或禁用会议录制
|
||||
* @param roomId 房间ID
|
||||
* @param advance 是否使用高级模式
|
||||
* @param recording true-启用录制,false-禁用录制
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> enableRecording(String roomId, boolean advance, boolean recording) throws Exception {
|
||||
String path = APIPath.Conference_Recording;
|
||||
PojoConferenceRecording create = new PojoConferenceRecording();
|
||||
@@ -46,24 +103,59 @@ public class ConferenceAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, create, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁会议房间
|
||||
* @param roomId 房间ID
|
||||
* @param advance 是否使用高级模式
|
||||
* @return 销毁结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> destroy(String roomId, boolean advance) throws Exception {
|
||||
String path = APIPath.Conference_Destroy;
|
||||
PojoConferenceRoomId conferenceRoomId = new PojoConferenceRoomId(roomId, advance);
|
||||
return AdminHttpUtils.httpJsonPost(path, conferenceRoomId, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* RTP转发
|
||||
* @param roomId 房间ID
|
||||
* @param userId 用户ID
|
||||
* @param rtpHost RTP主机地址
|
||||
* @param audioPort 音频端口
|
||||
* @param audioPt 音频Payload类型
|
||||
* @param audioSSRC 音频SSRC
|
||||
* @param videoPort 视频端口
|
||||
* @param videoPt 视频Payload类型
|
||||
* @param videoSSRC 视频SSRC
|
||||
* @return 转发结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> rtpForward(String roomId, String userId, String rtpHost, int audioPort, int audioPt, long audioSSRC, int videoPort, int videoPt, long videoSSRC) throws Exception {
|
||||
String path = APIPath.Conference_Rtp_Forward;
|
||||
PojoConferenceRtpForwardReq req = new PojoConferenceRtpForwardReq(roomId, userId, rtpHost, audioPort, audioPt, audioSSRC, videoPort, videoPt, videoSSRC);
|
||||
return AdminHttpUtils.httpJsonPost(path, req, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止RTP转发
|
||||
* @param roomId 房间ID
|
||||
* @param userId 用户ID
|
||||
* @param streamId 流ID
|
||||
* @return 停止结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> stopRtpForward(String roomId, String userId, long streamId) throws Exception {
|
||||
String path = APIPath.Conference_Stop_Rtp_Forward;
|
||||
PojoConferenceStopRtpForwardReq req = new PojoConferenceStopRtpForwardReq(roomId, userId, streamId);
|
||||
return AdminHttpUtils.httpJsonPost(path, req, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取RTP转发列表
|
||||
* @param roomId 房间ID
|
||||
* @return RTP转发列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<PojoConferenceRtpForwarders> listRtpForwarders(String roomId) throws Exception {
|
||||
String path = APIPath.Conference_List_Rtp_Forward;
|
||||
PojoConferenceRoomId req = new PojoConferenceRoomId();
|
||||
|
||||
@@ -5,7 +5,26 @@ import cn.wildfirechat.pojos.*;
|
||||
import cn.wildfirechat.sdk.model.IMResult;
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
|
||||
/**
|
||||
* 通用管理类
|
||||
* <p>
|
||||
* 提供通用的系统管理功能,包括:
|
||||
* <ul>
|
||||
* <li>系统设置管理</li>
|
||||
* <li>文件管理(会话文件、用户文件)</li>
|
||||
* <li>用户设置管理(会话置顶等)</li>
|
||||
* <li>健康检查</li>
|
||||
* <li>频道管理(已废弃,请使用ChannelAdmin)</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class GeneralAdmin {
|
||||
/**
|
||||
* 获取系统设置
|
||||
* @param id 设置项ID
|
||||
* @return 系统设置信息
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<SystemSettingPojo> getSystemSetting(int id) throws Exception {
|
||||
String path = APIPath.Get_System_Setting;
|
||||
SystemSettingPojo input = new SystemSettingPojo();
|
||||
@@ -13,6 +32,14 @@ public class GeneralAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, input, SystemSettingPojo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置系统设置
|
||||
* @param id 设置项ID
|
||||
* @param value 设置值
|
||||
* @param desc 设置描述
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> setSystemSetting(int id, String value, String desc) throws Exception {
|
||||
String path = APIPath.Put_System_Setting;
|
||||
SystemSettingPojo input = new SystemSettingPojo();
|
||||
@@ -81,13 +108,91 @@ public class GeneralAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputBooleanValue.class);
|
||||
}
|
||||
|
||||
//以下仅专业版支持
|
||||
/**
|
||||
* 获取会话文件列表(仅专业版支持)
|
||||
* <p>
|
||||
* 如果是单聊会话,target和userId代表会话的2个用户;如果是其他会话userId无意义。
|
||||
* </p>
|
||||
* @param conversationType 会话类型
|
||||
* @param target 会话目标ID
|
||||
* @param line 线路
|
||||
* @param userId 用户ID
|
||||
* @param offset 偏移量
|
||||
* @param desc 是否降序
|
||||
* @param count 每页数量
|
||||
* @return 文件列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<FilesPojo> getConversationFiles(int conversationType, String target, int line, String userId, int offset, boolean desc, int count) throws Exception {
|
||||
String path = APIPath.Get_Conversation_Files;
|
||||
GetConversationFilesPojo input = new GetConversationFilesPojo();
|
||||
input.conversationType = conversationType;
|
||||
input.target = target;
|
||||
input.line = line;
|
||||
input.userId = userId;
|
||||
input.offset = offset;
|
||||
input.desc = desc;
|
||||
input.count = count;
|
||||
return AdminHttpUtils.httpJsonPost(path, input, FilesPojo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户文件列表
|
||||
* @param userId 用户ID
|
||||
* @param offset 偏移量
|
||||
* @param desc 是否降序
|
||||
* @param count 每页数量
|
||||
* @return 文件列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<FilesPojo> getUserFiles(String userId, int offset, boolean desc, int count) throws Exception {
|
||||
String path = APIPath.Get_User_Files;
|
||||
GetUserFilesPojo input = new GetUserFilesPojo();
|
||||
input.userId = userId;
|
||||
input.offset = offset;
|
||||
input.desc = desc;
|
||||
input.count = count;
|
||||
return AdminHttpUtils.httpJsonPost(path, input, FilesPojo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据消息ID获取文件信息
|
||||
* @param messageId 消息ID
|
||||
* @return 文件信息
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<FilesPojo.FilePojo> getFile(long messageId) throws Exception {
|
||||
String path = APIPath.Get_Message_File;
|
||||
LongPojo input = new LongPojo();
|
||||
input.value = messageId;
|
||||
return AdminHttpUtils.httpJsonPost(path, input, FilesPojo.FilePojo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置会话置顶
|
||||
* @param userId 用户ID
|
||||
* @param conversationType 会话类型
|
||||
* @param target 会话目标ID
|
||||
* @param line 线路
|
||||
* @param isTop true-置顶,false-取消置顶
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> setConversationTop(String userId, int conversationType, String target, int line, boolean isTop) throws Exception {
|
||||
String key = conversationType + "-" + line + "-" + target;
|
||||
String value = isTop?"1":"0";
|
||||
return setUserSetting(userId, 3, key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会话置顶状态
|
||||
* @param userId 用户ID
|
||||
* @param conversationType 会话类型
|
||||
* @param target 会话目标ID
|
||||
* @param line 线路
|
||||
* @return true-已置顶,false-未置顶
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Boolean> getConversationTop(String userId, int conversationType, String target, int line) throws Exception {
|
||||
String key = conversationType + "-" + line + "-" + target;
|
||||
IMResult<UserSettingPojo> result = getUserSetting(userId, 3, key);
|
||||
@@ -98,7 +203,14 @@ public class GeneralAdmin {
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户设置
|
||||
* @param userId 用户ID
|
||||
* @param scope 设置范围
|
||||
* @param key 设置键
|
||||
* @return 用户设置信息
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<UserSettingPojo> getUserSetting(String userId, int scope, String key) throws Exception {
|
||||
String path = APIPath.User_Get_Setting;
|
||||
UserSettingPojo pojo = new UserSettingPojo();
|
||||
@@ -108,6 +220,15 @@ public class GeneralAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, pojo, UserSettingPojo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户设置
|
||||
* @param userId 用户ID
|
||||
* @param scope 设置范围
|
||||
* @param key 设置键
|
||||
* @param value 设置值
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> setUserSetting(String userId, int scope, String key, String value) throws Exception {
|
||||
String path = APIPath.User_Put_Setting;
|
||||
UserSettingPojo pojo = new UserSettingPojo();
|
||||
@@ -118,10 +239,20 @@ public class GeneralAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, pojo, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 健康检查
|
||||
* @return 健康检查结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<HealthCheckResult> healthCheck() throws Exception {
|
||||
return AdminHttpUtils.httpGet(APIPath.Health, HealthCheckResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户信息
|
||||
* @return 客户信息
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<String> getCustomer() throws Exception {
|
||||
return AdminHttpUtils.httpJsonPost(APIPath.GET_CUSTOMER, null, String.class);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,39 @@
|
||||
package cn.wildfirechat.sdk;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.*;
|
||||
import cn.wildfirechat.sdk.model.IMResult;
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 群组管理类
|
||||
* <p>
|
||||
* 提供群组管理相关的功能,包括:
|
||||
* <ul>
|
||||
* <li>群组的创建、解散、转移</li>
|
||||
* <li>群组信息修改</li>
|
||||
* <li>群组成员管理(添加、移除、踢出)</li>
|
||||
* <li>群组管理员设置</li>
|
||||
* <li>群组成员禁言</li>
|
||||
* <li>用户群组查询</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class GroupAdmin {
|
||||
/**
|
||||
* 创建群组
|
||||
* @param operator 操作者用户ID
|
||||
* @param group_info 群组信息
|
||||
* @param members 群组成员列表
|
||||
* @param member_extra 成员额外信息
|
||||
* @param to_lines 消息同步到的线路列表
|
||||
* @param notify_message 通知消息
|
||||
* @return 创建结果,包含群组ID
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputCreateGroupResult> createGroup(String operator, PojoGroupInfo group_info, List<PojoGroupMember> members, String member_extra, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Create_Group;
|
||||
PojoGroup pojoGroup = new PojoGroup();
|
||||
@@ -23,6 +49,12 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, createGroup, OutputCreateGroupResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取群组信息
|
||||
* @param groupId 群组ID
|
||||
* @return 群组信息
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<PojoGroupInfo> getGroupInfo(String groupId) throws Exception {
|
||||
String path = APIPath.Group_Get_Info;
|
||||
InputGetGroup input = new InputGetGroup();
|
||||
@@ -31,11 +63,26 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, input, PojoGroupInfo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取群组信息
|
||||
* @param groupIds 群组ID列表
|
||||
* @return 群组信息列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<PojoGroupInfoList> batchGroupInfos(List<String> groupIds) throws Exception {
|
||||
String path = APIPath.Group_Batch_Info;
|
||||
return AdminHttpUtils.httpJsonPost(path, groupIds, PojoGroupInfoList.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解散群组
|
||||
* @param operator 操作者用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param to_lines 消息同步到的线路列表
|
||||
* @param notify_message 通知消息
|
||||
* @return 解散结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> dismissGroup(String operator, String groupId, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Group_Dismiss;
|
||||
InputDismissGroup dismissGroup = new InputDismissGroup();
|
||||
@@ -46,6 +93,16 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, dismissGroup, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转让群组
|
||||
* @param operator 操作者用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param newOwner 新群主用户ID
|
||||
* @param to_lines 消息同步到的线路列表
|
||||
* @param notify_message 通知消息
|
||||
* @return 转让结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> transferGroup(String operator, String groupId, String newOwner, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Group_Transfer;
|
||||
InputTransferGroup transferGroup = new InputTransferGroup();
|
||||
@@ -57,6 +114,17 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, transferGroup, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改群组信息
|
||||
* @param operator 操作者用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param type 修改信息类型(ModifyGroupInfoType)
|
||||
* @param value 新值
|
||||
* @param to_lines 消息同步到的线路列表
|
||||
* @param notify_message 通知消息
|
||||
* @return 修改结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> modifyGroupInfo(String operator, String groupId, /*ModifyGroupInfoType*/int type, String value, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Group_Modify_Info;
|
||||
InputModifyGroupInfo modifyGroupInfo = new InputModifyGroupInfo();
|
||||
@@ -69,7 +137,12 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, modifyGroupInfo, Void.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取群组成员列表
|
||||
* @param groupId 群组ID
|
||||
* @return 群组成员列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputGroupMemberList> getGroupMembers(String groupId) throws Exception {
|
||||
String path = APIPath.Group_Member_List;
|
||||
InputGetGroup input = new InputGetGroup();
|
||||
@@ -77,6 +150,13 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputGroupMemberList.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取群组成员信息
|
||||
* @param groupId 群组ID
|
||||
* @param memberId 成员用户ID
|
||||
* @return 群组成员信息
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<PojoGroupMember> getGroupMember(String groupId, String memberId) throws Exception {
|
||||
String path = APIPath.Group_Member_Get;
|
||||
InputGetGroupMember input = new InputGetGroupMember();
|
||||
@@ -85,6 +165,17 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, input, PojoGroupMember.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加群组成员
|
||||
* @param operator 操作者用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param groupMembers 要添加的成员列表
|
||||
* @param member_extra 成员额外信息
|
||||
* @param to_lines 消息同步到的线路列表
|
||||
* @param notify_message 通知消息
|
||||
* @return 添加结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> addGroupMembers(String operator, String groupId, List<PojoGroupMember> groupMembers, String member_extra, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Group_Member_Add;
|
||||
InputAddGroupMember addGroupMember = new InputAddGroupMember();
|
||||
@@ -97,6 +188,17 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置或取消群组管理员
|
||||
* @param operator 操作者用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param groupMemberIds 成员用户ID列表
|
||||
* @param isManager true-设置为管理员,false-取消管理员
|
||||
* @param to_lines 消息同步到的线路列表
|
||||
* @param notify_message 通知消息
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> setGroupManager(String operator, String groupId, List<String> groupMemberIds, boolean isManager, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Group_Set_Manager;
|
||||
InputSetGroupManager addGroupMember = new InputSetGroupManager();
|
||||
@@ -109,6 +211,17 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁言或解禁群组成员
|
||||
* @param operator 操作者用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param groupMemberIds 成员用户ID列表
|
||||
* @param isMute true-禁言,false-解禁
|
||||
* @param to_lines 消息同步到的线路列表
|
||||
* @param notify_message 通知消息
|
||||
* @return 禁言结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> muteGroupMemeber(String operator, String groupId, List<String> groupMemberIds, boolean isMute, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Group_Mute_Member;
|
||||
InputMuteGroupMember addGroupMember = new InputMuteGroupMember();
|
||||
@@ -121,6 +234,17 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 允许或禁止群组成员发言
|
||||
* @param operator 操作者用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param groupMemberIds 成员用户ID列表
|
||||
* @param isAllow true-允许,false-禁止
|
||||
* @param to_lines 消息同步到的线路列表
|
||||
* @param notify_message 通知消息
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> allowGroupMemeber(String operator, String groupId, List<String> groupMemberIds, boolean isAllow, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Group_Allow_Member;
|
||||
InputMuteGroupMember addGroupMember = new InputMuteGroupMember();
|
||||
@@ -133,6 +257,16 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 踢出群组成员
|
||||
* @param operator 操作者用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param groupMemberIds 要踢出的成员用户ID列表
|
||||
* @param to_lines 消息同步到的线路列表
|
||||
* @param notify_message 通知消息
|
||||
* @return 踢出结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> kickoffGroupMembers(String operator, String groupId, List<String> groupMemberIds, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Group_Member_Kickoff;
|
||||
InputKickoffGroupMember kickoffGroupMember = new InputKickoffGroupMember();
|
||||
@@ -144,6 +278,15 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, kickoffGroupMember, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出群组
|
||||
* @param operator 操作者用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param to_lines 消息同步到的线路列表
|
||||
* @param notify_message 通知消息
|
||||
* @return 退出结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> quitGroup(String operator, String groupId, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Group_Member_Quit;
|
||||
InputQuitGroup quitGroup = new InputQuitGroup();
|
||||
@@ -154,6 +297,17 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, quitGroup, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置群组成员别名
|
||||
* @param operator 操作者用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param memberId 成员用户ID
|
||||
* @param alias 别名
|
||||
* @param to_lines 消息同步到的线路列表
|
||||
* @param notify_message 通知消息
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> setGroupMemberAlias(String operator, String groupId, String memberId, String alias, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Group_Set_Member_Alias;
|
||||
InputSetGroupMemberAlias input = new InputSetGroupMemberAlias();
|
||||
@@ -166,6 +320,17 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置群组成员额外信息
|
||||
* @param operator 操作者用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param memberId 成员用户ID
|
||||
* @param extra 额外信息
|
||||
* @param to_lines 消息同步到的线路列表
|
||||
* @param notify_message 通知消息
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> setGroupMemberExtra(String operator, String groupId, String memberId, String extra, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Group_Set_Member_Extra;
|
||||
InputSetGroupMemberExtra input = new InputSetGroupMemberExtra();
|
||||
@@ -178,6 +343,72 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置群组备注(用户个性化设置)
|
||||
* @param userId 用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param remark 备注内容
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> setGroupRemark(String userId, String groupId, String remark) throws Exception {
|
||||
return GeneralAdmin.setUserSetting(userId, 26, groupId, remark);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取群组备注(用户个性化设置)
|
||||
* @param userId 用户ID
|
||||
* @param groupId 群组ID
|
||||
* @return 备注内容
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<String> getGroupRemark(String userId, String groupId) throws Exception {
|
||||
IMResult<UserSettingPojo> imResult = GeneralAdmin.getUserSetting(userId, 26, groupId);
|
||||
IMResult<String> result = new IMResult<>();
|
||||
result.code = imResult.code;;
|
||||
result.msg = imResult.msg;;
|
||||
if(imResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
result.result = imResult.result.getValue();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置群组是否收藏(用户个性化设置)
|
||||
* @param userId 用户ID
|
||||
* @param groupId 群组ID
|
||||
* @param fav true-收藏,false-取消收藏
|
||||
* @return 设置结果
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Void> setFavGroup(String userId, String groupId, boolean fav) throws Exception {
|
||||
return GeneralAdmin.setUserSetting(userId, 6, groupId, fav?"1":"0");
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查群组是否收藏(用户个性化设置)
|
||||
* @param userId 用户ID
|
||||
* @param groupId 群组ID
|
||||
* @return true-已收藏,false-未收藏
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<Boolean> isFavGroup(String userId, String groupId) throws Exception {
|
||||
IMResult<UserSettingPojo> imResult = GeneralAdmin.getUserSetting(userId, 6, groupId);
|
||||
IMResult<Boolean> result = new IMResult<>();
|
||||
result.code = imResult.code;;
|
||||
result.msg = imResult.msg;;
|
||||
if(imResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
result.result = "1".equals(imResult.getResult().getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户的群组列表
|
||||
* @param user 用户ID
|
||||
* @return 用户所属的群组ID列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputGroupIds> getUserGroups(String user) throws Exception {
|
||||
String path = APIPath.Get_User_Groups;
|
||||
InputUserId inputUserId = new InputUserId();
|
||||
@@ -185,12 +416,26 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, inputUserId, OutputGroupIds.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据成员类型获取用户的群组列表
|
||||
* @param user 用户ID
|
||||
* @param groupMemberType 群组成员类型列表(GroupMemberType)
|
||||
* @return 用户所属的群组ID列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputGroupIds> getUserGroupsByType(String user, List</*ProtoConstants.GroupMemberType*/Integer> groupMemberType) throws Exception {
|
||||
String path = APIPath.Get_User_Groups_By_Type;
|
||||
InputGetUserGroupByType input = new InputGetUserGroupByType(user, groupMemberType);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputGroupIds.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取两个用户的共同群组
|
||||
* @param user1 用户1的ID
|
||||
* @param user2 用户2的ID
|
||||
* @return 共同群组ID列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public static IMResult<OutputGroupIds> getCommonGroups(String user1, String user2) throws Exception {
|
||||
String path = APIPath.Get_Common_Groups;
|
||||
StringPairPojo intput = new StringPairPojo(user1, user2);
|
||||
|
||||
@@ -20,27 +20,54 @@ import static cn.wildfirechat.pojos.MyInfoType.Modify_DisplayName;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ChannelState.*;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.SystemSettingType.Group_Max_Member_Count;
|
||||
|
||||
/**
|
||||
* 野火IM Server SDK示例程序主类
|
||||
* <p>
|
||||
* 提供SDK功能演示的示例代码,包括:
|
||||
* <ul>
|
||||
* <li>用户管理操作</li>
|
||||
* <li>群组管理操作</li>
|
||||
* <li>消息发送操作</li>
|
||||
* <li>好友关系管理</li>
|
||||
* <li>朋友圈功能</li>
|
||||
* <li>机器人功能</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class Main {
|
||||
/** 是否为商业版服务器 */
|
||||
private static boolean commercialServer = false;
|
||||
/** 是否启用高级音视频功能 */
|
||||
private static boolean advanceVoip = false;
|
||||
/** 是否启用机器人朋友圈功能 */
|
||||
private static boolean robotMomentsEnabled = false;
|
||||
/** 是否启用朋友圈功能 */
|
||||
private static boolean momentsEnabled = false;
|
||||
//管理端口是8080
|
||||
/** 管理端口是18080 */
|
||||
private static String AdminUrl = "http://localhost:18080";
|
||||
/** 管理员密钥 */
|
||||
private static String AdminSecret = "123456";
|
||||
|
||||
//机器人和频道使用IM服务的公开端口80,注意不是18080
|
||||
/** 机器人和频道使用IM服务的公开端口80,注意不是18080 */
|
||||
private static String IMUrl = "http://localhost";
|
||||
|
||||
|
||||
/**
|
||||
* 程序主入口
|
||||
* @param args 命令行参数,包括:adminUrl、adminSecret、imUrl、commercialServer、advanceVoip
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
// 解析命令行参数
|
||||
if (args.length == 5) {
|
||||
// 从命令行参数获取配置信息
|
||||
AdminUrl = args[0];
|
||||
AdminSecret = args[1];
|
||||
IMUrl = args[2];
|
||||
commercialServer = Boolean.parseBoolean(args[3]);
|
||||
advanceVoip = Boolean.parseBoolean(args[4]);
|
||||
} else {
|
||||
// 显示帮助信息或使用默认值
|
||||
if(args.length == 1 && (args[0].equals("-h") || args[0].equals("--help") || args[0].equals("-help"))) {
|
||||
System.out.println("Usage: java -jar checker.jar adminUrl adminSecret imUrl commercialServer advanceVoip \n e.g. java -jar checker.jar http://192.168.1.80:18080 123456 http://192.168.1.80 false false");
|
||||
return;
|
||||
@@ -53,38 +80,72 @@ public class Main {
|
||||
|
||||
|
||||
//admin使用的是18080端口,超级管理接口,理论上不能对外开放端口,也不能让非内部服务知悉密钥。
|
||||
// 执行管理员API测试
|
||||
testAdmin();
|
||||
|
||||
//测试解析数据库中消息内容
|
||||
testReadMessageContentFromDB();
|
||||
|
||||
//计算消息分表
|
||||
testMessageSharding();
|
||||
|
||||
//Robot和Channel都是使用的80端口,第三方可以创建或者为第三方创建,第三方可以使用robot或者channel与IM系统进行对接。
|
||||
// 测试机器人功能
|
||||
testRobot();
|
||||
// 测试频道功能
|
||||
testChannel();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 管理员API测试总入口
|
||||
* <p>
|
||||
* 测试所有管理员功能,包括:
|
||||
* <ul>
|
||||
* <li>用户管理</li>
|
||||
* <li>用户关系管理</li>
|
||||
* <li>群组管理</li>
|
||||
* <li>聊天室管理</li>
|
||||
* <li>消息管理</li>
|
||||
* <li>消息内容测试</li>
|
||||
* <li>频道API测试</li>
|
||||
* <li>通用API测试</li>
|
||||
* <li>敏感词API测试</li>
|
||||
* <li>设备管理测试(仅商业版)</li>
|
||||
* <li>会议功能测试(仅高级音视频版)</li>
|
||||
* <li>朋友圈功能测试(仅启用时)</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testAdmin() throws Exception {
|
||||
//初始化服务API
|
||||
//初始化服务API,使用管理员URL和密钥
|
||||
AdminConfig.initAdmin(AdminUrl, AdminSecret);
|
||||
|
||||
testUser();
|
||||
testUserRelation();
|
||||
testGroup();
|
||||
testChatroom();
|
||||
testMessage();
|
||||
testMessageContent();
|
||||
testChannelApi();
|
||||
testGeneralApi();
|
||||
testSensitiveApi();
|
||||
// 执行各类管理员API测试
|
||||
testUser(); // 用户管理测试
|
||||
testUserRelation(); // 用户关系测试
|
||||
testGroup(); // 群组管理测试
|
||||
testChatroom(); // 聊天室测试
|
||||
testMessage(); // 消息发送测试
|
||||
testMessageContent(); // 消息内容编码测试
|
||||
testChannelApi(); // 频道API测试
|
||||
testGeneralApi(); // 通用API测试
|
||||
testSensitiveApi(); // 敏感词API测试
|
||||
|
||||
// 商业版功能测试
|
||||
if (commercialServer) {
|
||||
testDevice();
|
||||
testDevice(); // 设备测试(仅商业版)
|
||||
}
|
||||
|
||||
// 高级音视频功能测试
|
||||
if(advanceVoip) {
|
||||
testConference();
|
||||
testConference(); // 会议功能测试(仅高级音视频版)
|
||||
}
|
||||
|
||||
// 朋友圈功能测试
|
||||
if (momentsEnabled) {
|
||||
testMomentsApi();
|
||||
testMomentsApi(); // 朋友圈API测试
|
||||
}
|
||||
|
||||
System.out.println("Congratulation, all admin test case passed!!!!!!!");
|
||||
@@ -93,7 +154,29 @@ public class Main {
|
||||
//***********************************************
|
||||
//**** 用户相关的API
|
||||
//***********************************************
|
||||
/**
|
||||
* 用户管理API测试
|
||||
* <p>
|
||||
* 测试以下功能:
|
||||
* <ul>
|
||||
* <li>创建普通用户</li>
|
||||
* <li>创建和删除机器人</li>
|
||||
* <li>获取用户信息(按用户名、手机号、用户ID、邮箱)</li>
|
||||
* <li>批量获取用户信息</li>
|
||||
* <li>更新用户信息</li>
|
||||
* <li>获取用户IM Token</li>
|
||||
* <li>用户封禁/解封</li>
|
||||
* <li>检查用户在线状态</li>
|
||||
* <li>销毁用户(慎用)</li>
|
||||
* <li>获取所有用户列表</li>
|
||||
* <li>获取在线用户数量和列表(仅商业版)</li>
|
||||
* <li>获取用户会话信息(仅商业版)</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testUser() throws Exception {
|
||||
// 创建用户信息对象
|
||||
InputOutputUserInfo userInfo = new InputOutputUserInfo();
|
||||
//用户ID,必须保证唯一性
|
||||
userInfo.setUserId("userId1");
|
||||
@@ -102,6 +185,7 @@ public class Main {
|
||||
userInfo.setMobile("13900000000");
|
||||
userInfo.setDisplayName("user 1");
|
||||
|
||||
// 调用SDK创建用户
|
||||
IMResult<OutputCreateUser> resultCreateUser = UserAdmin.createUser(userInfo);
|
||||
if (resultCreateUser != null && resultCreateUser.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("Create user " + resultCreateUser.getResult().getName() + " success");
|
||||
@@ -110,6 +194,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 创建机器人信息对象
|
||||
InputCreateRobot createRobot = new InputCreateRobot();
|
||||
createRobot.setUserId("robot1");
|
||||
createRobot.setName("robot1");
|
||||
@@ -117,6 +202,7 @@ public class Main {
|
||||
createRobot.setOwner("userId1");
|
||||
createRobot.setSecret("123456");
|
||||
createRobot.setCallback("http://127.0.0.1:8883/robot/recvmsg");
|
||||
// 调用SDK创建机器人
|
||||
IMResult<OutputCreateRobot> resultCreateRobot = UserAdmin.createRobot(createRobot);
|
||||
if (resultCreateRobot != null && resultCreateRobot.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("Create robot " + resultCreateRobot.getResult().getUserId() + " success");
|
||||
@@ -125,6 +211,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 获取机器人信息
|
||||
IMResult<OutputRobot> outputRobotIMResult = UserAdmin.getRobotInfo("robot1");
|
||||
if(outputRobotIMResult != null && outputRobotIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("Get robot success");
|
||||
@@ -133,6 +220,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 销毁机器人
|
||||
IMResult<Void> destroyResult = UserAdmin.destroyRobot("robot1");
|
||||
if(destroyResult != null && destroyResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("success");
|
||||
@@ -141,6 +229,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 通过用户名获取用户信息
|
||||
IMResult<InputOutputUserInfo> resultGetUserInfo1 = UserAdmin.getUserByName(userInfo.getName());
|
||||
if (resultGetUserInfo1 != null && resultGetUserInfo1.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (userInfo.getUserId().equals(resultGetUserInfo1.getResult().getUserId())
|
||||
@@ -157,6 +246,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 通过手机号获取用户信息
|
||||
IMResult<InputOutputUserInfo> resultGetUserInfo2 = UserAdmin.getUserByMobile(userInfo.getMobile());
|
||||
if (resultGetUserInfo2 != null && resultGetUserInfo2.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (userInfo.getUserId().equals(resultGetUserInfo2.getResult().getUserId())
|
||||
@@ -173,6 +263,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 通过用户ID获取用户信息
|
||||
IMResult<InputOutputUserInfo> resultGetUserInfo3 = UserAdmin.getUserByUserId(userInfo.getUserId());
|
||||
if (resultGetUserInfo3 != null && resultGetUserInfo3.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (userInfo.getUserId().equals(resultGetUserInfo3.getResult().getUserId())
|
||||
@@ -189,6 +280,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 通过邮箱获取用户信息(允许用户不存在)
|
||||
IMResult<OutputUserInfoList> userInfoListIMResult = UserAdmin.getUserByEmail("[email protected]");
|
||||
if(userInfoListIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS || userInfoListIMResult.getErrorCode() == ErrorCode.ERROR_CODE_NOT_EXIST) {
|
||||
System.out.println("getUserByEmail success");
|
||||
@@ -197,6 +289,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 批量获取用户信息
|
||||
IMResult<OutputUserInfoList> batchGetUsers = UserAdmin.getBatchUsers(Arrays.asList("userId1", "admin", "FireRobot", "TestUser"));
|
||||
if (batchGetUsers.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get batch user success");
|
||||
@@ -205,10 +298,12 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 准备更新用户信息(先测试不存在的用户ID)
|
||||
InputOutputUserInfo updateUserInfo = new InputOutputUserInfo();
|
||||
updateUserInfo.setUserId(System.currentTimeMillis()+"");
|
||||
updateUserInfo.setDisplayName("updatedUserName");
|
||||
updateUserInfo.setPortrait("updatedUserPortrait");
|
||||
// 设置更新标志:更新显示名称和头像
|
||||
int updateUserFlag = ProtoConstants.UpdateUserInfoMask.Update_User_DisplayName | ProtoConstants.UpdateUserInfoMask.Update_User_Portrait;
|
||||
IMResult<Void> result = UserAdmin.updateUserInfo(updateUserInfo, updateUserFlag);
|
||||
if(result != null && result.getErrorCode() == ErrorCode.ERROR_CODE_NOT_EXIST) {
|
||||
@@ -218,6 +313,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 更新存在的用户信息
|
||||
updateUserInfo.setUserId(userInfo.getUserId());
|
||||
result = UserAdmin.updateUserInfo(updateUserInfo, updateUserFlag);
|
||||
if(result != null && result.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
@@ -227,6 +323,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 验证用户信息是否更新成功
|
||||
IMResult<InputOutputUserInfo> resultGetUserInfo4 = UserAdmin.getUserByUserId(userInfo.getUserId());
|
||||
if (resultGetUserInfo4 != null && resultGetUserInfo4.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (userInfo.getUserId().equals(resultGetUserInfo4.getResult().getUserId())
|
||||
@@ -242,6 +339,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 获取用户的IM Token,用于客户端登录
|
||||
IMResult<OutputGetIMTokenData> resultGetToken = UserAdmin.getUserToken(userInfo.getUserId(), "client111", ProtoConstants.Platform.Platform_Android);
|
||||
if (resultGetToken != null && resultGetToken.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get token success: " + resultGetToken.getResult().getToken());
|
||||
@@ -250,6 +348,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 封禁用户(状态码:2表示封禁)
|
||||
IMResult<Void> resultVoid =UserAdmin.updateUserBlockStatus(userInfo.getUserId(), 2);
|
||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("block user done");
|
||||
@@ -258,6 +357,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 检查用户封禁状态
|
||||
IMResult<OutputUserStatus> resultCheckUserStatus = UserAdmin.checkUserBlockStatus(userInfo.getUserId());
|
||||
if (resultCheckUserStatus != null && resultCheckUserStatus.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (resultCheckUserStatus.getResult().getStatus() == 2) {
|
||||
@@ -271,6 +371,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 获取所有被封禁用户列表
|
||||
IMResult<OutputUserBlockStatusList> resultBlockStatusList = UserAdmin.getBlockedList();
|
||||
if (resultBlockStatusList != null && resultBlockStatusList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
boolean success = false;
|
||||
@@ -290,6 +391,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 解封用户(状态码:0表示正常)
|
||||
resultVoid =UserAdmin.updateUserBlockStatus(userInfo.getUserId(), 0);
|
||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("block user done");
|
||||
@@ -298,6 +400,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 再次检查用户状态,确认已解封
|
||||
resultCheckUserStatus = UserAdmin.checkUserBlockStatus(userInfo.getUserId());
|
||||
if (resultCheckUserStatus != null && resultCheckUserStatus.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (resultCheckUserStatus.getResult().getStatus() == 0) {
|
||||
@@ -311,6 +414,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 检查用户在线状态
|
||||
IMResult<OutputCheckUserOnline> outputCheckUserOnline = UserAdmin.checkUserOnlineStatus(userInfo.getUserId());
|
||||
if (outputCheckUserOnline != null && outputCheckUserOnline.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("check user online status success:" + outputCheckUserOnline.getResult().getSessions().size());
|
||||
@@ -320,6 +424,7 @@ public class Main {
|
||||
}
|
||||
|
||||
//慎用,这个方法可能功能不完全,如果用户不在需要,建议使用block功能屏蔽用户
|
||||
// 销毁用户(物理删除,不可恢复)
|
||||
IMResult<Void> voidIMResult = UserAdmin.destroyUser("user11");
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("destroy user success");
|
||||
@@ -328,6 +433,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 获取所有用户列表(分页:每页100条,第0页)
|
||||
IMResult<OutputGetUserList> getUserListIMResult = UserAdmin.getAllUsers(100, 0);
|
||||
if (getUserListIMResult != null && getUserListIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("getUserListIMResult success");
|
||||
@@ -336,7 +442,9 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 商业版专属功能
|
||||
if (commercialServer) {
|
||||
// 获取在线用户总数
|
||||
IMResult<GetOnlineUserCountResult> getOnlineUserCountResultIMResult = UserAdmin.getOnlineUserCount();
|
||||
if (getOnlineUserCountResultIMResult != null && getOnlineUserCountResultIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get user online count success");
|
||||
@@ -345,6 +453,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 获取在线用户列表(分页:第1页,从0开始,每页100条)
|
||||
IMResult<GetOnlineUserResult> getOnlineUserResultIMResult = UserAdmin.getOnlineUser(1, 0, 100);
|
||||
if (getOnlineUserResultIMResult != null && getOnlineUserResultIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get user online success");
|
||||
@@ -353,6 +462,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 获取指定用户的会话信息
|
||||
IMResult<GetUserSessionResult> getUserSessionResultIMResult = UserAdmin.getUserSession("hygqmws2k");
|
||||
if (getUserSessionResultIMResult != null && getUserSessionResultIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get user session success");
|
||||
@@ -366,15 +476,33 @@ public class Main {
|
||||
//***********************************************
|
||||
//**** 用户关系相关的API
|
||||
//***********************************************
|
||||
/**
|
||||
* 用户关系管理API测试
|
||||
* <p>
|
||||
* 测试以下功能:
|
||||
* <ul>
|
||||
* <li>发送好友请求</li>
|
||||
* <li>设置好友关系</li>
|
||||
* <li>获取好友列表</li>
|
||||
* <li>解除好友关系</li>
|
||||
* <li>黑名单管理</li>
|
||||
* <li>好友备注(别名)管理</li>
|
||||
* <li>好友额外信息管理</li>
|
||||
* <li>获取好友关系详情</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testUserRelation() throws Exception {
|
||||
|
||||
//先创建2个用户
|
||||
//先创建2个用户用于测试好友关系
|
||||
InputOutputUserInfo userInfo = new InputOutputUserInfo();
|
||||
userInfo.setUserId("ff1");
|
||||
userInfo.setName("ff1");
|
||||
userInfo.setMobile("13800000000");
|
||||
userInfo.setDisplayName("ff1");
|
||||
|
||||
// 调用SDK创建第一个用户
|
||||
IMResult<OutputCreateUser> resultCreateUser = UserAdmin.createUser(userInfo);
|
||||
if (resultCreateUser != null && resultCreateUser.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("Create user " + resultCreateUser.getResult().getName() + " success");
|
||||
@@ -383,12 +511,14 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 创建第二个用户
|
||||
userInfo = new InputOutputUserInfo();
|
||||
userInfo.setUserId("ff2");
|
||||
userInfo.setName("ff2");
|
||||
userInfo.setMobile("13800000001");
|
||||
userInfo.setDisplayName("ff2");
|
||||
|
||||
// 调用SDK创建第二个用户
|
||||
resultCreateUser = UserAdmin.createUser(userInfo);
|
||||
if (resultCreateUser != null && resultCreateUser.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("Create user " + resultCreateUser.getResult().getName() + " success");
|
||||
@@ -397,6 +527,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 发送好友请求:ff1向ff2发送好友请求,附带问候语"hello",直接设为好友
|
||||
IMResult<Void> result = RelationAdmin.sendFriendRequest("ff1", "ff2", "hello", true);
|
||||
if (result != null && (result.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS || result.getErrorCode() == ErrorCode.ERROR_CODE_ALREADY_FRIENDS)) {
|
||||
System.out.println("send friend request success");
|
||||
@@ -405,6 +536,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 设置好友关系:ff1把ff2设为好友,并附带额外信息
|
||||
IMResult<Void> updateFriendStatusResult = RelationAdmin.setUserFriend("ff1", "ff2", true, "{\"from\":1}");
|
||||
if (updateFriendStatusResult != null && updateFriendStatusResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("update friend status success");
|
||||
@@ -413,6 +545,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 获取ff1的好友列表
|
||||
IMResult<OutputStringList> resultGetFriendList = RelationAdmin.getFriendList("ff1");
|
||||
if (resultGetFriendList != null && resultGetFriendList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultGetFriendList.getResult().getList().contains("ff2")) {
|
||||
System.out.println("get friend status success");
|
||||
@@ -421,6 +554,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 解除好友关系:ff1删除ff2
|
||||
updateFriendStatusResult = RelationAdmin.setUserFriend("ff1", "ff2", false, null);
|
||||
if (updateFriendStatusResult != null && updateFriendStatusResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("update friend status success");
|
||||
@@ -429,6 +563,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 再次获取好友列表,确认ff2已被删除
|
||||
resultGetFriendList = RelationAdmin.getFriendList("ff1");
|
||||
if (resultGetFriendList != null && resultGetFriendList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && !resultGetFriendList.getResult().getList().contains("ff2")) {
|
||||
System.out.println("get friend status success");
|
||||
@@ -438,6 +573,7 @@ public class Main {
|
||||
}
|
||||
|
||||
|
||||
// 将ff2加入黑名单:ff1把ff2加入黑名单
|
||||
IMResult<Void> updateBlacklistStatusResult = RelationAdmin.setUserBlacklist("ff1", "ff2", true);
|
||||
if (updateBlacklistStatusResult != null && updateBlacklistStatusResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("update blacklist status success");
|
||||
@@ -446,6 +582,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 获取黑名单列表
|
||||
resultGetFriendList = RelationAdmin.getUserBlacklist("ff1");
|
||||
if (resultGetFriendList != null && resultGetFriendList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultGetFriendList.getResult().getList().contains("ff2")) {
|
||||
System.out.println("get blacklist status success");
|
||||
@@ -454,6 +591,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 设置好友备注(别名)
|
||||
String alias = "hello" + System.currentTimeMillis();
|
||||
IMResult<Void> updateFriendAlias = RelationAdmin.updateFriendAlias("ff1", "ff2", alias);
|
||||
if (updateFriendAlias != null && updateFriendAlias.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
@@ -463,6 +601,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 获取好友备注(别名)
|
||||
IMResult<OutputGetAlias> getFriendAlias = RelationAdmin.getFriendAlias("ff1", "ff2");
|
||||
if (getFriendAlias != null && getFriendAlias.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && getFriendAlias.getResult().getAlias().equals(alias)) {
|
||||
System.out.println("get friend alias success");
|
||||
@@ -471,6 +610,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 设置好友额外信息(可以存储自定义数据)
|
||||
String friendExtra = "hello friend extra";
|
||||
IMResult<Void> setExtraResult = RelationAdmin.updateFriendExtra("ff1", "ff2", friendExtra);
|
||||
if (setExtraResult != null && setExtraResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
@@ -480,6 +620,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 获取好友关系详情(包括额外信息等)
|
||||
IMResult<RelationPojo> getRelation = RelationAdmin.getRelation("ff1", "ff2");
|
||||
if (getRelation != null && getRelation.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get friend relation success");
|
||||
@@ -488,6 +629,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// 验证好友额外信息是否正确
|
||||
if(!friendExtra.equals(getRelation.getResult().extra)) {
|
||||
System.out.println("set friend extra failure");
|
||||
System.exit(-1);
|
||||
@@ -496,8 +638,31 @@ public class Main {
|
||||
//***********************************************
|
||||
//**** 群组相关功能
|
||||
//***********************************************
|
||||
/**
|
||||
* 群组管理API测试
|
||||
* <p>
|
||||
* 测试以下功能:
|
||||
* <ul>
|
||||
* <li>创建群组</li>
|
||||
* <li>获取群组信息</li>
|
||||
* <li>转移群主</li>
|
||||
* <li>修改群组信息(名称、扩展字段)</li>
|
||||
* <li>获取群成员列表</li>
|
||||
* <li>添加群成员</li>
|
||||
* <li>踢出群成员</li>
|
||||
* <li>设置群成员别名和扩展信息</li>
|
||||
* <li>设置/取消群管理员(仅商业版)</li>
|
||||
* <li>退出群组</li>
|
||||
* <li>获取用户的群组列表</li>
|
||||
* <li>获取共同群组</li>
|
||||
* <li>群成员禁言/白名单管理(仅商业版)</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testGroup() throws Exception {
|
||||
|
||||
// 先解散可能存在的测试群组
|
||||
IMResult<Void> voidIMResult1 = GroupAdmin.dismissGroup("user1", "groupId1", null, null);
|
||||
|
||||
PojoGroupInfo groupInfo = new PojoGroupInfo();
|
||||
@@ -616,7 +781,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
voidIMResult = GroupAdmin.setGroupMemberAlias("user1", groupInfo.getTarget_id(), "user3", "test user3", null, null);
|
||||
voidIMResult = GroupAdmin.setGroupMemberAlias("user1", groupInfo.getTarget_id(), "user2", "test user2", null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("set group member alias success");
|
||||
} else {
|
||||
@@ -745,10 +910,33 @@ public class Main {
|
||||
//***********************************************
|
||||
//**** 消息相关功能
|
||||
//***********************************************
|
||||
/**
|
||||
* 消息管理API测试
|
||||
* <p>
|
||||
* 测试以下功能:
|
||||
* <ul>
|
||||
* <li>发送单聊消息</li>
|
||||
* <li>获取消息详情</li>
|
||||
* <li>撤回消息</li>
|
||||
* <li>删除消息(仅商业版)</li>
|
||||
* <li>更新消息内容(仅商业版)</li>
|
||||
* <li>广播消息(仅商业版)</li>
|
||||
* <li>撤回广播消息(仅商业版)</li>
|
||||
* <li>获取会话已读时间戳(仅商业版)</li>
|
||||
* <li>获取消息投递状态(仅商业版)</li>
|
||||
* <li>清除会话(仅商业版)</li>
|
||||
* <li>群发消息</li>
|
||||
* <li>撤回群发消息</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testMessage() throws Exception {
|
||||
// 创建会话对象:目标用户ff2,会话类型为私聊
|
||||
Conversation conversation = new Conversation();
|
||||
conversation.setTarget("ff2");
|
||||
conversation.setType(ProtoConstants.ConversationType.ConversationType_Private);
|
||||
// 创建文本消息内容并编码为MessagePayload
|
||||
TextMessageContent textMessageContent = new TextMessageContent("Hello world");
|
||||
MessagePayload payload = textMessageContent.encode();
|
||||
|
||||
@@ -865,8 +1053,31 @@ public class Main {
|
||||
//***********************************************
|
||||
//**** 发送各种消息。
|
||||
//***********************************************
|
||||
/**
|
||||
* 消息内容编码测试
|
||||
* <p>
|
||||
* 测试各种类型消息的编码和发送:
|
||||
* <ul>
|
||||
* <li>文本消息</li>
|
||||
* <li>语音消息</li>
|
||||
* <li>图片消息</li>
|
||||
* <li>视频消息</li>
|
||||
* <li>位置消息</li>
|
||||
* <li>文件消息</li>
|
||||
* <li>动态表情消息</li>
|
||||
* <li>链接消息</li>
|
||||
* <li>名片消息</li>
|
||||
* <li>提醒消息</li>
|
||||
* <li>富通知消息</li>
|
||||
* <li>流式文本消息</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testMessageContent() throws Exception {
|
||||
// 设置发送者
|
||||
String sender = "userId2";
|
||||
// 创建会话对象
|
||||
Conversation conversation = new Conversation();
|
||||
conversation.setTarget("3ygqmws2k");
|
||||
conversation.setType(ProtoConstants.ConversationType.ConversationType_Private);
|
||||
@@ -1003,13 +1214,49 @@ public class Main {
|
||||
testStreamingText(sender, conversation);
|
||||
}
|
||||
|
||||
static void testReadMessageContentFromDB() throws Exception {
|
||||
//需要注意几点:
|
||||
// 1 WFCMessage类不能混淆,如果混淆 WFCMessage.MessageContent.parseFrom(data) 就会失败。
|
||||
// 2 MessageContentFactory方法会自动查找所有的消息类,包括文本/图片/语音等。也有可能在某些环境下找不到这些类。可以检查MessageContentFactory
|
||||
// 类的源码,修改registerAllMessageContent方法,确保能找到所有的内容类。也可以显式调用注册的方法把所有已知消息都注册一遍,比如:
|
||||
// MessageContentFactory.registerCustomMessageContent(TextMessageContent.class); //这里示例只写了文本的,其他所有已知消息都需要注册一遍。
|
||||
//消息相关表分为2类,分表是:t_messages_x和t_user_messages_y,并且是分表存储的。表内存储数据和分表规则请参考 https://docs.wildfirechat.cn/faq/server.html 问题2
|
||||
/**
|
||||
* 消息分表计算测试
|
||||
* <p>
|
||||
* 演示如何计算消息存储的分表名称:
|
||||
* <ul>
|
||||
* <li>用户消息表:t_user_messages_x (x为用户ID哈希值%128)</li>
|
||||
* <li>消息表:t_messages_y (y为年份*12+月份)</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
static void testMessageSharding() {
|
||||
String userId = "user1";
|
||||
// 计算用户消息表:使用用户ID的哈希值对128取模
|
||||
int hashId = Math.abs(userId.hashCode())%128;
|
||||
String userMessageTable = "t_user_messages_" + hashId;
|
||||
System.out.println("user:" + userId + " user messages table is " + userMessageTable);
|
||||
|
||||
// 计算消息表:使用年份和月份
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Date date = new Date();
|
||||
calendar.setTime(date);
|
||||
int month = calendar.get(Calendar.MONTH);
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
year %= 3;
|
||||
String messageTable = "t_messages_" + (year * 12 + month);
|
||||
System.out.println("This month save message to table " + messageTable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从数据库读取消息内容测试
|
||||
* <p>
|
||||
* 演示如何从数据库的二进制数据解析消息内容:
|
||||
* <ul>
|
||||
* <li>从数据库读取_messageContent字段</li>
|
||||
* <li>解析为协议栈MessageContent对象</li>
|
||||
* <li>使用MessageContentFactory解码为具体消息类型</li>
|
||||
* <li>处理不同类型的消息(文本、图片、语音等)</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当解析过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testReadMessageContentFromDB() throws Exception {
|
||||
//从数据库t_messages_x表中读取到消息内容字段_data的二进制数据为
|
||||
byte[] data = {8,1,18,5,72,101,108,108,111,64,3};
|
||||
//1. 先把二进制数据转化为协议栈消息内容。
|
||||
@@ -1049,6 +1296,13 @@ public class Main {
|
||||
// 比如 MessageContentFactory.registerCustomMessageContent(CustomTextMessageContent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查消息发送结果
|
||||
* <p>
|
||||
* 验证消息是否发送成功,如果失败则退出程序。
|
||||
* </p>
|
||||
* @param resultSendMessage 消息发送结果
|
||||
*/
|
||||
static void checkSendMessageResult(IMResult<SendMessageResult> resultSendMessage) {
|
||||
if (resultSendMessage != null && resultSendMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("send message success");
|
||||
@@ -1058,7 +1312,22 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 流式文本消息测试
|
||||
* <p>
|
||||
* 演示如何发送流式文本消息,模拟AI逐字生成效果:
|
||||
* <ul>
|
||||
* <li>将长文本分段发送</li>
|
||||
* <li>使用StreamTextGeneratingMessageContent表示正在生成</li>
|
||||
* <li>使用StreamTextGeneratedMessageContent表示生成完成</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @param sender 发送者用户ID
|
||||
* @param conversation 会话对象
|
||||
* @throws Exception 当发送过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testStreamingText(String sender, Conversation conversation) throws Exception {
|
||||
// 准备要发送的长文本
|
||||
String fullText = "北京野火无限网络科技有限公司是成立于2019年底的一家科技创新企业,公司的主要目标是为广大企业和单位提供优质可控、私有部署的即时通讯和实时音视频能力,为社会信息化水平提高作出自己的贡献。\n" +
|
||||
"\n" +
|
||||
"野火IM是公司研发一套自主可控的即时通讯组件,具有全部私有化、功能齐全、协议稳定可靠、全平台支持、安全性高和支持国产化等技术特点。客户端分层设计,既可开箱即用,也可与现有系统深度融合。具有完善的服务端API和自定义消息功能,可以任意扩展功能。代码开源率高,方便二次开发和使用。支持多人实时音视频和会议功能,线上沟通更通畅。\n" +
|
||||
@@ -1099,6 +1368,21 @@ public class Main {
|
||||
//***********************************************
|
||||
//**** 测试频道功能
|
||||
//***********************************************
|
||||
/**
|
||||
* 频道管理API测试
|
||||
* <p>
|
||||
* 测试以下功能:
|
||||
* <ul>
|
||||
* <li>创建频道</li>
|
||||
* <li>获取频道信息</li>
|
||||
* <li>关注频道</li>
|
||||
* <li>取消关注频道</li>
|
||||
* <li>检查用户关注状态</li>
|
||||
* <li>销毁频道(标记为已删除状态)</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testChannelApi() throws Exception {
|
||||
String channelName = "MyChannel";
|
||||
String channelOwner = "user1";
|
||||
@@ -1180,6 +1464,19 @@ public class Main {
|
||||
//***********************************************
|
||||
//**** 一些其它的功能,比如创建频道,更新用户设置等
|
||||
//***********************************************
|
||||
/**
|
||||
* 通用API测试
|
||||
* <p>
|
||||
* 测试以下功能:
|
||||
* <ul>
|
||||
* <li>获取系统设置(如群组最大成员数)</li>
|
||||
* <li>修改用户设置</li>
|
||||
* <li>发送用户设置</li>
|
||||
* <li>获取用户设置</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testGeneralApi() throws Exception {
|
||||
IMResult<SystemSettingPojo> resultGetSystemSetting = GeneralAdmin.getSystemSetting(Group_Max_Member_Count);
|
||||
if (resultGetSystemSetting != null && resultGetSystemSetting.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
@@ -1214,6 +1511,23 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 聊天室管理API测试
|
||||
* <p>
|
||||
* 测试以下功能:
|
||||
* <ul>
|
||||
* <li>创建聊天室</li>
|
||||
* <li>获取聊天室信息</li>
|
||||
* <li>获取聊天室成员列表</li>
|
||||
* <li>销毁聊天室</li>
|
||||
* <li>获取用户的聊天室</li>
|
||||
* <li>设置聊天室黑名单(仅商业版)</li>
|
||||
* <li>获取聊天室黑名单(仅商业版)</li>
|
||||
* <li>发送聊天室消息</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testChatroom() throws Exception {
|
||||
String chatroomId = "chatroomId1";
|
||||
String chatroomTitle = "TESTCHATROM";
|
||||
@@ -1378,6 +1692,32 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 机器人功能测试
|
||||
* <p>
|
||||
* 测试以下功能:
|
||||
* <ul>
|
||||
* <li>创建机器人</li>
|
||||
* <li>初始化RobotService(使用IM端口80)</li>
|
||||
* <li>获取机器人信息</li>
|
||||
* <li>发送消息</li>
|
||||
* <li>撤回消息(仅商业版)</li>
|
||||
* <li>更新消息(仅商业版)</li>
|
||||
* <li>获取用户信息</li>
|
||||
* <li>创建群组</li>
|
||||
* <li>发送群组消息</li>
|
||||
* <li>获取群组信息</li>
|
||||
* <li>获取群组成员</li>
|
||||
* <li>修改群组信息</li>
|
||||
* <li>添加群成员</li>
|
||||
* <li>踢出群成员</li>
|
||||
* <li>退出群组</li>
|
||||
* <li>解散群组</li>
|
||||
* <li>销毁机器人</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testRobot() throws Exception {
|
||||
String robotId = "robot1";
|
||||
String robotSecret = "123456";
|
||||
@@ -1399,6 +1739,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
//使用完需要释放
|
||||
RobotService robotService = new RobotService(IMUrl, robotId, robotSecret);
|
||||
|
||||
//***********************************************
|
||||
@@ -1605,7 +1946,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
voidIMResult = robotService.setGroupMemberAlias(groupInfo.getTarget_id(), "user3", "test user3", null, null);
|
||||
voidIMResult = robotService.setGroupMemberAlias(groupInfo.getTarget_id(), "user2", "test user2", null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("set group member alias success");
|
||||
} else {
|
||||
@@ -1798,9 +2139,33 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
//使用完需要释放
|
||||
robotService.close();
|
||||
}
|
||||
|
||||
//***测试频道API功能,仅专业版支持***
|
||||
/**
|
||||
* 频道功能测试(仅专业版支持)
|
||||
* <p>
|
||||
* 测试以下功能:
|
||||
* <ul>
|
||||
* <li>创建频道</li>
|
||||
* <li>获取频道信息</li>
|
||||
* <li>修改频道信息</li>
|
||||
* <li>获取频道列表</li>
|
||||
* <li>关注/取消关注频道</li>
|
||||
* <li>获取频道关注者</li>
|
||||
* <li>设置频道菜单</li>
|
||||
* <li>获取频道菜单</li>
|
||||
* <li>发送频道消息</li>
|
||||
* <li>获取频道历史消息</li>
|
||||
* <li>获取用户关注的频道</li>
|
||||
* <li>删除频道(标记为已删除)</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testChannel() throws Exception {
|
||||
//初始化服务API
|
||||
AdminConfig.initAdmin(AdminUrl, AdminSecret);
|
||||
@@ -1868,7 +2233,7 @@ public class Main {
|
||||
}
|
||||
|
||||
|
||||
//2. 初始化api,注意端口是80,不是18080
|
||||
//2. 初始化api,注意端口是80,不是18080 //使用完需要释放
|
||||
ChannelServiceApi channelServiceApi = new ChannelServiceApi(IMUrl, channelId, secret);
|
||||
|
||||
|
||||
@@ -2024,7 +2389,24 @@ public class Main {
|
||||
}
|
||||
OutputApplicationConfigData config = channelServiceApi.getApplicationSignature();
|
||||
System.out.println(config);
|
||||
|
||||
//使用完需要释放
|
||||
channelServiceApi.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 敏感词管理API测试
|
||||
* <p>
|
||||
* 测试以下功能:
|
||||
* <ul>
|
||||
* <li>添加敏感词到敏感词库</li>
|
||||
* <li>获取敏感词列表</li>
|
||||
* <li>从敏感词库移除敏感词</li>
|
||||
* <li>验证敏感词添加和移除操作</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testSensitiveApi() throws Exception {
|
||||
List<String> words = Arrays.asList("a","b","c");
|
||||
IMResult<Void> addResult = SensitiveAdmin.addSensitives(words);
|
||||
@@ -2063,6 +2445,18 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 朋友圈(动态)API测试
|
||||
* <p>
|
||||
* 测试以下功能:
|
||||
* <ul>
|
||||
* <li>发布动态(朋友圈)</li>
|
||||
* <li>发送文本动态内容</li>
|
||||
* <li>验证动态发送结果</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testMomentsApi() throws Exception {
|
||||
FeedPojo feedPojo = new FeedPojo();
|
||||
feedPojo.sender = "73055b4105de4b70993b7258afbfc387";
|
||||
@@ -2080,6 +2474,20 @@ public class Main {
|
||||
//***********************************************
|
||||
//**** 物联网相关的API,仅专业版支持
|
||||
//***********************************************
|
||||
/**
|
||||
* 物联网设备管理API测试(仅专业版支持)
|
||||
* <p>
|
||||
* 测试以下功能:
|
||||
* <ul>
|
||||
* <li>创建或更新设备</li>
|
||||
* <li>获取设备信息</li>
|
||||
* <li>设备绑定多个所有者</li>
|
||||
* <li>设备ID唯一性验证</li>
|
||||
* <li>销毁设备</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* @throws Exception 当测试过程中发生错误时抛出异常
|
||||
*/
|
||||
static void testDevice() throws Exception {
|
||||
InputCreateDevice createDevice = new InputCreateDevice();
|
||||
createDevice.setDeviceId("deviceId1");
|
||||
@@ -2125,7 +2533,7 @@ public class Main {
|
||||
会议相关接口,仅音视频高级版服务支持
|
||||
*/
|
||||
public static void testConference() throws Exception {
|
||||
IMResult<PojoConferenceInfoList> listResult = ConferenceAdmin.listConferences();
|
||||
IMResult<PojoConferenceInfoList> listResult = ConferenceAdmin.listConferences(100, 0);
|
||||
if(listResult == null || listResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get conference list failure");
|
||||
System.exit(-1);
|
||||
@@ -2143,7 +2551,7 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
listResult = ConferenceAdmin.listConferences();
|
||||
listResult = ConferenceAdmin.listConferences(100, 0);
|
||||
if(listResult == null || listResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get conference list failure");
|
||||
System.exit(-1);
|
||||
@@ -2183,7 +2591,7 @@ public class Main {
|
||||
System.out.println("recording conference success");
|
||||
}
|
||||
|
||||
listResult = ConferenceAdmin.listConferences();
|
||||
listResult = ConferenceAdmin.listConferences(100, 0);
|
||||
if(listResult == null || listResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get conference list failure");
|
||||
System.exit(-1);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user