Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51bfb788ac | ||
|
|
82088db682 | ||
|
|
463e3e766a | ||
|
|
4b00b873c3 | ||
|
|
0c06e28116 | ||
|
|
7ea6ea08fd | ||
|
|
b61d292fb5 | ||
|
|
0aba453a24 | ||
|
|
10ce88de20 | ||
|
|
b0fe3fd57f | ||
|
|
141c8f38d8 | ||
|
|
43b325d2d5 | ||
|
|
1627515c1d | ||
|
|
d8670a0f66 | ||
|
|
40e9d108ad | ||
|
|
cdc7f0893c | ||
|
|
953342747d | ||
|
|
346e51b2e1 | ||
|
|
b64468f86f | ||
|
|
3609b02ed3 | ||
|
|
3c9ed877b5 | ||
|
|
7706efcf8c | ||
|
|
2ced517f70 | ||
|
|
d99e9a079d | ||
|
|
49fcc73f78 | ||
|
|
d491ac0ad7 | ||
|
|
d89893821f | ||
|
|
2d661a1f74 | ||
|
|
5028a64fa9 | ||
|
|
b4fe064807 | ||
|
|
7335fa4c2a | ||
|
|
a62e32a369 | ||
|
|
b7abdcae52 | ||
|
|
bc25587461 | ||
|
|
499ee713d6 | ||
|
|
a6c6cf080c | ||
|
|
47c2e26ec3 | ||
|
|
6b264f2c9d | ||
|
|
705ac341e0 | ||
|
|
2c07036364 | ||
|
|
1a460f1b29 | ||
|
|
e10b78bb34 | ||
|
|
edd973904a | ||
|
|
8ed1ba2f3a | ||
|
|
6f24579c8e | ||
|
|
c7bb49b3f7 | ||
|
|
d4d467afe2 | ||
|
|
96f7baece4 | ||
|
|
2421d02eb8 | ||
|
|
f6e9af58d4 | ||
|
|
1dbc5d490e | ||
|
|
f04f4fb087 | ||
|
|
1c9c77c06b |
@@ -2,18 +2,19 @@
|
||||
|
||||
野火IM是一套跨平台、核心功能开源的即时通讯解决方案,主要包含以下内容。
|
||||
|
||||
| 仓库 | 说明 | 备注 |
|
||||
| ------------------------------------------------------------ | ------------------------------------------------------- | ---- |
|
||||
| [android-chat](https://github.com/wildfirechat/android-chat) | 野火IM Android SDK源码和App源码 |可以很方便地进行二次开发,或集成到现有应用当中 |
|
||||
| [ios-chat](https://github.com/wildfirechat/ios-chat) | 野火IM iOS SDK源码和App源码 |可以很方便地进行二次开发,或集成到现有应用当中 |
|
||||
| [pc-chat](https://github.com/wildfirechat/pc-chat) | 基于[Electron](https://electronjs.org/)开发的PC平台应用 | |
|
||||
| [web-chat](https://github.com/wildfirechat/web-chat) | Web平台的Demo, [体验地址](http://web.wildfirechat.net) | |
|
||||
| [wx-chat](https://github.com/wildfirechat/wx-chat) | 微信小程序平台的Demo | |
|
||||
| [server](https://github.com/wildfirechat/server) | IM server | |
|
||||
| [app server](https://github.com/wildfirechat/app_server) | 应用服务端 | |
|
||||
| [robot_server](https://github.com/wildfirechat/robot_server) | 机器人服务端 | |
|
||||
| [push_server](https://github.com/wildfirechat/push_server) | 推送服务器 | |
|
||||
| [docs](https://github.com/wildfirechat/docs) | 野火IM相关文档,包含设计、概念、开发、使用说明 | | | |
|
||||
| [GitHub仓库地址(主站)](https://github.com/wildfirechat) | [码云仓库地址(镜像)](https://gitee.com/wfchat) | 说明 | 备注 |
|
||||
| ------------------------------------------------------------ | ----------------------------------------------------- | ----------------------------------------------------------------------------------------- | ---------------------------------------------- |
|
||||
| [android-chat](https://github.com/wildfirechat/android-chat) | [android-chat](https://gitee.com/wfchat/android-chat) | 野火IM Android SDK源码和App源码 | 可以很方便地进行二次开发,或集成到现有应用当中 |
|
||||
| [ios-chat](https://github.com/wildfirechat/ios-chat) | [ios-chat](https://gitee.com/wfchat/ios-chat) | 野火IM iOS SDK源码和App源码 | 可以很方便地进行二次开发,或集成到现有应用当中 |
|
||||
| [pc-chat](https://github.com/wildfirechat/pc-chat) | [pc-chat](https://gitee.com/wfchat/pc-chat) | 基于[Electron](https://electronjs.org/)开发的PC平台应用 | |
|
||||
| [web-chat](https://github.com/wildfirechat/web-chat) | [web-chat](https://gitee.com/wfchat/web-chat) | Web平台的Demo, [体验地址](http://web.wildfirechat.cn) | |
|
||||
| [wx-chat](https://github.com/wildfirechat/wx-chat) | [wx-chat](https://gitee.com/wfchat/wx-chat) | 微信小程序平台的Demo | |
|
||||
| [server](https://github.com/wildfirechat/server) | [server](https://gitee.com/wfchat/server) | IM server | |
|
||||
| [app server](https://github.com/wildfirechat/app_server) | [app server](https://gitee.com/wfchat/app_server) | 应用服务端 | |
|
||||
| [robot_server](https://github.com/wildfirechat/robot_server) | [robot_server](https://gitee.com/wfchat/robot_server) | 机器人服务端 | |
|
||||
| [push_server](https://github.com/wildfirechat/push_server) | [push_server](https://gitee.com/wfchat/push_server) | 推送服务器 | |
|
||||
| [docs](https://github.com/wildfirechat/docs) | [docs](https://gitee.com/wfchat/docs) | 野火IM相关文档,包含设计、概念、开发、使用说明,[在线查看](https://docs.wildfirechat.cn/) | | |
|
||||
|
||||
|
||||
# server
|
||||
本工程为野火IM 社区版IM服务软件。野火IM作为一个通用的即时通讯解决方案,可以集成到各种应用中。请阅读[docs](http://docs.wildfirechat.net)或下载服务器[发布版本](https://github.com/wildfirechat/server/releases)
|
||||
@@ -74,6 +75,7 @@
|
||||
1. 从0.42 版本增加了群成员数限制,默认为2000。如果您从之前的版本升级到这个版本或以后,需要注意到群成员数的限制。升级之后超出限制的群不受影响,但不能继续加人,如果您想修改默认值,可以在升级版本之后,修改t_setting表,把默认的大小改为您期望的人数。另外修改t_group表,把已经存在的群组max_member_count改成您期望的,然后重启。
|
||||
2. 0.46和0.47版本升级到0.48及以后版本时,可能会提示flyway migrate 38错误,请执行 [修复脚本](https://github.com/wildfirechat/server/blob/wildfirechat/flyway_repaire_migrate_38.sql) 进行修复。0.46和0.47版本之外的版本不会出现此问题。
|
||||
3. 从0.54之前版本升级到0.54及以后版本时,会提示flyway migrate错误。因为0.54版本删除了sql脚本中默认敏感词的内容,flyway checksum失败。请执行```update flyway_schema_history set checksum = 0 where script = 'V17__add_default_sensitive_word.sql';```来修复。
|
||||
4. 从0.59之前的版本升级到之后的版本执行数据库升级时间比较长,请耐心等待提示运行成功,避免中途中断。
|
||||
|
||||
## 特别感谢
|
||||
1. [moquette](https://github.com/moquette-io/moquette) 本项目是基于此项目二次开发而来,处理MQTT相关业务。
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#服务器的接入IP。给客户端提供是${server.ip}和${http_port}。
|
||||
#客户端会从${http_port}端口获取到长链接端口。这个地址一定要改成客户端可以访问到的IP地址
|
||||
# (如果您部署云服务器上或者具有独立公网出口的服务器上,请改为对应的公网IP;如果您部署在在内网环境下,在内网使用,这个地方改成内网地址)
|
||||
server.ip 0.0.0.0
|
||||
server.ip 192.168.3.124
|
||||
|
||||
##原生客户端长链接端口
|
||||
port 1883
|
||||
@@ -74,12 +74,24 @@ message.blacklist.strategy 0
|
||||
##是否禁止服务器端消息搜索,该功能暂未实现。目前的影响是如果打开,则存储消息时不单独保存_searchable_content字段
|
||||
message.disable_remote_search false
|
||||
|
||||
##允许客户端撤回消息时限,单位是秒。群组管理员或群主撤回群成员消息、server api不受此限制,可以撤回任意时限内的消息
|
||||
##允许客户端撤回用户自己发送的消息时限,单位是秒。群组管理员或群主撤回群成员消息、server api不受此限制,可以撤回任意时限内的消息
|
||||
message.recall_time_limit 120
|
||||
|
||||
##禁止群主/群管理员撤回群内消息,关闭时群主/群管理员可以撤回任意时间段内群内成员的消息,群主/群管理员撤回自己发送的消息还是会受到message.recall_time_limit时间限制。
|
||||
message.disable_group_manager_recall false
|
||||
|
||||
## 禁止客户端发送消息类型,消息类型以逗号分开,下面3个值为示例,可以删除。
|
||||
## 一般用于重要类型消息,比如交易、充值等,禁止客户端发送,仅限于服务器发送,提高安全性。
|
||||
message.forbidden_client_send_types 3999,4000,4001
|
||||
#message.forbidden_client_send_types 3999,4000,4001
|
||||
|
||||
## 当禁止发送消息时,允许例外发送的消息。这种一般用户需要被动回应的消息。比如群中被禁言的用户,他无法主动发起音视频,但可以接听未被禁言用户的音视频
|
||||
## 因为音视频使用了消息作为信令,所以就需要允许发送音视频信令。如果开发了其它场景也需要被动回应消息,可以加在这里。
|
||||
## 黑名单时允许发送的消息类型
|
||||
message.blacklist_exception_types 401,402,403,404,405,407,408,410,411
|
||||
## 群禁言或者聊天室或者频道禁言时允许发送的消息类型
|
||||
message.group_mute_exception_types 401,402,403,404,405,407,408,410,411
|
||||
## 用户被全局禁言时允许发送的消息类型
|
||||
message.global_mute_exception_types 401,402,403,404,405,407,408,410,411
|
||||
|
||||
##禁止搜索用户
|
||||
friend.disable_search false
|
||||
@@ -103,7 +115,7 @@ friend.request_expiration_duration 604800000
|
||||
##旧的方式会发送notification消息(contenttype是80),内容会根据好友接收者的语言选择对应的语言,如果双方语言不一致会导致另外一方看到的不是本地语言。
|
||||
##新的方式会发送添加好友消息(contenttype是93)和欢迎消息(contenttype是92),需要客户端实现这两种消息。
|
||||
##如果客户端已经实现这两种消息可以打开这个开关
|
||||
friend.new_welcome_message false
|
||||
friend.new_welcome_message true
|
||||
|
||||
## 聊天室观众空闲退出时间,单位为毫秒,默认为15分钟,0为永远不退出
|
||||
chatroom.participant_idle_time 900000
|
||||
@@ -123,6 +135,10 @@ group.visible_quit_or_kickoff_notification 0
|
||||
## 注意,修改本配置不会对已经同步的信息产生影响。
|
||||
#user.hide_properties 3,4,5
|
||||
|
||||
# 好友/好友请求/用户设置 这三类数据同步的最大条目数。之前是客户第一次登录时,会把所有的对应数据一次下载到客户端,但如果有特别多的信息,会导致无法同步到客户端,
|
||||
# 因此需要分段多次同步,此开关定义了每次同步的数据的条数。此需要客户端支持,客户端SDK在2021.5.25日后支持此功能。如果确认所有客户端都在这个日志之后才可以打开此设置。
|
||||
#sync.data_part_size 1000
|
||||
|
||||
#*********************************************************************
|
||||
# hazelcase configuration
|
||||
#*********************************************************************
|
||||
@@ -171,6 +187,11 @@ qiniu.bucket_favorite_domain http://cdn2.wildfirechat.cn
|
||||
# local media server configuration
|
||||
# 本地媒体服务器配置。
|
||||
local.media.storage.root media
|
||||
# 如果使用内置文件存储,文件上传后地址默认为 http://server.ip:http_port/fs/5/2021/03/27/08/filename。
|
||||
# 如果需要使用nginx添加https支持,请打开下面配置,这样客户端得到的文件地址为 https://example.com/media/fs/5/2021/03/27/08/filename。
|
||||
# 需要nginx把请求从https://example.com/media/fs 转到 http://server.ip:http_port/fs。注意需要带上所有header。
|
||||
# 尽管内置文件存储可以使用,但是我们还是建议使用专业级别的对象存储服务,社区版可以使用七牛,专业版另外支持阿里云和也是私有对象存储。详情请参考 https://docs.wildfirechat.cn/server/oss.html
|
||||
# local.media.storage.remote_server_url https://example.com/media
|
||||
|
||||
# 是否支持多端登陆,为true时支持任意平台任意多个客户端同时登录;为false时每个平台只支持一个端登录,但不同平台可以同时登录。
|
||||
server.multi_endpoint false
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
alter table `t_user_messages` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages` add column `_target` varchar(129) NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table `t_group_member` add column `_extra` TEXT DEFAULT NULL;
|
||||
alter table `t_friend_request` add column `_extra` TEXT DEFAULT NULL;
|
||||
+644
@@ -0,0 +1,644 @@
|
||||
alter table `t_user_messages` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_0` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_0` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_0` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_0` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_1` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_1` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_1` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_1` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_2` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_2` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_2` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_2` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_3` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_3` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_3` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_3` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_4` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_4` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_4` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_4` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_5` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_5` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_5` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_5` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_6` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_6` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_6` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_6` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_7` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_7` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_7` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_7` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_8` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_8` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_8` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_8` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_9` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_9` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_9` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_9` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_10` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_10` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_10` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_10` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_11` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_11` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_11` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_11` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_12` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_12` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_12` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_12` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_13` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_13` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_13` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_13` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_14` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_14` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_14` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_14` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_15` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_15` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_15` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_15` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_16` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_16` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_16` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_16` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_17` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_17` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_17` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_17` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_18` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_18` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_18` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_18` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_19` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_19` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_19` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_19` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_20` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_20` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_20` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_20` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_21` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_21` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_21` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_21` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_22` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_22` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_22` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_22` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_23` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_23` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_23` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_23` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_24` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_24` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_24` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_24` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_25` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_25` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_25` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_25` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_26` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_26` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_26` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_26` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_27` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_27` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_27` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_27` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_28` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_28` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_28` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_28` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_29` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_29` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_29` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_29` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_30` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_30` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_30` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_30` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_31` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_31` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_31` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_31` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_32` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_32` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_32` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_32` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_33` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_33` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_33` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_33` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_34` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_34` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_34` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_34` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_35` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_35` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_35` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_35` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_36` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_36` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_36` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_36` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_37` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_37` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_37` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_37` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_38` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_38` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_38` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_38` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_39` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_39` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_39` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_39` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_40` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_40` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_40` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_40` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_41` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_41` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_41` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_41` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_42` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_42` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_42` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_42` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_43` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_43` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_43` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_43` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_44` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_44` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_44` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_44` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_45` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_45` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_45` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_45` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_46` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_46` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_46` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_46` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_47` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_47` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_47` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_47` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_48` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_48` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_48` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_48` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_49` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_49` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_49` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_49` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_50` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_50` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_50` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_50` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_51` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_51` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_51` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_51` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_52` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_52` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_52` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_52` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_53` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_53` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_53` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_53` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_54` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_54` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_54` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_54` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_55` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_55` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_55` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_55` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_56` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_56` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_56` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_56` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_57` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_57` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_57` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_57` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_58` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_58` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_58` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_58` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_59` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_59` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_59` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_59` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_60` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_60` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_60` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_60` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_61` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_61` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_61` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_61` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_62` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_62` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_62` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_62` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_63` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_63` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_63` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_63` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_64` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_64` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_64` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_64` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_65` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_65` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_65` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_65` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_66` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_66` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_66` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_66` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_67` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_67` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_67` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_67` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_68` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_68` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_68` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_68` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_69` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_69` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_69` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_69` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_70` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_70` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_70` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_70` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_71` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_71` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_71` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_71` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_72` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_72` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_72` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_72` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_73` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_73` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_73` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_73` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_74` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_74` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_74` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_74` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_75` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_75` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_75` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_75` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_76` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_76` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_76` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_76` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_77` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_77` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_77` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_77` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_78` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_78` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_78` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_78` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_79` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_79` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_79` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_79` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_80` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_80` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_80` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_80` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_81` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_81` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_81` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_81` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_82` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_82` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_82` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_82` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_83` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_83` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_83` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_83` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_84` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_84` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_84` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_84` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_85` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_85` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_85` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_85` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_86` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_86` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_86` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_86` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_87` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_87` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_87` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_87` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_88` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_88` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_88` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_88` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_89` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_89` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_89` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_89` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_90` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_90` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_90` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_90` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_91` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_91` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_91` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_91` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_92` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_92` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_92` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_92` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_93` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_93` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_93` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_93` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_94` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_94` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_94` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_94` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_95` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_95` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_95` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_95` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_96` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_96` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_96` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_96` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_97` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_97` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_97` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_97` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_98` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_98` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_98` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_98` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_99` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_99` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_99` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_99` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_100` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_100` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_100` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_100` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_101` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_101` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_101` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_101` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_102` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_102` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_102` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_102` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_103` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_103` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_103` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_103` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_104` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_104` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_104` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_104` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_105` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_105` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_105` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_105` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_106` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_106` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_106` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_106` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_107` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_107` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_107` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_107` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_108` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_108` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_108` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_108` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_109` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_109` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_109` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_109` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_110` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_110` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_110` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_110` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_111` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_111` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_111` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_111` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_112` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_112` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_112` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_112` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_113` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_113` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_113` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_113` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_114` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_114` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_114` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_114` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_115` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_115` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_115` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_115` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_116` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_116` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_116` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_116` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_117` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_117` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_117` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_117` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_118` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_118` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_118` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_118` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_119` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_119` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_119` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_119` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_120` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_120` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_120` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_120` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_121` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_121` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_121` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_121` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_122` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_122` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_122` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_122` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_123` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_123` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_123` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_123` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_124` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_124` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_124` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_124` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_125` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_125` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_125` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_125` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_126` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_126` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_126` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_126` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
|
||||
alter table `t_user_messages_127` add column `_type` tinyint(4) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_127` add column `_target` varchar(129) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||
alter table `t_user_messages_127` add column `_directing` tinyint(1) NOT NULL DEFAULT '0';
|
||||
alter table `t_user_messages_127` add INDEX `user_messages_conv_index` ( `_uid`, `_type`, `_target`, `_line`, `_mid` desc);
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table `t_group_member` add column `_extra` TEXT DEFAULT NULL;
|
||||
alter table `t_friend_request` add column `_extra` TEXT DEFAULT NULL;
|
||||
+4
-4
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.57</version>
|
||||
<version>0.65</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>moquette-broker</artifactId>
|
||||
@@ -84,7 +84,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.4.1</version>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -118,7 +118,7 @@
|
||||
<dependency>
|
||||
<groupId>com.hazelcast</groupId>
|
||||
<artifactId>hazelcast</artifactId>
|
||||
<version>3.9.4</version>
|
||||
<version>3.11.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.xiaoleilu/hutool -->
|
||||
@@ -195,7 +195,7 @@
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
<version>2.7</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
|
||||
|
||||
@@ -43,7 +43,7 @@ public class PushMessage {
|
||||
this.cntType = messageContentType;
|
||||
this.serverTime = serverTime;
|
||||
this.unReceivedMsg = unReceivedMsg;
|
||||
if (cntType == 400) {
|
||||
if (cntType == 400 || cntType == 406) {
|
||||
this.pushMessageType = PushServer.PushMessageType.PUSH_MESSAGE_TYPE_VOIP_INVITE;
|
||||
} else if(cntType == 402) {
|
||||
this.pushMessageType = PushServer.PushMessageType.PUSH_MESSAGE_TYPE_VOIP_BYE;
|
||||
|
||||
@@ -38,6 +38,31 @@ abstract public class Action {
|
||||
public static ISessionsStore sessionsStore = null;
|
||||
|
||||
public ChannelHandlerContext ctx;
|
||||
protected class Result {
|
||||
Object data;
|
||||
ErrorCode errorCode;
|
||||
|
||||
public Result(ErrorCode errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public Result(ErrorCode errorCode, Object data) {
|
||||
this.data = data;
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public ErrorCode getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
|
||||
protected interface ApiCallback {
|
||||
Result onResult(byte[] response);
|
||||
}
|
||||
|
||||
public ErrorCode preAction(Request request, Response response) {
|
||||
if (getClass().getAnnotation(RequireAuthentication.class) != null) {
|
||||
@@ -93,4 +118,9 @@ abstract public class Action {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void setResponseContent(RestResult result, Response response) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,8 @@ 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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.ServerAPIHelper;
|
||||
import io.moquette.persistence.MemorySessionStore;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.moquette.spi.impl.Utils;
|
||||
import io.moquette.spi.impl.security.AES;
|
||||
import io.moquette.spi.security.Tokenor;
|
||||
@@ -80,7 +79,7 @@ public class IMAction extends Action {
|
||||
if (userId == null) {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TOKEN_ERROR, null);
|
||||
} else {
|
||||
RPCCenter.getInstance().sendRequest(userId, wrapper.getClientId(), wrapper.getRequest(), wrapper.getData().toByteArray(), userId, TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
ServerAPIHelper.sendRequest(userId, wrapper.getClientId(), wrapper.getRequest(), wrapper.getData().toByteArray(), new ServerAPIHelper.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
sendResponse(response, null, result);
|
||||
|
||||
@@ -15,8 +15,7 @@ import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.moquette.persistence.MemorySessionStore;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.moquette.persistence.ServerAPIHelper;
|
||||
import io.moquette.spi.impl.Utils;
|
||||
import io.moquette.spi.impl.security.AES;
|
||||
import io.moquette.spi.security.Tokenor;
|
||||
@@ -113,7 +112,7 @@ public class RouteAction extends Action {
|
||||
if (userId == null) {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TOKEN_ERROR, null, base64Response);
|
||||
} else {
|
||||
RPCCenter.getInstance().sendRequest(userId, wrapper.getClientId(), wrapper.getRequest(), wrapper.getData().toByteArray(), userId, TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
ServerAPIHelper.sendRequest(userId, wrapper.getClientId(), wrapper.getRequest(), wrapper.getData().toByteArray(), new ServerAPIHelper.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
sendResponse(response, null, result, base64Response);
|
||||
|
||||
@@ -201,7 +201,7 @@ public class UploadFileAction extends Action {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (remoteFileSize > 50 * 1024 * 1024) {
|
||||
if (remoteFileSize > 200 * 1024 * 1024) {
|
||||
logger.warn("file over limite!(" + remoteFileSize + ")");
|
||||
response.setStatus(HttpResponseStatus.BAD_REQUEST);
|
||||
response.setContent("file over limite!");
|
||||
|
||||
+5
-37
@@ -11,25 +11,17 @@ package com.xiaoleilu.loServer.action.admin;
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputAddFriendRequest;
|
||||
import cn.wildfirechat.pojos.InputUpdateAlias;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Friend_Send_Request)
|
||||
@HttpMethod("POST")
|
||||
public class AddFriendRequestAction extends AdminAction {
|
||||
@@ -50,35 +42,11 @@ public class AddFriendRequestAction extends AdminAction {
|
||||
}
|
||||
|
||||
WFCMessage.AddFriendRequest addFriendRequest = WFCMessage.AddFriendRequest.newBuilder().setReason(input.getReason()).setTargetUid(input.getFriendUid()).build();
|
||||
RPCCenter.getInstance().sendRequest(input.getUserId(), null, IMTopic.AddFriendRequestTopic, addFriendRequest.toByteArray(), input.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
sendApiMessage(response, input.getUserId(), IMTopic.AddFriendRequestTopic, addFriendRequest.toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
}, input.isForce());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -15,10 +15,8 @@ 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 cn.wildfirechat.pojos.InputAddGroupMember;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@@ -26,8 +24,6 @@ import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Group_Member_Add)
|
||||
@HttpMethod("POST")
|
||||
public class AddGroupMemberAction extends AdminAction {
|
||||
@@ -42,41 +38,15 @@ public class AddGroupMemberAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputAddGroupMember inputAddGroupMember = getRequestBody(request.getNettyRequest(), InputAddGroupMember.class);
|
||||
if (inputAddGroupMember.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputAddGroupMember.getOperator(), null, IMTopic.AddGroupMemberTopic, inputAddGroupMember.toProtoGroupRequest().toByteArray(), inputAddGroupMember.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, inputAddGroupMember.getOperator(), IMTopic.AddGroupMemberTopic, inputAddGroupMember.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.LoServer;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.Action;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.moquette.persistence.ServerAPIHelper;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
@@ -22,6 +22,8 @@ import org.slf4j.LoggerFactory;
|
||||
import win.liyufan.im.RateLimiter;
|
||||
import win.liyufan.im.Utility;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
abstract public class AdminAction extends Action {
|
||||
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(AdminAction.class);
|
||||
private static String SECRET_KEY = "123456";
|
||||
@@ -59,7 +61,7 @@ abstract public class AdminAction extends Action {
|
||||
}
|
||||
|
||||
if (StringUtil.isNullOrEmpty(nonce) || StringUtil.isNullOrEmpty(timestamp) || StringUtil.isNullOrEmpty(sign)) {
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
return ErrorCode.ERROR_CODE_API_NOT_SIGNED;
|
||||
}
|
||||
|
||||
Long ts;
|
||||
@@ -68,7 +70,7 @@ abstract public class AdminAction extends Action {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
return ErrorCode.ERROR_CODE_API_NOT_SIGNED;
|
||||
}
|
||||
|
||||
if (!NO_CHECK_TIME && System.currentTimeMillis() - ts > 2 * 60 * 60 * 1000) {
|
||||
@@ -90,4 +92,40 @@ abstract public class AdminAction extends Action {
|
||||
response.setContent(new Gson().toJson(result));
|
||||
response.send();
|
||||
}
|
||||
protected void sendApiMessage(Response response, String fromUser, String topic, byte[] message, ApiCallback callback) {
|
||||
sendApiMessage(response, fromUser, null, topic, message, callback, false);
|
||||
}
|
||||
|
||||
protected void sendApiMessage(Response response, String fromUser, String topic, byte[] message, ApiCallback callback, boolean noAdmin) {
|
||||
sendApiMessage(response, fromUser, null, topic, message, callback, noAdmin);
|
||||
}
|
||||
|
||||
protected void sendApiMessage(Response response, String fromUser, String clientId, String topic, byte[] message, ApiCallback callback, boolean noAdmin) {
|
||||
ServerAPIHelper.sendRequest(fromUser, clientId, topic, message, new ServerAPIHelper.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
if(callback != null) {
|
||||
Result r = callback.onResult(result);
|
||||
sendResponse(response, r.getErrorCode(), r.getData());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, !noAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputGetAlias;
|
||||
import cn.wildfirechat.pojos.InputGetFriendList;
|
||||
import cn.wildfirechat.pojos.OutputGetAlias;
|
||||
@@ -49,9 +50,8 @@ public class AliasGetAction extends AdminAction {
|
||||
break;
|
||||
}
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(out);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
setResponseContent(RestResult.ok(out), response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,7 @@ public class AliasPutAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputUpdateAlias input = getRequestBody(request.getNettyRequest(), InputUpdateAlias.class);
|
||||
ErrorCode errorCode = messagesStore.setFriendAliasRequest(input.getOperator(), input.getTargetId(), input.getAlias(), new long[1]);
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(errorCode);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(errorCode), response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ 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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@@ -27,8 +25,6 @@ import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Blacklist_Update_Status)
|
||||
@HttpMethod("POST")
|
||||
public class BlacklistAction extends AdminAction {
|
||||
@@ -47,39 +43,15 @@ public class BlacklistAction extends AdminAction {
|
||||
&& !StringUtil.isNullOrEmpty(inputData.getTargetUid())
|
||||
) {
|
||||
WFCMessage.BlackUserRequest friendRequest = WFCMessage.BlackUserRequest.newBuilder().setUid(inputData.getTargetUid()).setStatus(inputData.getStatus()).build();
|
||||
RPCCenter.getInstance().sendRequest(inputData.getUserId(), null, IMTopic.BlackListUserTopic, friendRequest.toByteArray(), inputData.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> ctx.executor().execute(command);
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, inputData.getUserId(), IMTopic.BlackListUserTopic, friendRequest.toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,9 +45,7 @@ public class BlacklistGetAction extends AdminAction {
|
||||
list.add(data.getFriendUid());
|
||||
}
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputStringList(list));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(new OutputStringList(list)), response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -14,10 +14,9 @@ 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 cn.wildfirechat.pojos.InputOutputUserBlockStatus;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.moquette.persistence.ServerAPIHelper;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
@@ -46,14 +45,12 @@ public class BlockUserAction extends AdminAction {
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
if (inputUserBlock.getStatus() == 2) {
|
||||
RPCCenter.getInstance().sendRequest(null, null, RPCCenter.KICKOFF_USER_REQUEST, inputUserBlock.getUserId().getBytes(), inputUserBlock.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, null, true);
|
||||
sendApiMessage(response, null, ServerAPIHelper.KICKOFF_USER_REQUEST, inputUserBlock.getUserId().getBytes(), null);
|
||||
}
|
||||
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SUCCESS, null);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
-40
@@ -13,8 +13,6 @@ import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.BroadMessageData;
|
||||
import cn.wildfirechat.pojos.BroadMessageResult;
|
||||
import cn.wildfirechat.pojos.SendMessageData;
|
||||
import cn.wildfirechat.pojos.SendMessageResult;
|
||||
import com.google.gson.Gson;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -22,16 +20,12 @@ 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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Msg_Broadcast)
|
||||
@HttpMethod("POST")
|
||||
public class BroadcastMessageAction extends AdminAction {
|
||||
@@ -46,43 +40,21 @@ public class BroadcastMessageAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
BroadMessageData sendMessageData = getRequestBody(request.getNettyRequest(), BroadMessageData.class);
|
||||
if (BroadMessageData.isValide(sendMessageData) && !StringUtil.isNullOrEmpty(sendMessageData.getSender())) {
|
||||
RPCCenter.getInstance().sendRequest(sendMessageData.getSender(), null, IMTopic.BroadcastMessageTopic, sendMessageData.toProtoMessage().toByteArray(), sendMessageData.getSender(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long count = byteBuf.readLong();
|
||||
sendResponse(response, null, new BroadMessageResult(messageId, count));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
sendApiMessage(response, sendMessageData.getSender(), IMTopic.BroadcastMessageTopic, sendMessageData.toProtoMessage().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long count = byteBuf.readLong();
|
||||
return new Result(errorCode, new BroadMessageResult(messageId, count));
|
||||
} else {
|
||||
return new Result(errorCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+6
-34
@@ -9,26 +9,18 @@
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.pojos.BroadMessageResult;
|
||||
import cn.wildfirechat.pojos.OutputCheckUserOnline;
|
||||
import com.google.gson.Gson;
|
||||
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 cn.wildfirechat.pojos.InputGetUserInfo;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.moquette.persistence.ServerAPIHelper;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.User_Get_Online_Status)
|
||||
@HttpMethod("POST")
|
||||
public class CheckUserOnlineAction extends AdminAction {
|
||||
@@ -43,30 +35,10 @@ public class CheckUserOnlineAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputGetUserInfo inputUserId = getRequestBody(request.getNettyRequest(), InputGetUserInfo.class);
|
||||
if (inputUserId == null || !StringUtil.isNullOrEmpty(inputUserId.getUserId())) {
|
||||
RPCCenter.getInstance().sendRequest(null, null, RPCCenter.CHECK_USER_ONLINE_REQUEST, inputUserId.getUserId().getBytes(), inputUserId.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] res) {
|
||||
OutputCheckUserOnline out = new Gson().fromJson(new String(res), OutputCheckUserOnline.class);
|
||||
sendResponse(response, null, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, inputUserId.getUserId(), ServerAPIHelper.CHECK_USER_ONLINE_REQUEST, inputUserId.getUserId().getBytes(), res -> {
|
||||
OutputCheckUserOnline out = new Gson().fromJson(new String(res), OutputCheckUserOnline.class);
|
||||
return new Result(ErrorCode.ERROR_CODE_SUCCESS, out);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
sendResponse(response, ErrorCode.INVALID_PARAMETER, null);
|
||||
|
||||
@@ -11,24 +11,18 @@ package com.xiaoleilu.loServer.action.admin;
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.*;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.IMTopic;
|
||||
import win.liyufan.im.UUIDGenerator;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Create_Channel)
|
||||
@HttpMethod("POST")
|
||||
@@ -52,44 +46,22 @@ public class CreateChannelAction extends AdminAction {
|
||||
inputCreateChannel.setTargetId(messagesStore.getShortUUID());
|
||||
}
|
||||
|
||||
RPCCenter.getInstance().sendRequest(inputCreateChannel.getOwner(), null, IMTopic.CreateChannelTopic, inputCreateChannel.toProtoChannelInfo().toByteArray(), inputCreateChannel.getOwner(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
byte[] data = new byte[byteBuf.readableBytes()];
|
||||
byteBuf.readBytes(data);
|
||||
String channelId = new String(data);
|
||||
sendResponse(response, null, new OutputCreateChannel(channelId));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
sendApiMessage(response, inputCreateChannel.getOwner(), IMTopic.CreateChannelTopic, inputCreateChannel.toProtoChannelInfo().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
byte[] data = new byte[byteBuf.readableBytes()];
|
||||
byteBuf.readBytes(data);
|
||||
String channelId = new String(data);
|
||||
return new Result(ErrorCode.ERROR_CODE_SUCCESS, new OutputCreateChannel(channelId));
|
||||
} else {
|
||||
return new Result(errorCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,17 +53,10 @@ public class CreateChatroomAction extends AdminAction {
|
||||
}
|
||||
|
||||
WFCMessage.ChatroomInfo info = inputCreateChatroom.toChatroomInfo();
|
||||
|
||||
messagesStore.createChatroom(inputCreateChatroom.getChatroomId(), info);
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputCreateChatroom(inputCreateChatroom.getChatroomId()));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
setResponseContent(RestResult.ok(new OutputCreateChatroom(inputCreateChatroom.getChatroomId())), response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,11 +15,9 @@ 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 cn.wildfirechat.pojos.InputCreateGroup;
|
||||
import cn.wildfirechat.pojos.OutputCreateGroupResult;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@@ -27,8 +25,6 @@ import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Create_Group)
|
||||
@HttpMethod("POST")
|
||||
public class CreateGroupAction extends AdminAction {
|
||||
@@ -43,44 +39,22 @@ public class CreateGroupAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputCreateGroup inputCreateGroup = getRequestBody(request.getNettyRequest(), InputCreateGroup.class);
|
||||
if (inputCreateGroup.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputCreateGroup.getOperator(), null, IMTopic.CreateGroupTopic, inputCreateGroup.toProtoGroupRequest().toByteArray(), inputCreateGroup.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
byte[] data = new byte[byteBuf.readableBytes()];
|
||||
byteBuf.readBytes(data);
|
||||
String groupId = new String(data);
|
||||
sendResponse(response, null, new OutputCreateGroupResult(groupId));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
sendApiMessage(response, inputCreateGroup.getOperator(), IMTopic.CreateGroupTopic, inputCreateGroup.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
byte[] data = new byte[byteBuf.readableBytes()];
|
||||
byteBuf.readBytes(data);
|
||||
String groupId = new String(data);
|
||||
return new Result(ErrorCode.ERROR_CODE_SUCCESS, new OutputCreateGroupResult(groupId));
|
||||
} else {
|
||||
return new Result(errorCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -78,16 +78,10 @@ public class CreateRobotAction extends AdminAction {
|
||||
if (StringUtil.isNullOrEmpty(inputCreateRobot.getSecret())) {
|
||||
inputCreateRobot.setSecret(UUIDGenerator.getUUID());
|
||||
}
|
||||
|
||||
messagesStore.addRobot(inputCreateRobot.toRobot());
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputCreateRobot(inputCreateRobot.getUserId(), inputCreateRobot.getSecret()));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(new OutputCreateRobot(inputCreateRobot.getUserId(), inputCreateRobot.getSecret())), response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -89,19 +89,13 @@ public class CreateUserAction extends AdminAction {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e, IMExceptionEvent.EventType.ADMIN_API_Exception);
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.ERROR_CODE_SERVER_ERROR, e.getMessage());
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.ERROR_CODE_SERVER_ERROR, e.getMessage()), response);
|
||||
return true;
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputCreateUser(inputCreateUser.getUserId(), inputCreateUser.getName()));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(new OutputCreateUser(inputCreateUser.getUserId(), inputCreateUser.getName())), response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,17 +41,10 @@ public class DestoryChatroomAction extends AdminAction {
|
||||
InputDestoryChatroom inputDestoryChatroom = gson.fromJson(content, InputDestoryChatroom.class);
|
||||
if (inputDestoryChatroom != null
|
||||
&& !StringUtil.isNullOrEmpty(inputDestoryChatroom.getChatroomId())) {
|
||||
|
||||
messagesStore.destoryChatroom(inputDestoryChatroom.getChatroomId());
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok();
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
setResponseContent(RestResult.ok(), response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,9 +11,6 @@ package com.xiaoleilu.loServer.action.admin;
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputDestroyUser;
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.pojos.OutputCreateUser;
|
||||
import cn.wildfirechat.pojos.OutputGetIMTokenData;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -21,16 +18,12 @@ 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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.IMTopic;
|
||||
import win.liyufan.im.UUIDGenerator;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Destroy_User)
|
||||
@HttpMethod("POST")
|
||||
@@ -49,46 +42,13 @@ public class DestroyUserAction extends AdminAction {
|
||||
&& !StringUtil.isNullOrEmpty(inputDestroyUser.getUserId())) {
|
||||
|
||||
WFCMessage.IDBuf idBuf = WFCMessage.IDBuf.newBuilder().setId(inputDestroyUser.getUserId()).build();
|
||||
RPCCenter.getInstance().sendRequest(inputDestroyUser.getUserId(), null, IMTopic.DestroyUserTopic, idBuf.toByteArray(), inputDestroyUser.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ErrorCode errorCode1 = ErrorCode.fromCode(result[0]);
|
||||
if (errorCode1 == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
//ba errorcode qudiao
|
||||
byte[] data = new byte[result.length -1];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = result[i+1];
|
||||
}
|
||||
String token = Base64.getEncoder().encodeToString(data);
|
||||
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode1, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, inputDestroyUser.getUserId(), IMTopic.DestroyUserTopic, idBuf.toByteArray(), result -> {
|
||||
ErrorCode errorCode1 = ErrorCode.fromCode(result[0]);
|
||||
return new Result(errorCode1);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,10 +15,8 @@ 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 cn.wildfirechat.pojos.InputDismissGroup;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@@ -26,8 +24,6 @@ import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Group_Dismiss)
|
||||
@HttpMethod("POST")
|
||||
public class DismissGroupAction extends AdminAction {
|
||||
@@ -42,41 +38,15 @@ public class DismissGroupAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputDismissGroup inputDismissGroup = getRequestBody(request.getNettyRequest(), InputDismissGroup.class);
|
||||
if (inputDismissGroup.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputDismissGroup.getOperator(), null, IMTopic.DismissGroupTopic, inputDismissGroup.toProtoGroupRequest().toByteArray(), inputDismissGroup.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, inputDismissGroup.getOperator(), IMTopic.DismissGroupTopic, inputDismissGroup.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -15,10 +15,8 @@ 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 cn.wildfirechat.pojos.InputUpdateFriendStatusRequest;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@@ -27,8 +25,6 @@ import io.netty.util.internal.StringUtil;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Friend_Update_Status)
|
||||
@HttpMethod("POST")
|
||||
public class FriendRelationAction extends AdminAction {
|
||||
@@ -50,39 +46,15 @@ public class FriendRelationAction extends AdminAction {
|
||||
if (!StringUtil.isNullOrEmpty(friendAdd.getExtra())) {
|
||||
friendRequestBuilder = friendRequestBuilder.setExtra(friendAdd.getExtra());
|
||||
}
|
||||
RPCCenter.getInstance().sendRequest(friendAdd.getUserId(), null, IMTopic.HandleFriendRequestTopic, friendRequestBuilder.build().toByteArray(), friendAdd.getFriendUid(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> ctx.executor().execute(command);
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, friendAdd.getUserId(), IMTopic.HandleFriendRequestTopic, friendRequestBuilder.build().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-3
@@ -47,9 +47,7 @@ public class FriendRelationGetAction extends AdminAction {
|
||||
list.add(data.getFriendUid());
|
||||
}
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputStringList(list));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(new OutputStringList(list)), response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,14 +46,9 @@ public class GetChatroomInfoAction extends AdminAction {
|
||||
} else {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-7
@@ -58,14 +58,9 @@ public class GetChatroomMembersAction extends AdminAction {
|
||||
} else {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,8 +42,6 @@ public class GetGroupInfoAction extends AdminAction {
|
||||
&& (!StringUtil.isNullOrEmpty(inputGetGroup.getGroupId()))) {
|
||||
|
||||
WFCMessage.GroupInfo groupInfo = messagesStore.getGroupInfo(inputGetGroup.getGroupId());
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (groupInfo == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
@@ -55,14 +53,15 @@ public class GetGroupInfoAction extends AdminAction {
|
||||
pojoGroupInfo.setPortrait(groupInfo.getPortrait());
|
||||
pojoGroupInfo.setTarget_id(groupInfo.getTargetId());
|
||||
pojoGroupInfo.setType(groupInfo.getType());
|
||||
pojoGroupInfo.setMute(groupInfo.getMute());
|
||||
pojoGroupInfo.setJoin_type(groupInfo.getJoinType());
|
||||
pojoGroupInfo.setPrivate_chat(groupInfo.getPrivateChat());
|
||||
pojoGroupInfo.setSearchable(groupInfo.getSearchable());
|
||||
result = RestResult.ok(pojoGroupInfo);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,8 +48,6 @@ public class GetGroupMembersAction extends AdminAction {
|
||||
List<WFCMessage.GroupMember> members = new ArrayList<>();
|
||||
ErrorCode errorCode = messagesStore.getGroupMembers(null, inputGetGroup.getGroupId(), 0, members);
|
||||
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
result = RestResult.resultOf(errorCode);
|
||||
@@ -64,16 +62,15 @@ public class GetGroupMembersAction extends AdminAction {
|
||||
pm.setMember_id(member.getMemberId());
|
||||
pm.setAlias(member.getAlias());
|
||||
pm.setType(member.getType());
|
||||
pm.setExtra(member.getExtra());
|
||||
out.getMembers().add(pm);
|
||||
}
|
||||
result = RestResult.ok(out);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,17 +13,14 @@ import cn.wildfirechat.proto.WFCMessage;
|
||||
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 cn.wildfirechat.pojos.InputGetToken;
|
||||
import cn.wildfirechat.pojos.OutputGetIMTokenData;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.User_Get_Token)
|
||||
@HttpMethod("POST")
|
||||
@@ -42,41 +39,21 @@ public class GetIMTokenAction extends AdminAction {
|
||||
|
||||
|
||||
WFCMessage.GetTokenRequest getTokenRequest = WFCMessage.GetTokenRequest.newBuilder().setUserId(userId).setClientId(input.getClientId()).setPlatform(input.getPlatform() == null ? 0 : input.getPlatform()).build();
|
||||
RPCCenter.getInstance().sendRequest(userId, input.getClientId(), IMTopic.GetTokenTopic, getTokenRequest.toByteArray(), userId, TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ErrorCode errorCode1 = ErrorCode.fromCode(result[0]);
|
||||
if (errorCode1 == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
//ba errorcode qudiao
|
||||
byte[] data = new byte[result.length -1];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = result[i+1];
|
||||
}
|
||||
String token = Base64.getEncoder().encodeToString(data);
|
||||
|
||||
sendResponse(response, null, new OutputGetIMTokenData(userId, token));
|
||||
} else {
|
||||
sendResponse(response, errorCode1, null);
|
||||
sendApiMessage(response, userId, input.getClientId(), IMTopic.GetTokenTopic, getTokenRequest.toByteArray(), result -> {
|
||||
ErrorCode errorCode1 = ErrorCode.fromCode(result[0]);
|
||||
if (errorCode1 == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
//ba errorcode qudiao
|
||||
byte[] data = new byte[result.length -1];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = result[i+1];
|
||||
}
|
||||
}
|
||||
String token = Base64.getEncoder().encodeToString(data);
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
return new Result(errorCode1, new OutputGetIMTokenData(userId, token));
|
||||
} else {
|
||||
return new Result(errorCode1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
}, false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
+2
-5
@@ -40,7 +40,6 @@ public class GetSystemSettingAction extends AdminAction {
|
||||
if (inputUserId != null) {
|
||||
SystemSettingPojo output = messagesStore.getSystemSetting(inputUserId.id);
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (output == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
@@ -48,11 +47,9 @@ public class GetSystemSettingAction extends AdminAction {
|
||||
result = RestResult.ok(output);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@ public class GetUserAction extends AdminAction {
|
||||
user = messagesStore.getUserInfoByMobile(inputUserId.getMobile());
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (user == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
@@ -56,11 +55,9 @@ public class GetUserAction extends AdminAction {
|
||||
result = RestResult.ok(InputOutputUserInfo.fromPbUser(user));
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-2
@@ -31,11 +31,10 @@ public class GetUserBlockListAction extends AdminAction {
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
OutputUserBlockStatusList list = new OutputUserBlockStatusList();
|
||||
list.setStatusList(messagesStore.getUserStatusList());
|
||||
RestResult result = RestResult.ok(list);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result, response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-6
@@ -39,13 +39,9 @@ public class GetUserBlockStatusAction extends AdminAction {
|
||||
&& !StringUtil.isNullOrEmpty(inputUserId.getUserId())) {
|
||||
|
||||
int status = messagesStore.getUserStatus(inputUserId.getUserId());
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputUserStatus(status));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(new OutputUserStatus(status)), response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,16 +45,12 @@ public class GetUserGroupsAction extends AdminAction {
|
||||
&& (!StringUtil.isNullOrEmpty(inputUserId.getUserId()))) {
|
||||
|
||||
Set<String> groupIds = messagesStore.getUserGroupIds(inputUserId.getUserId());
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
OutputGroupIds outputGroupIds = new OutputGroupIds();
|
||||
outputGroupIds.setGroupIds(new ArrayList<>(groupIds));
|
||||
RestResult result = RestResult.ok(outputGroupIds);
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-38
@@ -15,10 +15,8 @@ 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 cn.wildfirechat.pojos.InputKickoffGroupMember;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@@ -26,8 +24,6 @@ import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Group_Member_Kickoff)
|
||||
@HttpMethod("POST")
|
||||
public class KickoffGroupMemberAction extends AdminAction {
|
||||
@@ -42,41 +38,15 @@ public class KickoffGroupMemberAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputKickoffGroupMember inputKickoffGroupMember = getRequestBody(request.getNettyRequest(), InputKickoffGroupMember.class);
|
||||
if (inputKickoffGroupMember.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputKickoffGroupMember.getOperator(), null, IMTopic.KickoffGroupMemberTopic, inputKickoffGroupMember.toProtoGroupRequest().toByteArray(), inputKickoffGroupMember.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, inputKickoffGroupMember.getOperator(), IMTopic.KickoffGroupMemberTopic, inputKickoffGroupMember.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+1
-6
@@ -10,7 +10,6 @@ package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputOutputUserBlockStatus;
|
||||
import cn.wildfirechat.pojos.StringPairPojo;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -18,8 +17,6 @@ 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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
@@ -41,9 +38,7 @@ public class KickoffUserClientAction extends AdminAction {
|
||||
sessionsStore.kickoffUserClient(pojo.getFirst(), pojo.getSecond());
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SUCCESS, null);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-38
@@ -11,7 +11,6 @@ package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputAddGroupMember;
|
||||
import cn.wildfirechat.pojos.InputModifyGroupInfo;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -19,16 +18,12 @@ 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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Group_Modify_Info)
|
||||
@HttpMethod("POST")
|
||||
public class ModifyGroupInfoAction extends AdminAction {
|
||||
@@ -43,41 +38,15 @@ public class ModifyGroupInfoAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputModifyGroupInfo inputAddGroupMember = getRequestBody(request.getNettyRequest(), InputModifyGroupInfo.class);
|
||||
if (inputAddGroupMember.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputAddGroupMember.getOperator(), null, IMTopic.ModifyGroupInfoTopic, inputAddGroupMember.toProtoGroupRequest().toByteArray(), inputAddGroupMember.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, inputAddGroupMember.getOperator(), IMTopic.ModifyGroupInfoTopic, inputAddGroupMember.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+7
-38
@@ -11,7 +11,6 @@ package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputKickoffGroupMember;
|
||||
import cn.wildfirechat.pojos.InputSetGroupMemberAlias;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -19,16 +18,12 @@ 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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Group_Set_Member_Alias)
|
||||
@HttpMethod("POST")
|
||||
public class ModifyGroupMemberAliasAction extends AdminAction {
|
||||
@@ -43,41 +38,15 @@ public class ModifyGroupMemberAliasAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputSetGroupMemberAlias inputSetGroupMemberAlias = getRequestBody(request.getNettyRequest(), InputSetGroupMemberAlias.class);
|
||||
if (inputSetGroupMemberAlias.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputSetGroupMemberAlias.getOperator(), null, IMTopic.ModifyGroupMemberAliasTopic, inputSetGroupMemberAlias.toProtoGroupRequest().toByteArray(), inputSetGroupMemberAlias.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, inputSetGroupMemberAlias.getOperator(), IMTopic.ModifyGroupMemberAliasTopic, inputSetGroupMemberAlias.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+12
-41
@@ -11,27 +11,20 @@ package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.BroadMessageData;
|
||||
import cn.wildfirechat.pojos.BroadMessageResult;
|
||||
import cn.wildfirechat.pojos.MultiMessageResult;
|
||||
import cn.wildfirechat.pojos.MulticastMessageData;
|
||||
import com.google.gson.Gson;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Msg_Multicast)
|
||||
@HttpMethod("POST")
|
||||
public class MulticastMessageAction extends AdminAction {
|
||||
@@ -46,43 +39,21 @@ public class MulticastMessageAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
MulticastMessageData sendMessageData = getRequestBody(request.getNettyRequest(), MulticastMessageData.class);
|
||||
if (MulticastMessageData.isValide(sendMessageData)) {
|
||||
RPCCenter.getInstance().sendRequest(sendMessageData.getSender(), null, IMTopic.MultiCastMessageTopic, sendMessageData.toProtoMessage().toByteArray(), sendMessageData.getSender(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long timestamp = byteBuf.readLong();
|
||||
sendResponse(response, null, new MultiMessageResult(messageId, timestamp));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
sendApiMessage(response, sendMessageData.getSender(), IMTopic.MultiCastMessageTopic, sendMessageData.toProtoMessage().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long timestamp = byteBuf.readLong();
|
||||
return new Result(errorCode, new MultiMessageResult(messageId, timestamp));
|
||||
} else {
|
||||
return new Result(errorCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+2
-8
@@ -40,22 +40,16 @@ public class PutSystemSettingAction extends AdminAction {
|
||||
if (inputUserId != null
|
||||
&& (!StringUtil.isNullOrEmpty(inputUserId.value) || !StringUtil.isNullOrEmpty(inputUserId.desc))) {
|
||||
|
||||
|
||||
boolean success = messagesStore.updateSystemSetting(inputUserId.id, inputUserId.value, inputUserId.desc);
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (!success) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_SERVER_ERROR);
|
||||
} else {
|
||||
result = RestResult.ok();
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-38
@@ -11,7 +11,6 @@ package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputKickoffGroupMember;
|
||||
import cn.wildfirechat.pojos.InputQuitGroup;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -19,16 +18,12 @@ 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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Group_Member_Quit)
|
||||
@HttpMethod("POST")
|
||||
public class QuitGroupMemberAction extends AdminAction {
|
||||
@@ -43,41 +38,15 @@ public class QuitGroupMemberAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputQuitGroup inputQuitGroup = getRequestBody(request.getNettyRequest(), InputQuitGroup.class);
|
||||
if (inputQuitGroup.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputQuitGroup.getOperator(), null, IMTopic.QuitGroupTopic, inputQuitGroup.toProtoGroupRequest().toByteArray(), inputQuitGroup.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, inputQuitGroup.getOperator(), IMTopic.QuitGroupTopic, inputQuitGroup.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -15,10 +15,8 @@ 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 cn.wildfirechat.pojos.RecallMessageData;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@@ -27,8 +25,6 @@ import io.netty.util.internal.StringUtil;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Msg_Recall)
|
||||
@HttpMethod("POST")
|
||||
public class RecallMessageAction extends AdminAction {
|
||||
@@ -45,37 +41,15 @@ public class RecallMessageAction extends AdminAction {
|
||||
if (recallMessageData != null && !StringUtil.isNullOrEmpty(recallMessageData.getOperator())) {
|
||||
|
||||
WFCMessage.INT64Buf idBuf = WFCMessage.INT64Buf.newBuilder().setId(recallMessageData.getMessageUid()).build();
|
||||
RPCCenter.getInstance().sendRequest(recallMessageData.getOperator(), null, IMTopic.RecallMessageTopic, idBuf.toByteArray(), recallMessageData.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, recallMessageData.getOperator(), IMTopic.RecallMessageTopic, idBuf.toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+7
-34
@@ -10,7 +10,6 @@ package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.RecallMessageData;
|
||||
import cn.wildfirechat.pojos.RecallMultiCastMessageData;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
@@ -19,8 +18,6 @@ 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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@@ -28,8 +25,6 @@ import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Msg_RecallMultiCast)
|
||||
@HttpMethod("POST")
|
||||
public class RecallMultiCastMessageAction extends AdminAction {
|
||||
@@ -46,37 +41,15 @@ public class RecallMultiCastMessageAction extends AdminAction {
|
||||
if (recallMessageData != null && !StringUtil.isNullOrEmpty(recallMessageData.operator)) {
|
||||
|
||||
WFCMessage.RecallMultiCastMessageRequest recallRequest = WFCMessage.RecallMultiCastMessageRequest.newBuilder().setMessageId(recallMessageData.messageUid).addAllReceiver(recallMessageData.receivers).build();
|
||||
RPCCenter.getInstance().sendRequest(recallMessageData.operator, null, IMTopic.RecallMultiCastMessageTopic, recallRequest.toByteArray(), recallMessageData.operator, TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, recallMessageData.operator, IMTopic.RecallMultiCastMessageTopic, recallRequest.toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -51,10 +51,7 @@ public class RelationGetAction extends AdminAction {
|
||||
out.alias = data.getAlias();
|
||||
out.extra = data.getExtra();
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(out);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(out), response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,11 +16,9 @@ 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 cn.wildfirechat.pojos.SendMessageData;
|
||||
import cn.wildfirechat.pojos.SendMessageResult;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@@ -28,8 +26,6 @@ import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Msg_Send)
|
||||
@HttpMethod("POST")
|
||||
public class SendMessageAction extends AdminAction {
|
||||
@@ -44,43 +40,21 @@ public class SendMessageAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
SendMessageData sendMessageData = getRequestBody(request.getNettyRequest(), SendMessageData.class);
|
||||
if (SendMessageData.isValide(sendMessageData) && !StringUtil.isNullOrEmpty(sendMessageData.getSender())) {
|
||||
RPCCenter.getInstance().sendRequest(sendMessageData.getSender(), null, IMTopic.SendMessageTopic, sendMessageData.toProtoMessage().toByteArray(), sendMessageData.getSender(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long timestamp = byteBuf.readLong();
|
||||
sendResponse(response, null, new SendMessageResult(messageId, timestamp));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
sendApiMessage(response, sendMessageData.getSender(), IMTopic.SendMessageTopic, sendMessageData.toProtoMessage().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long timestamp = byteBuf.readLong();
|
||||
return new Result(errorCode, new SendMessageResult(messageId, timestamp));
|
||||
} else {
|
||||
return new Result(errorCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+1
-3
@@ -38,9 +38,7 @@ public class SensitiveWordAddAction extends AdminAction {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
sendResponse(response, errorCode, null);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-3
@@ -39,9 +39,7 @@ public class SensitiveWordDeleteAction extends AdminAction {
|
||||
|
||||
sendResponse(response, errorCode, null);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-38
@@ -11,7 +11,6 @@ package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputAddGroupMember;
|
||||
import cn.wildfirechat.pojos.InputSetGroupManager;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -19,16 +18,12 @@ 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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Group_Set_Manager)
|
||||
@HttpMethod("POST")
|
||||
public class SetGroupManagerAction extends AdminAction {
|
||||
@@ -43,41 +38,15 @@ public class SetGroupManagerAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputSetGroupManager inputAddGroupMember = getRequestBody(request.getNettyRequest(), InputSetGroupManager.class);
|
||||
if (inputAddGroupMember.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputAddGroupMember.getOperator(), null, IMTopic.SetGroupManagerTopic, inputAddGroupMember.toProtoGroupRequest().toByteArray(), inputAddGroupMember.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, inputAddGroupMember.getOperator(), IMTopic.SetGroupManagerTopic, inputAddGroupMember.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -15,10 +15,8 @@ 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 cn.wildfirechat.pojos.InputTransferGroup;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@@ -26,8 +24,6 @@ import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Group_Transfer)
|
||||
@HttpMethod("POST")
|
||||
public class TransferGroupAction extends AdminAction {
|
||||
@@ -42,41 +38,15 @@ public class TransferGroupAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputTransferGroup inputDismissGroup = getRequestBody(request.getNettyRequest(), InputTransferGroup.class);
|
||||
if (inputDismissGroup.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputDismissGroup.getOperator(), null, IMTopic.TransferGroupTopic, inputDismissGroup.toProtoGroupRequest().toByteArray(), inputDismissGroup.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
sendApiMessage(response, inputDismissGroup.getOperator(), IMTopic.TransferGroupTopic, inputDismissGroup.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -50,13 +50,9 @@ public class UpdateUserAction extends AdminAction {
|
||||
&& inputCreateUser.flag > 0) {
|
||||
|
||||
ErrorCode errorCode = messagesStore.updateUserInfo(inputCreateUser.userInfo, inputCreateUser.flag);
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(errorCode);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(errorCode), response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.Action;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.moquette.persistence.ServerAPIHelper;
|
||||
import io.moquette.spi.impl.Utils;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
@@ -26,11 +27,17 @@ import org.slf4j.LoggerFactory;
|
||||
import win.liyufan.im.RateLimiter;
|
||||
import win.liyufan.im.Utility;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
abstract public class ChannelAction extends Action {
|
||||
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(ChannelAction.class);
|
||||
private final RateLimiter mLimitCounter = new RateLimiter(10, 200);
|
||||
protected WFCMessage.ChannelInfo channelInfo;
|
||||
|
||||
protected interface Callback {
|
||||
void onSuccess(byte[] response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode preAction(Request request, Response response) {
|
||||
String nonce = request.getHeader("nonce");
|
||||
@@ -51,7 +58,7 @@ abstract public class ChannelAction extends Action {
|
||||
}
|
||||
|
||||
if (StringUtil.isNullOrEmpty(nonce) || StringUtil.isNullOrEmpty(timestamp) || StringUtil.isNullOrEmpty(sign) || StringUtil.isNullOrEmpty(cid)) {
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
return ErrorCode.ERROR_CODE_API_NOT_SIGNED;
|
||||
}
|
||||
|
||||
if (!mLimitCounter.isGranted(cid)) {
|
||||
@@ -64,7 +71,7 @@ abstract public class ChannelAction extends Action {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e, IMExceptionEvent.EventType.CHANNEL_API_Exception);
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
return ErrorCode.ERROR_CODE_API_NOT_SIGNED;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() - ts > 2 * 60 * 60 * 1000) {
|
||||
@@ -107,4 +114,32 @@ abstract public class ChannelAction extends Action {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void sendApiMessage(Response response, String topic, byte[] message, Callback callback) {
|
||||
sendApiMessage(response, channelInfo.getOwner(), topic, message, callback);
|
||||
}
|
||||
protected void sendApiMessage(Response response, String user, String topic, byte[] message, Callback callback) {
|
||||
ServerAPIHelper.sendRequest(user, null, topic, message, new ServerAPIHelper.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] response) {
|
||||
callback.onSuccess(response);
|
||||
}
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.channel;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputGetUserInfo;
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.pojos.OutputGetChannelInfo;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
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.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
@Route(APIPath.Channel_Get_Profile)
|
||||
@HttpMethod("POST")
|
||||
public class GetChannelAction extends ChannelAction {
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
setResponseContent(RestResult.ok(OutputGetChannelInfo.fromPbInfo(channelInfo)), response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.channel;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputGetUserInfo;
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.pojos.OutputStringList;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
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.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Route(APIPath.Channel_Subscriber_List)
|
||||
@HttpMethod("POST")
|
||||
public class GetChannelSubscribersAction extends ChannelAction {
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
OutputStringList outputStringList = new OutputStringList();
|
||||
outputStringList.setList(new ArrayList<>());
|
||||
outputStringList.getList().addAll(messagesStore.getChannelSubscriber(channelInfo.getTargetId()));
|
||||
setResponseContent(RestResult.ok(outputStringList), response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.channel;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputGetUserInfo;
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.admin.AdminAction;
|
||||
import com.xiaoleilu.loServer.action.robot.RobotAction;
|
||||
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.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
@Route(APIPath.Channel_User_Info)
|
||||
@HttpMethod("POST")
|
||||
public class GetUserAction extends ChannelAction {
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputGetUserInfo inputUserId = getRequestBody(request.getNettyRequest(), InputGetUserInfo.class);
|
||||
if (inputUserId != null
|
||||
&& (!StringUtil.isNullOrEmpty(inputUserId.getUserId()) || !StringUtil.isNullOrEmpty(inputUserId.getName()) || !StringUtil.isNullOrEmpty(inputUserId.getMobile()))) {
|
||||
|
||||
WFCMessage.User user = null;
|
||||
if(!StringUtil.isNullOrEmpty(inputUserId.getUserId())) {
|
||||
user = messagesStore.getUserInfo(inputUserId.getUserId());
|
||||
} else if(!StringUtil.isNullOrEmpty(inputUserId.getName())) {
|
||||
user = messagesStore.getUserInfoByName(inputUserId.getName());
|
||||
} else if(!StringUtil.isNullOrEmpty(inputUserId.getMobile())) {
|
||||
user = messagesStore.getUserInfoByMobile(inputUserId.getMobile());
|
||||
}
|
||||
|
||||
RestResult result;
|
||||
|
||||
if (user == null || StringUtil.isNullOrEmpty(user.getName())) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
} else {
|
||||
if (channelInfo.getOwner().equals(inputUserId.getUserId()) ||
|
||||
messagesStore.checkUserInChannel(user.getUid(), channelInfo.getTargetId())) {
|
||||
if((channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_FullInfo) > 0) {
|
||||
result = RestResult.ok(InputOutputUserInfo.fromPbUser(user));
|
||||
} else {
|
||||
WFCMessage.User outUser = WFCMessage.User.newBuilder().setUid(user.getUid()).setName(user.getName()).setPortrait(user.getPortrait()).setDisplayName(user.getDisplayName()).build();
|
||||
result = RestResult.ok(InputOutputUserInfo.fromPbUser(outUser));
|
||||
}
|
||||
} else {
|
||||
if((channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Unsubscribed_User_Access) > 0) {
|
||||
WFCMessage.User outUser = WFCMessage.User.newBuilder().setUid(user.getUid()).setName(user.getName()).setPortrait(user.getPortrait()).setDisplayName(user.getDisplayName()).build();
|
||||
result = RestResult.ok(InputOutputUserInfo.fromPbUser(outUser));
|
||||
} else {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_RIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.channel;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputModifyChannelInfo;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
@Route(APIPath.Channel_Update_Profile)
|
||||
@HttpMethod("POST")
|
||||
public class ModifyChannelProfileAction extends ChannelAction {
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputModifyChannelInfo input = getRequestBody(request.getNettyRequest(), InputModifyChannelInfo.class);
|
||||
if (input != null) {
|
||||
WFCMessage.ModifyChannelInfo modifyChannelInfo = WFCMessage.ModifyChannelInfo.newBuilder().setChannelId(channelInfo.getTargetId()).setType(input.getType()).setValue(input.getValue()).build();
|
||||
sendApiMessage(response, IMTopic.ModifyChannelInfoTopic, modifyChannelInfo.toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ package com.xiaoleilu.loServer.action.channel;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.pojos.SendChannelMessageData;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
@@ -20,8 +21,6 @@ import com.xiaoleilu.loServer.handler.Response;
|
||||
import cn.wildfirechat.pojos.Conversation;
|
||||
import cn.wildfirechat.pojos.SendMessageData;
|
||||
import cn.wildfirechat.pojos.SendMessageResult;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@@ -29,8 +28,6 @@ import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ConversationType.ConversationType_Channel;
|
||||
|
||||
@Route(APIPath.Channel_Message_Send)
|
||||
@@ -46,6 +43,17 @@ public class SendMessageAction extends ChannelAction {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
SendChannelMessageData sendChannelMessageData = getRequestBody(request.getNettyRequest(), SendChannelMessageData.class);
|
||||
if(sendChannelMessageData.getTargets() != null && !sendChannelMessageData.getTargets().isEmpty()) {
|
||||
if((channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Message_Unsubscribed) == 0 && (channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Global) == 0) {
|
||||
for (String target:sendChannelMessageData.getTargets()) {
|
||||
if(!messagesStore.checkUserInChannel(target, channelInfo.getTargetId())) {
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_RIGHT, "User " + target + " not in channel"), response);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SendMessageData sendMessageData = new SendMessageData();
|
||||
sendMessageData.setConv(new Conversation());
|
||||
sendMessageData.getConv().setType(ConversationType_Channel);
|
||||
@@ -55,43 +63,21 @@ public class SendMessageAction extends ChannelAction {
|
||||
sendMessageData.setPayload(sendChannelMessageData.getPayload());
|
||||
sendMessageData.setToUsers(sendChannelMessageData.getTargets());
|
||||
if (SendMessageData.isValide(sendMessageData)) {
|
||||
RPCCenter.getInstance().sendRequest(sendMessageData.getSender(), null, IMTopic.SendMessageTopic, sendMessageData.toProtoMessage().toByteArray(), sendMessageData.getSender(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long timestamp = byteBuf.readLong();
|
||||
sendResponse(response, null, new SendMessageResult(messageId, timestamp));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendApiMessage(response, IMTopic.SendMessageTopic, sendMessageData.toProtoMessage().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long timestamp = byteBuf.readLong();
|
||||
sendResponse(response, null, new SendMessageResult(messageId, timestamp));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, false);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.channel;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputChannelSubscribe;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
@Route(APIPath.Channel_Subscribe)
|
||||
@HttpMethod("POST")
|
||||
public class SubscriberChannelAction extends ChannelAction {
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputChannelSubscribe input = getRequestBody(request.getNettyRequest(), InputChannelSubscribe.class);
|
||||
if (input != null && !StringUtil.isNullOrEmpty(input.getTarget())) {
|
||||
if(input.getSubscribe() > 0 && (channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Active_Subscribe) == 0) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_RIGHT);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
return true;
|
||||
}
|
||||
WFCMessage.ListenChannel listenChannel = WFCMessage.ListenChannel.newBuilder().setChannelId(channelInfo.getTargetId()).setListen(input.getSubscribe()).build();
|
||||
sendApiMessage(response, input.getTarget(), IMTopic.ChannelListenTopic, listenChannel.toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -14,21 +14,16 @@ import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputAddGroupMember;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.admin.AdminAction;
|
||||
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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Robot_Group_Member_Add)
|
||||
@HttpMethod("POST")
|
||||
public class AddGroupMemberAction extends RobotAction {
|
||||
@@ -44,41 +39,19 @@ public class AddGroupMemberAction extends RobotAction {
|
||||
InputAddGroupMember inputAddGroupMember = getRequestBody(request.getNettyRequest(), InputAddGroupMember.class);
|
||||
inputAddGroupMember.setOperator(robot.getUid());
|
||||
if (inputAddGroupMember.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputAddGroupMember.getOperator(), null, IMTopic.AddGroupMemberTopic, inputAddGroupMember.toProtoGroupRequest().toByteArray(), inputAddGroupMember.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendApiRequest(response, IMTopic.AddGroupMemberTopic, inputAddGroupMember.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, false);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -17,21 +17,16 @@ import cn.wildfirechat.pojos.PojoGroupInfo;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.admin.AdminAction;
|
||||
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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Robot_Create_Group)
|
||||
@HttpMethod("POST")
|
||||
public class CreateGroupAction extends RobotAction {
|
||||
@@ -50,44 +45,22 @@ public class CreateGroupAction extends RobotAction {
|
||||
if (inputCreateGroup.isValide()) {
|
||||
PojoGroupInfo group_info = inputCreateGroup.getGroup().getGroup_info();
|
||||
WFCMessage.CreateGroupRequest createGroupRequest = inputCreateGroup.toProtoGroupRequest();
|
||||
RPCCenter.getInstance().sendRequest(inputCreateGroup.getOperator(), null, IMTopic.CreateGroupTopic, createGroupRequest.toByteArray(), inputCreateGroup.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
byte[] data = new byte[byteBuf.readableBytes()];
|
||||
byteBuf.readBytes(data);
|
||||
String groupId = new String(data);
|
||||
sendResponse(response, null, new OutputCreateGroupResult(groupId));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendApiRequest(response, IMTopic.CreateGroupTopic, createGroupRequest.toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
byte[] data = new byte[byteBuf.readableBytes()];
|
||||
byteBuf.readBytes(data);
|
||||
String groupId = new String(data);
|
||||
sendResponse(response, null, new OutputCreateGroupResult(groupId));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, false);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -32,9 +32,7 @@ public class DeleteCallbackAction extends RobotAction {
|
||||
robot = robot.toBuilder().clearCallback().setState(0).build();
|
||||
messagesStore.addRobot(robot);
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok();
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(), response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -14,21 +14,16 @@ import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputDismissGroup;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.admin.AdminAction;
|
||||
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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Robot_Group_Dismiss)
|
||||
@HttpMethod("POST")
|
||||
public class DismissGroupAction extends RobotAction {
|
||||
@@ -44,41 +39,19 @@ public class DismissGroupAction extends RobotAction {
|
||||
InputDismissGroup inputDismissGroup = getRequestBody(request.getNettyRequest(), InputDismissGroup.class);
|
||||
inputDismissGroup.setOperator(robot.getUid());
|
||||
if (inputDismissGroup.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputDismissGroup.getOperator(), null, IMTopic.DismissGroupTopic, inputDismissGroup.toProtoGroupRequest().toByteArray(), inputDismissGroup.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendApiRequest(response, IMTopic.DismissGroupTopic, inputDismissGroup.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, false);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -33,9 +33,7 @@ public class GetCallbackAction extends RobotAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
RobotCallbackPojo out = new RobotCallbackPojo();
|
||||
out.setUrl(robot.getCallback());
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(out);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(out), response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,8 +41,6 @@ public class GetGroupInfoAction extends RobotAction {
|
||||
&& (!StringUtil.isNullOrEmpty(inputGetGroup.getGroupId()))) {
|
||||
|
||||
WFCMessage.GroupInfo groupInfo = messagesStore.getGroupInfo(inputGetGroup.getGroupId());
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (groupInfo == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
@@ -54,14 +52,15 @@ public class GetGroupInfoAction extends RobotAction {
|
||||
pojoGroupInfo.setPortrait(groupInfo.getPortrait());
|
||||
pojoGroupInfo.setTarget_id(groupInfo.getTargetId());
|
||||
pojoGroupInfo.setType(groupInfo.getType());
|
||||
pojoGroupInfo.setMute(groupInfo.getMute());
|
||||
pojoGroupInfo.setJoin_type(groupInfo.getJoinType());
|
||||
pojoGroupInfo.setPrivate_chat(groupInfo.getPrivateChat());
|
||||
pojoGroupInfo.setSearchable(groupInfo.getSearchable());
|
||||
result = RestResult.ok(pojoGroupInfo);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,9 +48,6 @@ public class GetGroupMembersAction extends RobotAction {
|
||||
|
||||
List<WFCMessage.GroupMember> members = new ArrayList<>();
|
||||
ErrorCode errorCode = messagesStore.getGroupMembers(null, inputGetGroup.getGroupId(), 0, members);
|
||||
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
result = RestResult.resultOf(errorCode);
|
||||
@@ -69,6 +66,7 @@ public class GetGroupMembersAction extends RobotAction {
|
||||
pm.setMember_id(member.getMemberId());
|
||||
pm.setAlias(member.getAlias());
|
||||
pm.setType(member.getType());
|
||||
pm.setExtra(member.getExtra());
|
||||
out.getMembers().add(pm);
|
||||
}
|
||||
if(!isInGroup) {
|
||||
@@ -77,11 +75,9 @@ public class GetGroupMembersAction extends RobotAction {
|
||||
result = RestResult.ok(out);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,19 +43,15 @@ public class GetUserAction extends RobotAction {
|
||||
user = messagesStore.getUserInfoByMobile(inputUserId.getMobile());
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (user == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
} else {
|
||||
result = RestResult.ok(InputOutputUserInfo.fromPbUser(user));
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result, response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-36
@@ -14,21 +14,16 @@ import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputKickoffGroupMember;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.admin.AdminAction;
|
||||
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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Robot_Group_Member_Kickoff)
|
||||
@HttpMethod("POST")
|
||||
public class KickoffGroupMemberAction extends RobotAction {
|
||||
@@ -44,41 +39,19 @@ public class KickoffGroupMemberAction extends RobotAction {
|
||||
InputKickoffGroupMember inputKickoffGroupMember = getRequestBody(request.getNettyRequest(), InputKickoffGroupMember.class);
|
||||
inputKickoffGroupMember.setOperator(robot.getUid());
|
||||
if (inputKickoffGroupMember.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputKickoffGroupMember.getOperator(), null, IMTopic.KickoffGroupMemberTopic, inputKickoffGroupMember.toProtoGroupRequest().toByteArray(), inputKickoffGroupMember.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendApiRequest(response, IMTopic.KickoffGroupMemberTopic, inputKickoffGroupMember.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, false);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+9
-36
@@ -14,21 +14,16 @@ import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputModifyGroupInfo;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.admin.AdminAction;
|
||||
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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Robot_Group_Modify_Info)
|
||||
@HttpMethod("POST")
|
||||
public class ModifyGroupInfoAction extends RobotAction {
|
||||
@@ -44,41 +39,19 @@ public class ModifyGroupInfoAction extends RobotAction {
|
||||
InputModifyGroupInfo inputAddGroupMember = getRequestBody(request.getNettyRequest(), InputModifyGroupInfo.class);
|
||||
inputAddGroupMember.setOperator(robot.getUid());
|
||||
if (inputAddGroupMember.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputAddGroupMember.getOperator(), null, IMTopic.ModifyGroupInfoTopic, inputAddGroupMember.toProtoGroupRequest().toByteArray(), inputAddGroupMember.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendApiRequest(response, IMTopic.ModifyGroupInfoTopic, inputAddGroupMember.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, false);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+9
-36
@@ -14,21 +14,16 @@ import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputSetGroupMemberAlias;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.admin.AdminAction;
|
||||
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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Robot_Group_Set_Member_Alias)
|
||||
@HttpMethod("POST")
|
||||
public class ModifyGroupMemberAliasAction extends RobotAction {
|
||||
@@ -44,41 +39,19 @@ public class ModifyGroupMemberAliasAction extends RobotAction {
|
||||
InputSetGroupMemberAlias inputSetGroupMemberAlias = getRequestBody(request.getNettyRequest(), InputSetGroupMemberAlias.class);
|
||||
inputSetGroupMemberAlias.setOperator(robot.getUid());
|
||||
if (inputSetGroupMemberAlias.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputSetGroupMemberAlias.getOperator(), null, IMTopic.ModifyGroupMemberAliasTopic, inputSetGroupMemberAlias.toProtoGroupRequest().toByteArray(), inputSetGroupMemberAlias.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendApiRequest(response, IMTopic.ModifyGroupMemberAliasTopic, inputSetGroupMemberAlias.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, false);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+9
-36
@@ -14,21 +14,16 @@ import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputQuitGroup;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.admin.AdminAction;
|
||||
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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Robot_Group_Member_Quit)
|
||||
@HttpMethod("POST")
|
||||
public class QuitGroupMemberAction extends RobotAction {
|
||||
@@ -44,41 +39,19 @@ public class QuitGroupMemberAction extends RobotAction {
|
||||
InputQuitGroup inputQuitGroup = getRequestBody(request.getNettyRequest(), InputQuitGroup.class);
|
||||
inputQuitGroup.setOperator(robot.getUid());
|
||||
if (inputQuitGroup.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputQuitGroup.getOperator(), null, IMTopic.QuitGroupTopic, inputQuitGroup.toProtoGroupRequest().toByteArray(), inputQuitGroup.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendApiRequest(response, IMTopic.QuitGroupTopic, inputQuitGroup.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, false);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.Action;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.moquette.persistence.ServerAPIHelper;
|
||||
import io.moquette.spi.impl.Utils;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
@@ -28,6 +29,7 @@ import win.liyufan.im.RateLimiter;
|
||||
import win.liyufan.im.Utility;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
abstract public class RobotAction extends Action {
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(RobotAction.class);
|
||||
@@ -35,6 +37,10 @@ abstract public class RobotAction extends Action {
|
||||
|
||||
protected WFCMessage.Robot robot;
|
||||
|
||||
protected interface Callback {
|
||||
void onSuccess(byte[] response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode preAction(Request request, Response response) {
|
||||
String nonce = request.getHeader("nonce");
|
||||
@@ -55,7 +61,7 @@ abstract public class RobotAction extends Action {
|
||||
}
|
||||
|
||||
if (StringUtil.isNullOrEmpty(nonce) || StringUtil.isNullOrEmpty(timestamp) || StringUtil.isNullOrEmpty(sign) || StringUtil.isNullOrEmpty(rid)) {
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
return ErrorCode.ERROR_CODE_API_NOT_SIGNED;
|
||||
}
|
||||
|
||||
if (!mLimitCounter.isGranted(rid)) {
|
||||
@@ -68,7 +74,7 @@ abstract public class RobotAction extends Action {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e, IMExceptionEvent.EventType.ROBOT_API_Exception);
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
return ErrorCode.ERROR_CODE_API_NOT_SIGNED;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() - ts > 2 * 60 * 60 * 1000) {
|
||||
@@ -117,4 +123,30 @@ abstract public class RobotAction extends Action {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void sendApiRequest(Response response, String topic, byte[] message, Callback callback) {
|
||||
ServerAPIHelper.sendRequest(robot.getUid(), null, topic, message, new ServerAPIHelper.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] response) {
|
||||
callback.onSuccess(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import cn.wildfirechat.pojos.SendMessageData;
|
||||
import cn.wildfirechat.pojos.SendMessageResult;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@@ -27,8 +25,6 @@ import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Robot_Message_Send)
|
||||
@HttpMethod("POST")
|
||||
public class SendMessageAction extends RobotAction {
|
||||
@@ -44,43 +40,21 @@ public class SendMessageAction extends RobotAction {
|
||||
SendMessageData sendMessageData = getRequestBody(request.getNettyRequest(), SendMessageData.class);
|
||||
sendMessageData.setSender(robot.getUid());
|
||||
if (SendMessageData.isValide(sendMessageData)) {
|
||||
RPCCenter.getInstance().sendRequest(sendMessageData.getSender(), null, IMTopic.SendMessageTopic, sendMessageData.toProtoMessage().toByteArray(), sendMessageData.getSender(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long timestamp = byteBuf.readLong();
|
||||
sendResponse(response, null, new SendMessageResult(messageId, timestamp));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendApiRequest(response, IMTopic.SendMessageTopic, sendMessageData.toProtoMessage().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long timestamp = byteBuf.readLong();
|
||||
sendResponse(response, null, new SendMessageResult(messageId, timestamp));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, false);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -35,14 +35,9 @@ public class SetCallbackAction extends RobotAction {
|
||||
robot = robot.toBuilder().setCallback(input.getUrl()).setState(1).build();
|
||||
messagesStore.addRobot(robot);
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok();
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(), response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,21 +14,16 @@ import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputTransferGroup;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.admin.AdminAction;
|
||||
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.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
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 win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Robot_Group_Transfer)
|
||||
@HttpMethod("POST")
|
||||
public class TransferGroupAction extends RobotAction {
|
||||
@@ -44,41 +39,19 @@ public class TransferGroupAction extends RobotAction {
|
||||
InputTransferGroup inputDismissGroup = getRequestBody(request.getNettyRequest(), InputTransferGroup.class);
|
||||
inputDismissGroup.setOperator(robot.getUid());
|
||||
if (inputDismissGroup.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputDismissGroup.getOperator(), null, IMTopic.TransferGroupTopic, inputDismissGroup.toProtoGroupRequest().toByteArray(), inputDismissGroup.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendApiRequest(response, IMTopic.TransferGroupTopic, inputDismissGroup.toProtoGroupRequest().toByteArray(), result -> {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, false);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -76,7 +76,6 @@ public class UpdateProfileAction extends RobotAction {
|
||||
break;
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok();
|
||||
if(modified) {
|
||||
try {
|
||||
@@ -86,8 +85,7 @@ public class UpdateProfileAction extends RobotAction {
|
||||
result.setErrorCode(ErrorCode.ERROR_CODE_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result, response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,8 @@ public final class BrokerConstants {
|
||||
public static final String QINIU_BUCKET_FAVORITE_DOMAIN = "qiniu.bucket_favorite_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";
|
||||
|
||||
public static final String USER_QINIU = "media.server.use_qiniu";
|
||||
|
||||
public static final String PUSH_ANDROID_SERVER_ADDRESS = "push.android.server.address";
|
||||
@@ -155,12 +157,18 @@ public final class BrokerConstants {
|
||||
public static final String GROUP_Visible_Quit_Kickoff_Notification = "group.visible_quit_or_kickoff_notification";
|
||||
|
||||
public static final String USER_HIDE_PROPERTIES = "user.hide_properties";
|
||||
public static final String SYNC_Data_Part_Size = "sync.data_part_size";
|
||||
|
||||
public static final String MESSAGES_FORBIDDEN_CLIENT_SEND_TYPES = "message.forbidden_client_send_types";
|
||||
public static final String MESSAGES_BLACKLIST_EXCEPTION_TYPES = "message.blacklist_exception_types";
|
||||
public static final String MESSAGES_GROUP_MUTE_EXCEPTION_TYPES = "message.group_mute_exception_types";
|
||||
public static final String MESSAGES_GLOBAL_MUTE_EXCEPTION_TYPES = "message.global_mute_exception_types";
|
||||
|
||||
public static final String MESSAGES_DISABLE_REMOTE_SEARCH = "message.disable_remote_search";
|
||||
|
||||
public static final String MESSAGES_RECALL_TIME_LIMIT = "message.recall_time_limit";
|
||||
public static final String MESSAGES_DISABLE_GROUP_MANAGER_RECALL = "message.disable_group_manager_recall";
|
||||
|
||||
|
||||
private BrokerConstants() {
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AddFriendHandler extends GroupHandler<WFCMessage.AddFriendRequest>
|
||||
publisher.publishNotification(IMTopic.NotifyFriendRequestTopic, request.getTargetUid(), head[0], fromUser, request.getReason());
|
||||
} else if(user != null && user.getType() == ProtoConstants.UserType.UserType_Robot) {
|
||||
WFCMessage.HandleFriendRequest handleFriendRequest = WFCMessage.HandleFriendRequest.newBuilder().setTargetUid(fromUser).setStatus(ProtoConstants.FriendRequestStatus.RequestStatus_Accepted).build();
|
||||
mServer.internalRpcMsg(request.getTargetUid(), null, handleFriendRequest.toByteArray(), 0, fromUser, HandleFriendRequestTopic, false);
|
||||
mServer.onApiMessage(request.getTargetUid(), null, handleFriendRequest.toByteArray(), 0, fromUser, HandleFriendRequestTopic, false, false);
|
||||
}
|
||||
}
|
||||
return errorCode;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class AddGroupMember extends GroupHandler<WFCMessage.AddGroupMemberReques
|
||||
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.AddGroupMemberRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = m_messagesStore.addGroupMembers(fromUser, isAdmin, request.getGroupId(), request.getAddedMemberList());
|
||||
ErrorCode errorCode = m_messagesStore.addGroupMembers(fromUser, isAdmin, request.getGroupId(), request.getAddedMemberList(), request.getExtra());
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ChannelListenMember extends IMHandler<WFCMessage.ListenChannel> {
|
||||
ErrorCode errorCode = m_messagesStore.listenChannel(fromUser, request.getChannelId(), request.getListen()>0);
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
WFCMessage.ModifyUserSettingReq modifyUserSettingReq = WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingListenedChannels).setKey(request.getChannelId()).setValue(request.getListen() > 0 ? "1" : "0").build();
|
||||
mServer.internalRpcMsg(fromUser, null, modifyUserSettingReq.toByteArray(), 0, fromUser, PutUserSettingTopic, false);
|
||||
mServer.onApiMessage(fromUser, null, modifyUserSettingReq.toByteArray(), 0, fromUser, PutUserSettingTopic, false, false);
|
||||
|
||||
publisher.notifyChannelListenStatusChanged(m_messagesStore.getChannelInfo(request.getChannelId()), fromUser, request.getListen() > 0);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class CreateChannelHandler extends GroupHandler<WFCMessage.ChannelInfo> {
|
||||
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
WFCMessage.ModifyUserSettingReq modifyUserSettingReq = WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingMyChannels).setKey(request.getTargetId()).setValue("1").build();
|
||||
mServer.internalRpcMsg(fromUser, null, modifyUserSettingReq.toByteArray(), 0, fromUser, PutUserSettingTopic, false);
|
||||
mServer.onApiMessage(fromUser, null, modifyUserSettingReq.toByteArray(), 0, fromUser, PutUserSettingTopic, false, false);
|
||||
byte[] data = request.getTargetId().getBytes();
|
||||
ackPayload.ensureWritable(data.length).writeBytes(data);
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class CreateGroupHandler extends GroupHandler<WFCMessage.CreateGroupReque
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
WFCMessage.GroupInfo groupInfo = m_messagesStore.createGroup(fromUser, request.getGroup().getGroupInfo(), request.getGroup().getMembersList(), isAdmin);
|
||||
WFCMessage.GroupInfo groupInfo = m_messagesStore.createGroup(fromUser, request.getGroup().getGroupInfo(), request.getGroup().getMembersList(), request.getMemberExtra(), isAdmin);
|
||||
|
||||
if (groupInfo != null) {
|
||||
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0 && (isAdmin || m_messagesStore.isAllowClientCustomGroupNotification())) {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DistoryChannelHandler extends GroupHandler<WFCMessage.IDBuf> {
|
||||
ErrorCode errorCode = m_messagesStore.distoryChannel(fromUser, request.getId());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
WFCMessage.ModifyUserSettingReq modifyUserSettingReq = WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingMyChannels).setKey(request.getId()).setValue("0").build();
|
||||
mServer.internalRpcMsg(fromUser, null, modifyUserSettingReq.toByteArray(), 0, fromUser, PutUserSettingTopic, false);
|
||||
mServer.onApiMessage(fromUser, null, modifyUserSettingReq.toByteArray(), 0, fromUser, PutUserSettingTopic, false, false);
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,15 @@ package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import com.qiniu.util.Auth;
|
||||
import com.xiaoleilu.loServer.action.UploadFileAction;
|
||||
import io.moquette.server.config.MediaServerConfig;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import static io.moquette.server.config.MediaServerConfig.FILE_STROAGE_REMOTE_SERVER_URL;
|
||||
|
||||
@Handler("GMUT")
|
||||
public class GetMediaUploadTokenHandler extends IMHandler<WFCMessage.GetUploadTokenRequest> {
|
||||
@Override
|
||||
@@ -80,8 +83,12 @@ public class GetMediaUploadTokenHandler extends IMHandler<WFCMessage.GetUploadTo
|
||||
resultBuilder.setPort(80);
|
||||
} else {
|
||||
token = UploadFileAction.getToken(type);
|
||||
resultBuilder.setDomain("http://" + MediaServerConfig.SERVER_IP + ":" + MediaServerConfig.HTTP_SERVER_PORT)
|
||||
.setServer(MediaServerConfig.SERVER_IP);
|
||||
if(StringUtil.isNullOrEmpty(MediaServerConfig.FILE_STROAGE_REMOTE_SERVER_URL)) {
|
||||
resultBuilder.setDomain("http://" + MediaServerConfig.SERVER_IP + ":" + MediaServerConfig.HTTP_SERVER_PORT);
|
||||
} else {
|
||||
resultBuilder.setDomain(MediaServerConfig.FILE_STROAGE_REMOTE_SERVER_URL);
|
||||
}
|
||||
resultBuilder.setServer(MediaServerConfig.SERVER_IP);
|
||||
resultBuilder.setPort(MediaServerConfig.HTTP_SERVER_PORT);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ public class ModifyGroupInfoHandler extends GroupHandler<WFCMessage.ModifyGroupI
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupPrivatechatNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_Searchable) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupSearchableNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_Extra) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupExtraNotifyContent();
|
||||
}
|
||||
|
||||
if (content != null) {
|
||||
|
||||
@@ -18,7 +18,7 @@ import win.liyufan.im.IMTopic;
|
||||
public class PutUserSettingHandler extends IMHandler<WFCMessage.ModifyUserSettingReq> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.ModifyUserSettingReq request, Qos1PublishHandler.IMCallback callback) {
|
||||
m_messagesStore.updateUserSettings(fromUser, request);
|
||||
m_messagesStore.updateUserSettings(fromUser, request, clientID);
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,17 +105,21 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
|
||||
int userStatus = m_messagesStore.getUserStatus(fromUser);
|
||||
if (userStatus == ProtoConstants.UserStatus.Muted || userStatus == ProtoConstants.UserStatus.Forbidden) {
|
||||
return ErrorCode.ERROR_CODE_FORBIDDEN_SEND_MSG;
|
||||
if(!m_messagesStore.getGlobalMuteExceptionTypes().contains(message.getContent().getType())) {
|
||||
return ErrorCode.ERROR_CODE_FORBIDDEN_SEND_MSG;
|
||||
}
|
||||
}
|
||||
|
||||
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Private) {
|
||||
errorCode = m_messagesStore.isAllowUserMessage(message.getConversation().getTarget(), fromUser);
|
||||
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(!m_messagesStore.getBlackListExceptionTypes().contains(message.getContent().getType())) {
|
||||
errorCode = m_messagesStore.isAllowUserMessage(message.getConversation().getTarget(), fromUser);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,17 +130,23 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
}
|
||||
|
||||
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group ) {
|
||||
errorCode = m_messagesStore.canSendMessageInGroup(fromUser, message.getConversation().getTarget());
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
return errorCode;
|
||||
if(!m_messagesStore.getGroupMuteExceptionTypes().contains(message.getContent().getType())) {
|
||||
errorCode = m_messagesStore.canSendMessageInGroup(fromUser, message.getConversation().getTarget());
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_ChatRoom) {
|
||||
if(!m_messagesStore.checkUserClientInChatroom(fromUser, clientID, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_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.checkUserInChannel(fromUser, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHANNEL;
|
||||
if(!m_messagesStore.getGroupMuteExceptionTypes().contains(message.getContent().getType())) {
|
||||
if (!m_messagesStore.checkUserInChannel(fromUser, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHANNEL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ public class DatabaseStore {
|
||||
String sql = "select `_mid`" +
|
||||
", `_alias`" +
|
||||
", `_type`" +
|
||||
", `_dt`, `_create_dt` from t_group_member where _gid = ?";
|
||||
", `_dt`, `_create_dt`, `_extra` from t_group_member where _gid = ?";
|
||||
statement = connection.prepareStatement(sql);
|
||||
|
||||
statement.setString(1, groupId);
|
||||
@@ -362,6 +362,10 @@ public class DatabaseStore {
|
||||
longValue = rs.getLong(index++);
|
||||
builder.setCreateDt(longValue);
|
||||
|
||||
value = rs.getString(index++);
|
||||
value = (value == null ? "" : value);
|
||||
builder.setExtra(value);
|
||||
|
||||
WFCMessage.GroupMember member = builder.build();
|
||||
groupMembers.put(groupId, member);
|
||||
}
|
||||
@@ -442,7 +446,7 @@ public class DatabaseStore {
|
||||
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "select `_uid`, `_friend_uid`, `_reason`, `_status`, `_dt`, `_from_read_status`, `_to_read_status` from t_friend_request";
|
||||
String sql = "select `_uid`, `_friend_uid`, `_reason`, `_status`, `_dt`, `_from_read_status`, `_to_read_status`, `_extra` from t_friend_request";
|
||||
statement = connection.prepareStatement(sql);
|
||||
|
||||
int index;
|
||||
@@ -476,6 +480,9 @@ public class DatabaseStore {
|
||||
intvalue = rs.getInt(index++);
|
||||
builder.setToReadStatus(intvalue > 0);
|
||||
|
||||
value = rs.getString(index++);
|
||||
value = (value == null ? "" : value);
|
||||
builder.setExtra(value);
|
||||
|
||||
WFCMessage.FriendRequest request = builder.build();
|
||||
requestMap.put(request.getFromUid(), request);
|
||||
@@ -696,7 +703,7 @@ public class DatabaseStore {
|
||||
}
|
||||
|
||||
MessageBundle getMessage(long messageId) {
|
||||
String sql = "select `_from`, `_type`, `_target`, `_line`, `_data`, `_dt` from " + MessageShardingUtil.getMessageTable(messageId) +" where _mid = ? limit 1";
|
||||
String sql = "select `_from`, `_type`, `_target`, `_line`, `_data`, `_dt` from " + MessageShardingUtil.getMessageTable(messageId) +" where _mid = ? order by `_dt` DESC limit 1";
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
ResultSet resultSet = null;
|
||||
@@ -1702,7 +1709,7 @@ public class DatabaseStore {
|
||||
}
|
||||
}
|
||||
|
||||
void persistGroupMember(final String groupId, final List<WFCMessage.GroupMember> memberList) {
|
||||
void persistGroupMember(final String groupId, final List<WFCMessage.GroupMember> memberList, boolean updateCreateTime) {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
@@ -1713,11 +1720,15 @@ public class DatabaseStore {
|
||||
", `_mid`" +
|
||||
", `_alias`" +
|
||||
", `_type`" +
|
||||
", `_dt`, `_create_dt`) values(?, ?, ?, ?, ?, ?)" +
|
||||
", `_dt`, `_create_dt`, `_extra`) values(?, ?, ?, ?, ?, ?,?)" +
|
||||
" ON DUPLICATE KEY UPDATE " +
|
||||
"`_alias` = ?," +
|
||||
"`_type` = ?," +
|
||||
"`_dt` = ?";
|
||||
"`_dt` = ?," +
|
||||
"`_extra` = ?";
|
||||
if(updateCreateTime) {
|
||||
sql += ", `_create_dt` = ?";
|
||||
}
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
|
||||
@@ -1735,17 +1746,22 @@ public class DatabaseStore {
|
||||
statement.setInt(index++, member.getType());
|
||||
statement.setLong(index++, dt);
|
||||
statement.setLong(index++, member.getCreateDt());
|
||||
statement.setString(index++, member.getExtra());
|
||||
statement.setString(index++, member.getAlias());
|
||||
statement.setInt(index++, member.getType());
|
||||
statement.setLong(index++, dt);
|
||||
statement.setString(index++, member.getExtra());
|
||||
if(updateCreateTime) {
|
||||
statement.setLong(index++, dt);
|
||||
}
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
}
|
||||
|
||||
connection.commit();
|
||||
connection.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e, RDBS_Exception);
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.commit();
|
||||
@@ -1754,9 +1770,6 @@ public class DatabaseStore {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e, RDBS_Exception);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
}
|
||||
@@ -2677,14 +2690,14 @@ public class DatabaseStore {
|
||||
", `_status`" +
|
||||
", `_dt`" +
|
||||
", `_from_read_status`" +
|
||||
", `_to_read_status` from t_friend_request where `_uid` = ? UNION ALL " +
|
||||
", `_to_read_status`, `_extra` from t_friend_request where `_uid` = ? UNION ALL " +
|
||||
"select `_uid`" +
|
||||
", `_friend_uid`" +
|
||||
", `_reason`" +
|
||||
", `_status`" +
|
||||
", `_dt`" +
|
||||
", `_from_read_status`" +
|
||||
", `_to_read_status` from t_friend_request where `_friend_uid` = ?";
|
||||
", `_to_read_status`, `_extra` from t_friend_request where `_friend_uid` = ?";
|
||||
statement = connection.prepareStatement(sql);
|
||||
|
||||
int index = 1;
|
||||
@@ -2722,6 +2735,10 @@ public class DatabaseStore {
|
||||
b = rs.getBoolean(index++);
|
||||
builder.setToReadStatus(b);
|
||||
|
||||
value = rs.getString(index++);
|
||||
value = (value == null ? "" : value);
|
||||
builder.setExtra(value);
|
||||
|
||||
out.add(builder.build());
|
||||
}
|
||||
return out;
|
||||
@@ -2769,13 +2786,14 @@ public class DatabaseStore {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "insert into t_friend_request (`_uid`, `_friend_uid`, `_reason`, `_status`, `_dt`, `_from_read_status`, `_to_read_status`) values(?, ?, ?, ?, ?, ?, ?)" +
|
||||
String sql = "insert into t_friend_request (`_uid`, `_friend_uid`, `_reason`, `_status`, `_dt`, `_from_read_status`, `_to_read_status`, `_extra`) values(?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
" ON DUPLICATE KEY UPDATE " +
|
||||
"`_reason` = ?," +
|
||||
"`_status` = ?," +
|
||||
"`_dt` = ?," +
|
||||
"`_from_read_status` = ?," +
|
||||
"`_to_read_status` = ?";
|
||||
"`_to_read_status` = ?," +
|
||||
"`_extra` = ?";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
int index = 1;
|
||||
@@ -2786,12 +2804,14 @@ public class DatabaseStore {
|
||||
statement.setLong(index++, request.getUpdateDt());
|
||||
statement.setInt(index++, request.getFromReadStatus() ? 1 : 0);
|
||||
statement.setInt(index++, request.getToReadStatus() ? 1 : 0);
|
||||
statement.setString(index++, request.getExtra());
|
||||
|
||||
statement.setString(index++, request.getReason());
|
||||
statement.setInt(index++, request.getStatus());
|
||||
statement.setLong(index++, request.getUpdateDt());
|
||||
statement.setInt(index++, request.getFromReadStatus() ? 1 : 0);
|
||||
statement.setInt(index++, request.getToReadStatus() ? 1 : 0);
|
||||
statement.setString(index++, request.getExtra());
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
} catch (SQLException e) {
|
||||
@@ -3082,11 +3102,11 @@ public class DatabaseStore {
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
}
|
||||
|
||||
connection.commit();
|
||||
connection.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e, RDBS_Exception);
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.commit();
|
||||
@@ -3095,9 +3115,6 @@ public class DatabaseStore {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e, RDBS_Exception);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -130,7 +130,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private long mFriendRequestDuration = 7 * 24 * 60 * 60 * 1000;
|
||||
private long mFriendRejectDuration = 30 * 24 * 60 * 60 * 1000;
|
||||
private long mFriendRequestExpiration = 7 * 24 * 60 * 60 * 1000;
|
||||
private boolean mFriendNewWelcomeMessage = false;
|
||||
private boolean mFriendNewWelcomeMessage = true;
|
||||
|
||||
private boolean mMultiPlatformNotification = false;
|
||||
private boolean mDisableStrangerChat = false;
|
||||
@@ -139,9 +139,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private boolean mChatroomRejoinWhenActive = true;
|
||||
|
||||
private List<Integer> mForbiddenClientSendTypes = new ArrayList<>();
|
||||
private List<Integer> mBlackListExceptionTypes = new ArrayList<>();
|
||||
private List<Integer> mGroupMuteExceptionTypes = new ArrayList<>();
|
||||
private List<Integer> mGlobalMuteExceptionTypes = new ArrayList<>();
|
||||
|
||||
private long mRecallTimeLimit = 300;
|
||||
|
||||
private boolean mDisableGroupManagerRecall = false;
|
||||
private String mGroupInfoUpdateCallback;
|
||||
private String mGroupMemberUpdateCallback;
|
||||
private String mRelationUpdateCallback;
|
||||
@@ -151,6 +154,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private String mChatroomMemberUpdateCallback;
|
||||
private boolean mGroupAllowClientCustomOperationNotification;
|
||||
private int mGroupVisibleQuitKickoffNotification;
|
||||
private int mSyncDataPartSize = 0;
|
||||
|
||||
private Set<Integer> mUserHideProperties = new HashSet<>();
|
||||
|
||||
@@ -175,7 +179,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
printMissConfigLog(SERVER_MULTI_PLATFROM_NOTIFICATION, mDisableStrangerChat + "");
|
||||
printMissConfigLog(SERVER_MULTI_PLATFROM_NOTIFICATION, mMultiPlatformNotification + "");
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -260,6 +264,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
try {
|
||||
mDisableGroupManagerRecall = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.MESSAGES_DISABLE_GROUP_MANAGER_RECALL, "false"));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
String strTypes = m_Server.getConfig().getProperty(BrokerConstants.MESSAGES_FORBIDDEN_CLIENT_SEND_TYPES);
|
||||
if(!StringUtil.isNullOrEmpty(strTypes)) {
|
||||
@@ -275,7 +285,48 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
try {
|
||||
String strTypes = m_Server.getConfig().getProperty(BrokerConstants.MESSAGES_BLACKLIST_EXCEPTION_TYPES);
|
||||
if(!StringUtil.isNullOrEmpty(strTypes)) {
|
||||
for (String strType:strTypes.split(",")) {
|
||||
try {
|
||||
int type = Integer.parseInt(strType);
|
||||
mBlackListExceptionTypes.add(type);
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
String strTypes = m_Server.getConfig().getProperty(BrokerConstants.MESSAGES_GROUP_MUTE_EXCEPTION_TYPES);
|
||||
if(!StringUtil.isNullOrEmpty(strTypes)) {
|
||||
for (String strType:strTypes.split(",")) {
|
||||
try {
|
||||
int type = Integer.parseInt(strType);
|
||||
mGroupMuteExceptionTypes.add(type);
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
String strTypes = m_Server.getConfig().getProperty(BrokerConstants.MESSAGES_GLOBAL_MUTE_EXCEPTION_TYPES);
|
||||
if(!StringUtil.isNullOrEmpty(strTypes)) {
|
||||
for (String strType:strTypes.split(",")) {
|
||||
try {
|
||||
int type = Integer.parseInt(strType);
|
||||
mGlobalMuteExceptionTypes.add(type);
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
try {
|
||||
mGroupInfoUpdateCallback = server.getConfig().getProperty(GROUP_INFO_UPDATE_CALLBACK);
|
||||
@@ -331,6 +382,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
mSyncDataPartSize = Integer.parseInt(server.getConfig().getProperty(SYNC_Data_Part_Size, "0"));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
String userHideStr = server.getConfig().getProperty(USER_HIDE_PROPERTIES);
|
||||
@@ -469,19 +526,27 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if (channelInfo != null) {
|
||||
notifyReceivers.add(fromUser);
|
||||
if (channelInfo.getOwner().equals(fromUser)) {
|
||||
Collection<String> listeners = getChannelListener(message.getConversation().getTarget());
|
||||
if (!StringUtil.isNullOrEmpty(message.getToUser())) {
|
||||
if (listeners.contains(message.getToUser())) {
|
||||
notifyReceivers.add(message.getToUser());
|
||||
}
|
||||
} else if(message.getToList() != null && !message.getToList().isEmpty()) {
|
||||
for (String to:message.getToList()) {
|
||||
if (listeners.contains(to)) {
|
||||
notifyReceivers.add(to);
|
||||
}
|
||||
if((channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Global) > 0) {
|
||||
if((message.getToList() != null && !message.getToList().isEmpty())) {
|
||||
notifyReceivers.addAll(message.getToList());
|
||||
} else {
|
||||
notifyReceivers.addAll(getAllEnds());
|
||||
}
|
||||
} else {
|
||||
notifyReceivers.addAll(listeners);
|
||||
Collection<String> listeners = getChannelListener(message.getConversation().getTarget());
|
||||
if (!StringUtil.isNullOrEmpty(message.getToUser())) {
|
||||
if (listeners.contains(message.getToUser()) || (channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Message_Unsubscribed) > 0) {
|
||||
notifyReceivers.add(message.getToUser());
|
||||
}
|
||||
} else if (message.getToList() != null && !message.getToList().isEmpty()) {
|
||||
for (String to : message.getToList()) {
|
||||
if (listeners.contains(to) || (channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Message_Unsubscribed) > 0) {
|
||||
notifyReceivers.add(to);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notifyReceivers.addAll(listeners);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (StringUtil.isNullOrEmpty(channelInfo.getCallback()) || channelInfo.getAutomatic() == 0) {
|
||||
@@ -876,7 +941,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WFCMessage.GroupInfo createGroup(String fromUser, WFCMessage.GroupInfo groupInfo, List<WFCMessage.GroupMember> memberList, boolean isAdmin) {
|
||||
public WFCMessage.GroupInfo createGroup(String fromUser, WFCMessage.GroupInfo groupInfo, List<WFCMessage.GroupMember> memberList, String memberExtra, boolean isAdmin) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
IMap<String, WFCMessage.GroupInfo> mIMap = hzInstance.getMap(GROUPS_MAP);
|
||||
|
||||
@@ -898,19 +963,39 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
List<WFCMessage.GroupMember> updatedMemberList = new ArrayList<>();
|
||||
boolean hasOwnerMember = false;
|
||||
for (WFCMessage.GroupMember member : memberList) {
|
||||
WFCMessage.GroupMember.Builder builder = member.toBuilder();
|
||||
builder.setUpdateDt(dt).setCreateDt(dt);
|
||||
if (member.getMemberId().equals(owner)) {
|
||||
member = member.toBuilder().setUpdateDt(dt).setCreateDt(dt).setType(ProtoConstants.GroupMemberType.GroupMemberType_Owner).build();
|
||||
builder.setType(ProtoConstants.GroupMemberType.GroupMemberType_Owner);
|
||||
hasOwnerMember = true;
|
||||
} else {
|
||||
member = member.toBuilder().setUpdateDt(dt).setCreateDt(dt).build();
|
||||
if (isAdmin) {
|
||||
if (member.getType() == GroupMemberType_Owner) {
|
||||
builder.setType(GroupMemberType_Normal);
|
||||
LOG.error("group member conflicted, group info owner is {}, and group member {} type is owner, set the member to normal member", owner, member.getMemberId());
|
||||
}
|
||||
} else {
|
||||
builder.setType(GroupMemberType_Normal);
|
||||
}
|
||||
}
|
||||
|
||||
if(!StringUtil.isNullOrEmpty(memberExtra)) {
|
||||
builder.setExtra(memberExtra);
|
||||
}
|
||||
|
||||
member = builder.build();
|
||||
groupMembers.put(groupId, member);
|
||||
updatedMemberList.add(member);
|
||||
dt++;
|
||||
}
|
||||
|
||||
if(!hasOwnerMember && !StringUtil.isNullOrEmpty(owner)) {
|
||||
WFCMessage.GroupMember member = WFCMessage.GroupMember.newBuilder().setMemberId(owner).setUpdateDt(dt).setCreateDt(dt).setType(ProtoConstants.GroupMemberType.GroupMemberType_Owner).build();
|
||||
WFCMessage.GroupMember member;
|
||||
if(!StringUtil.isNullOrEmpty(memberExtra)) {
|
||||
member = WFCMessage.GroupMember.newBuilder().setMemberId(owner).setExtra(memberExtra).setUpdateDt(dt).setCreateDt(dt).setType(ProtoConstants.GroupMemberType.GroupMemberType_Owner).build();
|
||||
} else {
|
||||
member = WFCMessage.GroupMember.newBuilder().setMemberId(owner).setUpdateDt(dt).setCreateDt(dt).setType(ProtoConstants.GroupMemberType.GroupMemberType_Owner).build();
|
||||
}
|
||||
groupMembers.put(groupId, member);
|
||||
updatedMemberList.add(member);
|
||||
}
|
||||
@@ -928,7 +1013,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
.build();
|
||||
|
||||
mIMap.set(groupId, groupInfo);
|
||||
databaseStore.persistGroupMember(groupId, updatedMemberList);
|
||||
databaseStore.persistGroupMember(groupId, updatedMemberList, false);
|
||||
|
||||
callbackGroupEvent(fromUser, groupInfo.getTargetId(), ProtoConstants.GroupUpdateEventType.Group_Event_Create);
|
||||
return groupInfo;
|
||||
@@ -1054,7 +1139,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode addGroupMembers(String operator, boolean isAdmin, String groupId, List<WFCMessage.GroupMember> memberList) {
|
||||
public ErrorCode addGroupMembers(String operator, boolean isAdmin, String groupId, List<WFCMessage.GroupMember> memberList, String extra) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
IMap<String, WFCMessage.GroupInfo> mIMap = hzInstance.getMap(GROUPS_MAP);
|
||||
|
||||
@@ -1111,18 +1196,24 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
List<WFCMessage.GroupMember> tmp = new ArrayList<>();
|
||||
ArrayList<String> newInviteUsers = new ArrayList<>();
|
||||
for (WFCMessage.GroupMember member : memberList) {
|
||||
WFCMessage.GroupMember.Builder builder = member.toBuilder();
|
||||
builder.setUpdateDt(updateDt).setCreateDt(updateDt);
|
||||
if (member.getMemberId().equals(groupInfo.getOwner())) {
|
||||
member = member.toBuilder().setType(GroupMemberType_Owner).setUpdateDt(updateDt).setCreateDt(updateDt).build();
|
||||
builder.setType(GroupMemberType_Owner).build();
|
||||
} else {
|
||||
if (isAdmin) {
|
||||
if (member.getType() != GroupMemberType_Owner)
|
||||
member = member.toBuilder().setUpdateDt(updateDt).setCreateDt(updateDt).build();
|
||||
else
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
if (member.getType() == GroupMemberType_Owner) {
|
||||
builder.setType(GroupMemberType_Normal);
|
||||
LOG.error("group member conflicted, group info owner is {}, and group member {} type is owner, set the member to normal member", groupInfo.getOwner(), member.getMemberId());
|
||||
}
|
||||
} else {
|
||||
member = member.toBuilder().setType(GroupMemberType_Normal).setUpdateDt(updateDt).setCreateDt(updateDt).build();
|
||||
builder.setType(GroupMemberType_Normal);
|
||||
}
|
||||
}
|
||||
if(!StringUtil.isNullOrEmpty(extra)) {
|
||||
builder.setExtra(extra);
|
||||
}
|
||||
member = builder.build();
|
||||
tmp.add(member);
|
||||
newInviteUsers.add(member.getMemberId());
|
||||
updateDt++;
|
||||
@@ -1147,7 +1238,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
databaseStore.persistGroupMember(groupId, memberList);
|
||||
databaseStore.persistGroupMember(groupId, memberList, true);
|
||||
databaseStore.updateGroupMemberCountDt(groupId);
|
||||
|
||||
groupMembers.remove(groupId);
|
||||
@@ -1472,7 +1563,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if (member.getMemberId().equals(memberId)) {
|
||||
groupMembers.remove(groupId, member);
|
||||
member = member.toBuilder().setAlias(alias).setUpdateDt(updateDt).build();
|
||||
databaseStore.persistGroupMember(groupId, Arrays.asList(member));
|
||||
databaseStore.persistGroupMember(groupId, Arrays.asList(member), false);
|
||||
databaseStore.updateGroupMemberDt(groupId, updateDt);
|
||||
groupMembers.put(groupId, member);
|
||||
|
||||
@@ -1629,13 +1720,13 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if (newOwner.equals(member.getMemberId())) {
|
||||
groupMembers.remove(groupId, member);
|
||||
member = member.toBuilder().setType(GroupMemberType_Owner).setUpdateDt(updateDt).build();
|
||||
databaseStore.persistGroupMember(groupId, Arrays.asList(member));
|
||||
databaseStore.persistGroupMember(groupId, Arrays.asList(member), false);
|
||||
groupMembers.put(groupId, member);
|
||||
modifyMemeberCount++;
|
||||
} else if(member.getType() == GroupMemberType_Owner) {
|
||||
groupMembers.remove(groupId, member);
|
||||
member = member.toBuilder().setType(GroupMemberType_Normal).setUpdateDt(updateDt).build();
|
||||
databaseStore.persistGroupMember(groupId, Arrays.asList(member));
|
||||
databaseStore.persistGroupMember(groupId, Arrays.asList(member), false);
|
||||
groupMembers.put(groupId, member);
|
||||
modifyMemeberCount++;
|
||||
}
|
||||
@@ -1673,7 +1764,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if (userList.contains(member.getMemberId())) {
|
||||
groupMembers.remove(groupId, member);
|
||||
member = member.toBuilder().setType(type == 0 ? ProtoConstants.GroupMemberType.GroupMemberType_Normal : ProtoConstants.GroupMemberType.GroupMemberType_Manager).setUpdateDt(updateDt).build();
|
||||
databaseStore.persistGroupMember(groupId, Arrays.asList(member));
|
||||
databaseStore.persistGroupMember(groupId, Arrays.asList(member), false);
|
||||
groupMembers.put(groupId, member);
|
||||
}
|
||||
}
|
||||
@@ -1788,7 +1879,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
if (!canRecall && message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group) {
|
||||
if (!canRecall && !mDisableGroupManagerRecall && message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group) {
|
||||
IMap<String, WFCMessage.GroupInfo> groupMap = hzInstance.getMap(GROUPS_MAP);
|
||||
|
||||
WFCMessage.GroupInfo groupInfo = groupMap.get(message.getConversation().getTarget());
|
||||
@@ -2054,7 +2145,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
if (session.getPlatform() == Platform_LINUX || session.getPlatform() == Platform_Windows || session.getPlatform() == Platform_OSX) {
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue(online ? (System.currentTimeMillis() + "|" + session.getPlatform() + "|" + session.getClientID() + "|" + session.getPhoneName()) : "").build());
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue(online ? (System.currentTimeMillis() + "|" + session.getPlatform() + "|" + session.getClientID() + "|" + session.getPhoneName()) : "").build(), session.clientID);
|
||||
} else {
|
||||
String value = null;
|
||||
for (MemorySessionStore.Session s : m_Server.getStore().sessionsStore().sessionForUser(session.username)) {
|
||||
@@ -2080,11 +2171,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
WFCMessage.UserSettingEntry pcentry = getUserSetting(session.getUsername(), kUserSettingPCOnline, "PC");
|
||||
if (value != null) {
|
||||
if (pcentry == null || StringUtil.isNullOrEmpty(pcentry.getValue())) {
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue(value).build());
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue(value).build(), session.clientID);
|
||||
}
|
||||
} else {
|
||||
if (pcentry != null && !StringUtil.isNullOrEmpty(pcentry.getValue())) {
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue("").build());
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue("").build(), session.clientID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2162,6 +2253,13 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if((flag & Update_User_Extra) > 0) {
|
||||
builder.setExtra(userInfo.getExtra());
|
||||
}
|
||||
if((flag & Update_User_Name) > 0) {
|
||||
if(StringUtil.isNullOrEmpty(userInfo.getName())) {
|
||||
LOG.error("Modify user info failure, name not exist!");
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
}
|
||||
builder.setName(userInfo.getName());
|
||||
}
|
||||
builder.setUpdateDt(System.currentTimeMillis());
|
||||
user = builder.build();
|
||||
try {
|
||||
@@ -2401,6 +2499,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mDisableStrangerChat) {
|
||||
//在禁止私聊时,允许机器人,物联网设备及管理员进行私聊。
|
||||
IMap<String, WFCMessage.User> mUserMap = hzInstance.getMap(USERS);
|
||||
@@ -2481,6 +2580,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
if(mSyncDataPartSize > 0 && out.size() > mSyncDataPartSize) {
|
||||
out.sort(Comparator.comparingLong(FriendData::getTimestamp));
|
||||
out = out.subList(0, mSyncDataPartSize);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -2526,12 +2630,16 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
if(mSyncDataPartSize > 0 && out.size() > mSyncDataPartSize) {
|
||||
out.sort(Comparator.comparingLong(WFCMessage.FriendRequest::getUpdateDt));
|
||||
out = out.subList(0, mSyncDataPartSize);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode saveAddFriendRequest(String userId, WFCMessage.AddFriendRequest request, long[] head, boolean isAdmin) {
|
||||
if (mDisableFriendRequest) {
|
||||
if (!isAdmin && mDisableFriendRequest) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
@@ -2584,6 +2692,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
.setFromUid(userId)
|
||||
.setToUid(request.getTargetUid())
|
||||
.setReason(request.getReason())
|
||||
.setExtra(request.getExtra())
|
||||
.setStatus(ProtoConstants.FriendRequestStatus.RequestStatus_Sent)
|
||||
.setToReadStatus(false)
|
||||
.setUpdateDt(System.currentTimeMillis())
|
||||
@@ -3018,6 +3127,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
if(mSyncDataPartSize > 0 && ec == ErrorCode.ERROR_CODE_SUCCESS && builder.getEntryCount() > mSyncDataPartSize) {
|
||||
List<WFCMessage.UserSettingEntry> list = new ArrayList<>(builder.getEntryList());
|
||||
list.sort(Comparator.comparingLong(WFCMessage.UserSettingEntry::getUpdateDt));
|
||||
list = list.subList(0, mSyncDataPartSize);
|
||||
builder.clearEntry().addAllEntry(list);
|
||||
}
|
||||
return ec;
|
||||
}
|
||||
|
||||
@@ -3077,7 +3192,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long updateUserSettings(String userId, WFCMessage.ModifyUserSettingReq request) {
|
||||
public long updateUserSettings(String userId, WFCMessage.ModifyUserSettingReq request, String clientId) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
|
||||
|
||||
@@ -3117,7 +3232,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
} else if(request.getScope() == UserSettingScope.kUserSettingHiddenNotificationDetail) {
|
||||
userPushHiddenDetail.remove(userId);
|
||||
}
|
||||
IMHandler.getPublisher().publishNotification(IMTopic.NotifyUserSettingTopic, userId, updateDt);
|
||||
IMHandler.getPublisher().publishNotification(IMTopic.NotifyUserSettingTopic, userId, updateDt, clientId);
|
||||
return updateDt;
|
||||
}
|
||||
|
||||
@@ -3349,6 +3464,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
public ErrorCode listenChannel(String operator, String channelId, boolean listen) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
MultiMap<String, String> listeners = hzInstance.getMultiMap(CHANNEL_LISTENERS);
|
||||
IMap<String, WFCMessage.ChannelInfo> mIMap = hzInstance.getMap(CHANNELS);
|
||||
WFCMessage.ChannelInfo channelInfo = mIMap.get(channelId);
|
||||
if(channelInfo != null && (channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Private) > 0) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
getChannelListener(channelId);
|
||||
|
||||
@@ -3384,12 +3504,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
@Override
|
||||
public boolean checkUserInChannel(String user, String channelId) {
|
||||
Collection<String> chatroomMembers = getChannelListener(channelId);
|
||||
if (chatroomMembers == null) {
|
||||
Collection<String> channelMembers = getChannelListener(channelId);
|
||||
if (channelMembers == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!chatroomMembers.contains(user)) {
|
||||
if(!channelMembers.contains(user)) {
|
||||
IMap<String, WFCMessage.ChannelInfo> mIMap = m_Server.getHazelcastInstance().getMap(CHANNELS);
|
||||
WFCMessage.ChannelInfo info = mIMap.get(channelId);
|
||||
if (info == null || !info.getOwner().equals(user)) {
|
||||
@@ -3467,6 +3587,21 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
return mForbiddenClientSendTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getBlackListExceptionTypes() {
|
||||
return mBlackListExceptionTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getGroupMuteExceptionTypes() {
|
||||
return mGroupMuteExceptionTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getGlobalMuteExceptionTypes() {
|
||||
return mGlobalMuteExceptionTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessageHead(String user) {
|
||||
TreeMap<Long, Long> maps = userMessages.get(user);
|
||||
|
||||
+13
-20
@@ -16,18 +16,18 @@ import cn.wildfirechat.common.ErrorCode;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class RPCCenter {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RPCCenter.class);
|
||||
public class ServerAPIHelper {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServerAPIHelper.class);
|
||||
public static final String CHECK_USER_ONLINE_REQUEST = "check_user_online";
|
||||
public static final String KICKOFF_USER_REQUEST = "kickoff_user";
|
||||
|
||||
private Server server;
|
||||
public ConcurrentHashMap<Integer, RequestInfo> requestMap = new ConcurrentHashMap<>();
|
||||
private AtomicInteger aiRequestId = new AtomicInteger(1);
|
||||
public ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(2);
|
||||
private static Server server;
|
||||
public static ConcurrentHashMap<Integer, RequestInfo> requestMap = new ConcurrentHashMap<>();
|
||||
private static AtomicInteger aiRequestId = new AtomicInteger(1);
|
||||
public static ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(2);
|
||||
|
||||
public void init(Server server) {
|
||||
this.server = server;
|
||||
public static void init(Server s) {
|
||||
server = s;
|
||||
}
|
||||
|
||||
public interface Callback {
|
||||
@@ -37,18 +37,11 @@ public class RPCCenter {
|
||||
Executor getResponseExecutor();
|
||||
}
|
||||
|
||||
private static RPCCenter instance;
|
||||
|
||||
public static RPCCenter getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new RPCCenter();
|
||||
}
|
||||
return instance;
|
||||
public static void sendRequest(String fromUser, String clientId, String request, byte[] message, Callback callback, boolean isAdmin) {
|
||||
sendRequest(fromUser, clientId, request, message, callback, isAdmin, false);
|
||||
}
|
||||
|
||||
protected RPCCenter() {}
|
||||
|
||||
public void sendRequest(String fromUser, String clientId, String request, byte[] message, String target, TargetEntry.Type type, Callback callback, boolean isAdmin) {
|
||||
public static void sendRequest(String fromUser, String clientId, String request, byte[] message, Callback callback, boolean isAdmin, boolean isRobotOrChannel) {
|
||||
int requestId = 0;
|
||||
|
||||
if (callback != null) {
|
||||
@@ -61,10 +54,10 @@ public class RPCCenter {
|
||||
requestMap.put(requestId, new RequestInfo(fromUser, clientId, callback, message, requestId, request));
|
||||
}
|
||||
|
||||
server.internalRpcMsg(fromUser, clientId, message, requestId, "", request, isAdmin);
|
||||
server.onApiMessage(fromUser, clientId, message, requestId, "", request, isAdmin, isRobotOrChannel);
|
||||
}
|
||||
|
||||
public void sendResponse(int errorCode, byte[] message, String toUuid, int requestId) {
|
||||
public static void sendResponse(int errorCode, byte[] message, String toUuid, int requestId) {
|
||||
LOG.debug("send async reponse to {} with requestId {}", toUuid, requestId);
|
||||
if (requestId > 0) {
|
||||
RequestInfo info = requestMap.remove(requestId);
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* 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 io.moquette.persistence;
|
||||
|
||||
public class TargetEntry {
|
||||
public TargetEntry(Type type, String target) {
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
TARGET_TYPE_USER,
|
||||
TARGET_TYPE_CHATROOM,
|
||||
TARGET_TYPE_MASTER_NODE,
|
||||
}
|
||||
public Type type;
|
||||
public String target;
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
package io.moquette.persistence.remote;
|
||||
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.ServerAPIHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class RequestInfo {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RequestInfo.class);
|
||||
public final RPCCenter.Callback callback;
|
||||
public final ServerAPIHelper.Callback callback;
|
||||
final byte[] message;
|
||||
final int requestId;
|
||||
final String fromUser;
|
||||
@@ -25,15 +25,15 @@ public class RequestInfo {
|
||||
final String clientId;
|
||||
public final ScheduledFuture future;
|
||||
|
||||
public RequestInfo(String fromUser, String clientId, RPCCenter.Callback callback, byte[] message, int requestId, String request) {
|
||||
public RequestInfo(String fromUser, String clientId, ServerAPIHelper.Callback callback, byte[] message, int requestId, String request) {
|
||||
this.callback = callback;
|
||||
this.message = message;
|
||||
this.requestId = requestId;
|
||||
this.fromUser = fromUser;
|
||||
this.clientId = clientId;
|
||||
this.request = request;
|
||||
this.future = RPCCenter.getInstance().scheduledExecutorService.schedule(() -> {
|
||||
RequestInfo info = RPCCenter.getInstance().requestMap.remove(requestId);
|
||||
this.future = ServerAPIHelper.scheduledExecutorService.schedule(() -> {
|
||||
RequestInfo info = ServerAPIHelper.requestMap.remove(requestId);
|
||||
if (info != null) {
|
||||
LOG.error("Request timeout. fromUser {}, cliendId {}, requestId {}, request {}", fromUser, clientId, requestId, request);
|
||||
info.callback.getResponseExecutor().execute(() -> {
|
||||
|
||||
@@ -35,7 +35,6 @@ import io.moquette.spi.IStore;
|
||||
import io.moquette.spi.impl.ProtocolProcessor;
|
||||
import io.moquette.spi.impl.ProtocolProcessorBootstrapper;
|
||||
import io.moquette.spi.impl.security.AES;
|
||||
import io.moquette.spi.impl.subscriptions.Token;
|
||||
import io.moquette.spi.security.IAuthenticator;
|
||||
import io.moquette.spi.security.IAuthorizator;
|
||||
import io.moquette.spi.security.ISslContextCreator;
|
||||
@@ -347,6 +346,7 @@ public class Server {
|
||||
file.mkdirs();
|
||||
}
|
||||
ServerSetting.setRoot(file);
|
||||
MediaServerConfig.FILE_STROAGE_REMOTE_SERVER_URL = config.getProperty(FILE_STORAGE_REMOTE_SERVER_URL);
|
||||
|
||||
MediaServerConfig.USER_QINIU = Integer.parseInt(config.getProperty(BrokerConstants.USER_QINIU)) > 0;
|
||||
}
|
||||
@@ -410,7 +410,7 @@ public class Server {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
RPCCenter.getInstance().init(this);
|
||||
ServerAPIHelper.init(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -418,14 +418,9 @@ public class Server {
|
||||
return hazelcastInstance;
|
||||
}
|
||||
|
||||
public void internalRpcMsg(String fromUser, String clientId, byte[] message, int messageId, String from, String request, boolean isAdmin) {
|
||||
|
||||
if (!m_initialized) {
|
||||
LOG.error("Moquette is not started, internal message cannot be notify");
|
||||
return;
|
||||
}
|
||||
LOG.debug("internalNotifyMsg");
|
||||
m_processor.onRpcMsg(fromUser, clientId, message, messageId, from, request, isAdmin);
|
||||
public void onApiMessage(String fromUser, String clientId, byte[] message, int messageId, String from, String request, boolean isAdmin, boolean isRobotOrChannel) {
|
||||
LOG.debug("onApiMessage");
|
||||
m_processor.onApiMessage(fromUser, clientId, message, messageId, from, request, isAdmin, isRobotOrChannel);
|
||||
}
|
||||
|
||||
public boolean isShutdowning() {
|
||||
|
||||
@@ -27,6 +27,7 @@ public class MediaServerConfig {
|
||||
public static String SERVER_IP = "localhost";
|
||||
public static int HTTP_SERVER_PORT = 8080;
|
||||
public static String FILE_STROAGE_ROOT = "fs";
|
||||
public static String FILE_STROAGE_REMOTE_SERVER_URL;
|
||||
public static boolean USER_QINIU = false;
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user