Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49eb57af00 | ||
|
|
6bd6a80e71 | ||
|
|
38b84f0fa5 | ||
|
|
1f46debd0c | ||
|
|
37998e76d1 | ||
|
|
80b5508533 | ||
|
|
a646cc8227 | ||
|
|
92692adf52 | ||
|
|
b2cfc2b99b | ||
|
|
86e08f6151 | ||
|
|
8d852eb2d1 | ||
|
|
8bef018911 | ||
|
|
5e13419c28 | ||
|
|
503a7ae18f | ||
|
|
dfb9638a38 | ||
|
|
8452b0675b | ||
|
|
930643706a | ||
|
|
a2eac1f721 | ||
|
|
6e994cd694 | ||
|
|
c82869c631 | ||
|
|
f5a94868c4 | ||
|
|
c5628d613b | ||
|
|
9509b1ffa8 | ||
|
|
c1dac8a21e | ||
|
|
950846df45 | ||
|
|
31d96e2dc6 | ||
|
|
031e96075e | ||
|
|
bf2caeac6c | ||
|
|
12e523b37e | ||
|
|
576c985d8f | ||
|
|
9365807f47 | ||
|
|
25ce10fa61 | ||
|
|
09c333501f | ||
|
|
c51b09ee3a | ||
|
|
4d82eace86 | ||
|
|
385b03a163 | ||
|
|
4b438afa69 | ||
|
|
66961b94da | ||
|
|
39b62e5942 | ||
|
|
5bb8ab3d95 | ||
|
|
8dfc23b61d | ||
|
|
c8769808b5 | ||
|
|
2fc106aa26 | ||
|
|
da0b725ff8 | ||
|
|
15703d66fb | ||
|
|
c68beeaa51 | ||
|
|
5ef8868916 | ||
|
|
24488cc985 | ||
|
|
1c9faaa1e6 | ||
|
|
ac32875b14 | ||
|
|
07c1dd29e0 | ||
|
|
bd93233c34 | ||
|
|
20aec2fbcf | ||
|
|
a149139143 | ||
|
|
c857d1abb7 | ||
|
|
dde9da7006 | ||
|
|
d18a1970e5 | ||
|
|
66b9aeec17 | ||
|
|
ea301a3923 | ||
|
|
ced272a783 | ||
|
|
c9f320da31 | ||
|
|
025873e66b | ||
|
|
ecddc40aa5 | ||
|
|
cb13a02b75 | ||
|
|
5714a9a1d3 | ||
|
|
d0671c1682 | ||
|
|
88b3ac42bb | ||
|
|
4ecf3dec76 | ||
|
|
b4b70ca7e5 | ||
|
|
d3aa68df05 | ||
|
|
36aa0518ed | ||
|
|
b1c5692322 | ||
|
|
db24edf7d5 | ||
|
|
798a576d0b | ||
|
|
b49225fbf7 | ||
|
|
439cf82fcc | ||
|
|
7527bf4761 | ||
|
|
a9abda9ae9 | ||
|
|
757186d77b | ||
|
|
3e769c885c | ||
|
|
af4d73a0d5 | ||
|
|
331c38cc98 | ||
|
|
fbd1a7f5dc | ||
|
|
675025c0ec | ||
|
|
3e1efe4c4c | ||
|
|
679e76a5f6 | ||
|
|
5a338cdba1 | ||
|
|
3ef973ffc5 | ||
|
|
d36c3f4f77 | ||
|
|
79bd0c3304 | ||
|
|
721abfe3a5 | ||
|
|
77a5d61861 | ||
|
|
34aee2290c | ||
|
|
4b93157816 | ||
|
|
d66b01c681 | ||
|
|
939dfc2c9b | ||
|
|
1578c4c77d | ||
|
|
640a4fa47c | ||
|
|
3d50b65ad9 | ||
|
|
3f9eef9538 | ||
|
|
f655f519d0 | ||
|
|
59add35703 | ||
|
|
0ff21e70b5 | ||
|
|
cfc97e602e | ||
|
|
4661b8c856 | ||
|
|
e955153d53 | ||
|
|
911dcb99ec | ||
|
|
40ff829c72 | ||
|
|
729f3485de | ||
|
|
84db868244 | ||
|
|
126a9af2ac | ||
|
|
c9dc33d285 | ||
|
|
49ee1d1d57 | ||
|
|
1a477068fb | ||
|
|
d633830f7a | ||
|
|
b2bc616e18 | ||
|
|
934f8ba4d7 | ||
|
|
477616ce38 | ||
|
|
f66d0e5cd7 | ||
|
|
2bb6de1198 | ||
|
|
6570d71234 | ||
|
|
64c7da70e7 | ||
|
|
a2eadf5a78 | ||
|
|
7fb040ac1a | ||
|
|
b575274680 | ||
|
|
8bfe3583b9 | ||
|
|
ab3882e1d4 | ||
|
|
0cbb9fd1a4 | ||
|
|
115a597038 | ||
|
|
a8fde271ea | ||
|
|
b0143bb5bf | ||
|
|
025af5eae0 | ||
|
|
ce16f87e12 | ||
|
|
b47084f61f | ||
|
|
936e3581b4 | ||
|
|
cc756842c4 | ||
|
|
9aa29685ef | ||
|
|
c1bb45fe14 | ||
|
|
928555b36e | ||
|
|
744d516932 | ||
|
|
8721c80a9f | ||
|
|
06698a54e1 | ||
|
|
7f48b54b73 | ||
|
|
cf619ebeee | ||
|
|
9fdc6c2e1b | ||
|
|
1d309816ba | ||
|
|
21aa248d49 | ||
|
|
90c8e49808 | ||
|
|
2326850538 | ||
|
|
cef0cb1076 | ||
|
|
9b34e51494 |
@@ -51,3 +51,6 @@ broker/config/git.properties
|
||||
distribution/src/main/resources/git.properties
|
||||
broker/h2db
|
||||
broker/media
|
||||
common/target
|
||||
server/target
|
||||
sdk/target
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
| 仓库 | 说明 | 备注 |
|
||||
| ------------------------------------------------------------ | ------------------------------------------------------- | ---------------------------------------------- |
|
||||
| [android-chat](https://github.com/wildfirechat/android-chat) | 野火IM Android App | 可以很方便地进行二次开发,或集成到现有应用当中 |
|
||||
| [ios-chat](https://github.com/wildfirechat/ios-chat) | 野火IM iOS App | 可以很方便地进行二次开发,或集成到现有应用当中 |
|
||||
| [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平台应用 | |
|
||||
| [proto](https://github.com/wildfirechat/proto) | 野火IM的协议栈实现 | |
|
||||
| [server](https://github.com/wildfirechat/server) | IM server | |
|
||||
@@ -24,7 +24,11 @@
|
||||
### 联系我们
|
||||
问题讨论请加群:822762829
|
||||
|
||||
<img src="http://static.wildfirechat.cn/qr_qqgroup.jpeg" width = 50% height = 50% />
|
||||
微信公众号:
|
||||
|
||||
<img src="http://static.wildfirechat.cn/wx_wfc_qrcode.jpg" width = 50% height = 50% />
|
||||
|
||||
> 强烈建议关注我们的公众号。我们有新版本发布或者有重大更新会通过公众号通知大家,另外我们也会不定期的发布一些关于野火IM的技术介绍。
|
||||
|
||||
#### 体验Demo
|
||||
我们提供了体验demo,请使用微信扫码下载安装体验
|
||||
@@ -54,9 +58,22 @@
|
||||
|
||||
<img src="http://static.wildfirechat.cn/ios-voip-view.png" width = 50% height = 50% />
|
||||
|
||||
## 编译
|
||||
在安装JDK1.8以上及maven的前提下,在命令行中执行```mvn clean compile package```,生成的目标文件在```./distribution/target/distribution-xxxx-bundle-tar.tar.gz```
|
||||
|
||||
## 捐赠者名单
|
||||
|
||||
| 捐赠者 | 商标 | 金额 | 简介 |
|
||||
| ----- | ---- | -------- | --- |
|
||||
| [SAMOS](http://samos.io) |  | 保密 | 一站式区块链解决方案服务商(http://samos.io) |
|
||||
|
||||
## 特别感谢
|
||||
1. [moquette](https://github.com/moquette-io/moquette) 本项目是基于此项目二次开发而来,处理MQTT相关业务。
|
||||
2. [loServer](https://github.com/looly/loServer) 本项目使用loServer处理HTTP相关业务。
|
||||
|
||||
*** 对他们表示诚挚的感谢🙏 ***
|
||||
|
||||
## License
|
||||
|
||||
1. Under the Creative Commons Attribution-NoDerivs 3.0 Unported license. See the [LICENSE](https://github.com/wildfirechat/server/blob/wildfirechat/LICENSE) file for details.
|
||||
2. Under the Anti 996 License. See the [Anti 996 LICENSE](https://github.com/wildfirechat/server/blob/wildfirechat/LICENSE_996) file for details.
|
||||
2. Under the Anti 996 License. See the [Anti 996 LICENSE](https://github.com/wildfirechat/server/blob/wildfirechat/LICENSE_996) file for details.
|
||||
|
||||
@@ -3,15 +3,9 @@
|
||||
xsi:schemaLocation="http://www.hazelcast.com/schema/config
|
||||
http://www.hazelcast.com/schema/config/hazelcast-config-3.5.xsd"
|
||||
xmlns="http://www.hazelcast.com/schema/config">
|
||||
|
||||
<group>
|
||||
<!--<name>wfc-dev</name>-->
|
||||
<name>wfc-pro</name>
|
||||
</group>
|
||||
|
||||
<network>
|
||||
<join>
|
||||
<multicast enabled="true"/>
|
||||
<multicast enabled="false"/>
|
||||
</join>
|
||||
</network>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#*********************************************************************
|
||||
#服务器的接入IP。给客户端提供是${server.ip}和${http_port}。
|
||||
#客户端会从${http_port}端口获取到长链接端口。
|
||||
server.ip 0.0.0.0
|
||||
server.ip 192.168.1.100
|
||||
|
||||
##原生客户端长链接端口
|
||||
port 1883
|
||||
@@ -27,17 +27,24 @@ host 0.0.0.0
|
||||
local_port 80
|
||||
|
||||
##是否使用内置DB。0使用mysql;1使用h2db
|
||||
embed.db 1
|
||||
embed.db 0
|
||||
|
||||
##服务器管理接口密钥
|
||||
http.admin.secret_key 123456
|
||||
|
||||
##服务器API接口参数是否检查时间。当设置为false时,所有的请求会检查时间的有效性;当设置为true时,可以在http.admin.secret_key保持不变的情况下,使用固定的服务API签名
|
||||
##nonce = "76616", timestamp = "1558350862502", sign = "b98f9b0717f59febccf1440067a7f50d9b31bdde"
|
||||
http.admin.no_check_time true
|
||||
|
||||
##客户端协议栈密钥,需要与客户端协议栈文件libemqq.cc文件中的aes_key值保持一致,16进制byte用逗号分割。这个密钥对安全性帮助不大,客户不要修改
|
||||
client.proto.secret_key 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F
|
||||
|
||||
##用来生产im token的私钥,只在服务器使用,客户端不用。正式使用时为了安全一定要修改这个值,切记切记
|
||||
token.key testim
|
||||
|
||||
##首次登录,是否接收之前的历史消息。0 不接收;1接收。
|
||||
message.roaming 1
|
||||
|
||||
#*********************************************************************
|
||||
# hazelcase configuration
|
||||
#*********************************************************************
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
|
||||
insert into t_user (`_uid`,`_name`,`_display_name`,`_type`,`_dt`) values ('admin','admin','系统管理员',3,1);
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
ALTER TABLE t_user_session MODIFY _token VARCHAR(240) DEFAULT NULL;
|
||||
@@ -0,0 +1,4 @@
|
||||
alter table `t_group` add column `_mute` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_join_type` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_private_chat` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_searchable` tinyint NOT NULL DEFAULT 0;
|
||||
Executable
@@ -1,26 +1,4 @@
|
||||
DROP TABLE IF EXISTS `t_messages`;
|
||||
CREATE TABLE `t_messages` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`_mid` bigint(20) NOT NULL,
|
||||
`_from` varchar(64) NOT NULL,
|
||||
`_type` tinyint NOT NULL DEFAULT 0,
|
||||
`_target` varchar(64) NOT NULL,
|
||||
`_line` int(11) NOT NULL DEFAULT 0,
|
||||
`_data` BLOB NOT NULL,
|
||||
`_searchable_key` TEXT DEFAULT NULL,
|
||||
`_dt` DATETIME NOT NULL DEFAULT NOW(),
|
||||
UNIQUE INDEX `message_uid_index` (`_mid` ASC)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS `t_user_messages`;
|
||||
CREATE TABLE `t_user_messages` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`_mid` bigint(20) NOT NULL,
|
||||
`_uid` varchar(64) NOT NULL,
|
||||
`_seq` bigint(20) NOT NULL,
|
||||
`_dt` DATETIME NOT NULL DEFAULT NOW(),
|
||||
UNIQUE INDEX `message_seq_uid_index` (`_uid` DESC, `_seq` DESC)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS `t_group`;
|
||||
CREATE TABLE `t_group` (
|
||||
@@ -181,6 +159,7 @@ CREATE TABLE `t_robot` (
|
||||
`_owner` varchar(64) DEFAULT '',
|
||||
`_secret` varchar(64) DEFAULT '',
|
||||
`_callback` varchar(1024) DEFAULT '',
|
||||
`_state` tinyint DEFAULT 0,
|
||||
`_extra` TEXT DEFAULT NULL,
|
||||
`_dt` bigint(20) NOT NULL,
|
||||
UNIQUE INDEX `robot_uid_index` (`_uid` ASC),
|
||||
@@ -219,11 +198,3 @@ CREATE TABLE `t_sensitiveword` (
|
||||
`_word` TEXT DEFAULT NULL
|
||||
);
|
||||
|
||||
|
||||
|
||||
insert into t_chatroom (`_cid`, `_title`, `_desc`,`_dt`) values ('chatroom1','火信聊天室1','火信测试聊天室1,用来演示聊天室功能', 1);
|
||||
|
||||
insert into t_chatroom (`_cid`, `_title`, `_desc`,`_dt`) values ('chatroom2','火信聊天室2','火信测试聊天室2,用来演示聊天室功能', 1);
|
||||
|
||||
insert into t_chatroom (`_cid`, `_title`, `_desc`,`_dt`) values ('chatroom3','火信聊天室3','火信测试聊天室3,用来演示聊天室功能', 1);
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_messages`;
|
||||
CREATE TABLE `t_messages` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`_mid` bigint(20) NOT NULL,
|
||||
`_from` varchar(64) NOT NULL,
|
||||
`_type` tinyint NOT NULL DEFAULT 0,
|
||||
`_target` varchar(64) NOT NULL,
|
||||
`_line` int(11) NOT NULL DEFAULT 0,
|
||||
`_data` BLOB NOT NULL,
|
||||
`_searchable_key` TEXT DEFAULT NULL,
|
||||
`_dt` DATETIME NOT NULL DEFAULT NOW(),
|
||||
UNIQUE INDEX `message_uid_index` (`_mid` ASC)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS `t_user_messages`;
|
||||
CREATE TABLE `t_user_messages` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`_mid` bigint(20) NOT NULL,
|
||||
`_uid` varchar(64) NOT NULL,
|
||||
`_seq` bigint(20) NOT NULL,
|
||||
`_dt` DATETIME NOT NULL DEFAULT NOW(),
|
||||
UNIQUE INDEX `message_seq_uid_index` (`_uid` DESC, `_seq` DESC)
|
||||
);
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
|
||||
insert into t_chatroom (`_cid`, `_title`, `_desc`,`_dt`) values ('chatroom1','火信聊天室1','火信测试聊天室1,用来演示聊天室功能', 1);
|
||||
|
||||
insert into t_chatroom (`_cid`, `_title`, `_desc`,`_dt`) values ('chatroom2','火信聊天室2','火信测试聊天室2,用来演示聊天室功能', 1);
|
||||
|
||||
insert into t_chatroom (`_cid`, `_title`, `_desc`,`_dt`) values ('chatroom3','火信聊天室3','火信测试聊天室3,用来演示聊天室功能', 1);
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
|
||||
insert into t_user (`_uid`,`_name`,`_display_name`,`_portrait`,`_type`,`_dt`) values ('FireRobot','FireRobot','小火','http://cdn2.wildfirechat.cn/robot.png',1,1);
|
||||
|
||||
insert into t_robot (`_uid`,`_owner`,`_secret`,`_callback`,`_state`,`_dt`) values ('FireRobot', 'FireRobot', '123456', 'http://127.0.0.1:8883/robot/recvmsg', 0, 1);
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
|
||||
alter table t_friend add column `_alias` varchar(64) DEFAULT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table t_user add column `_createTime` TIMESTAMP default CURRENT_TIMESTAMP;
|
||||
alter table t_group add column `_createTime` TIMESTAMP default CURRENT_TIMESTAMP;
|
||||
@@ -0,0 +1 @@
|
||||
alter table `t_messages` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_sensitive_messages`;
|
||||
CREATE TABLE `t_sensitive_messages` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`_mid` bigint(20) NOT NULL,
|
||||
`_from` varchar(64) NOT NULL,
|
||||
`_type` tinyint NOT NULL DEFAULT 0,
|
||||
`_target` varchar(64) NOT NULL,
|
||||
`_line` int(11) NOT NULL DEFAULT 0,
|
||||
`_data` BLOB NOT NULL,
|
||||
`_searchable_key` TEXT DEFAULT NULL,
|
||||
`_dt` DATETIME NOT NULL DEFAULT NOW(),
|
||||
`_content_type` int(11) NOT NULL DEFAULT 0,
|
||||
UNIQUE INDEX `sensitive_message_uid_index` (`_mid` ASC)
|
||||
);
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
|
||||
insert into t_user (`_uid`,`_name`,`_display_name`,`_type`,`_dt`) values ('admin','admin','系统管理员',3,1);
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
ALTER TABLE t_user_session MODIFY _token VARCHAR(240) DEFAULT NULL;
|
||||
@@ -0,0 +1,4 @@
|
||||
alter table `t_group` add column `_mute` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_join_type` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_private_chat` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_searchable` tinyint NOT NULL DEFAULT 0;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_session`;
|
||||
CREATE TABLE `t_session` (
|
||||
`row_id` varchar(50) not null primary key,
|
||||
`del_flag` tinyint(1) default 0 null,
|
||||
`create_time` timestamp null,
|
||||
`update_time` timestamp null,
|
||||
`expire_time` timestamp null,
|
||||
`user_id` int null,
|
||||
constraint `t_session_pk_2` unique (`user_id`, `expire_time`)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table t_user MODIFY column `_createTime` DATETIME NOT NULL DEFAULT NOW();
|
||||
alter table t_group MODIFY column `_createTime` DATETIME NOT NULL DEFAULT NOW();
|
||||
@@ -0,0 +1,4 @@
|
||||
alter table t_session MODIFY column `create_time` DATETIME NOT NULL DEFAULT NOW();
|
||||
alter table t_session MODIFY column `update_time` DATETIME NOT NULL DEFAULT NOW();
|
||||
alter table t_session MODIFY column `expire_time` DATETIME NOT NULL DEFAULT NOW();
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
update t_messages_0 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_1 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_2 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_3 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_4 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_5 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_6 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_7 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_8 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_9 set _dt = date_add(_dt, interval 8 hour);
|
||||
|
||||
update t_messages_10 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_11 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_12 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_13 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_14 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_15 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_16 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_17 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_18 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_19 set _dt = date_add(_dt, interval 8 hour);
|
||||
|
||||
update t_messages_20 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_21 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_22 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_23 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_24 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_25 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_26 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_27 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_28 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_29 set _dt = date_add(_dt, interval 8 hour);
|
||||
|
||||
|
||||
update t_messages_30 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_31 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_32 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_33 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_34 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_35 set _dt = date_add(_dt, interval 8 hour);
|
||||
Executable
@@ -1,3 +1,4 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_messages`;
|
||||
CREATE TABLE `t_messages` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
+2353
File diff suppressed because it is too large
Load Diff
+3
@@ -0,0 +1,3 @@
|
||||
insert into t_user (`_uid`,`_name`,`_display_name`,`_portrait`,`_type`,`_dt`) values ('FireRobot','FireRobot','小火','http://cdn2.wildfirechat.cn/robot.png',1,1);
|
||||
|
||||
insert into t_robot (`_uid`,`_owner`,`_secret`,`_callback`,`_state`,`_dt`) values ('FireRobot', 'FireRobot', '123456', 'http://127.0.0.1:8883/robot/recvmsg', 0, 1);
|
||||
+1
@@ -0,0 +1 @@
|
||||
alter table t_friend add column `_alias` varchar(64) DEFAULT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table t_user add column `_createTime` TIMESTAMP default CURRENT_TIMESTAMP;
|
||||
alter table t_group add column `_createTime` TIMESTAMP default CURRENT_TIMESTAMP;
|
||||
@@ -0,0 +1,36 @@
|
||||
alter table `t_messages_0` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_1` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_2` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_3` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_4` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_5` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_6` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_7` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_8` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_9` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_10` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_11` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_12` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_13` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_14` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_15` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_16` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_17` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_18` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_19` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_20` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_21` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_22` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_23` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_24` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_25` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_26` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_27` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_28` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_29` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_30` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_31` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_32` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_33` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_34` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_35` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_sensitive_messages`;
|
||||
CREATE TABLE `t_sensitive_messages` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`_mid` bigint(20) NOT NULL,
|
||||
`_from` varchar(64) NOT NULL,
|
||||
`_type` tinyint NOT NULL DEFAULT 0,
|
||||
`_target` varchar(64) NOT NULL,
|
||||
`_line` int(11) NOT NULL DEFAULT 0,
|
||||
`_data` BLOB NOT NULL,
|
||||
`_searchable_key` TEXT DEFAULT NULL,
|
||||
`_dt` DATETIME NOT NULL,
|
||||
`_content_type` int(11) NOT NULL DEFAULT '0',
|
||||
INDEX `message_uid_index` (`_mid` DESC)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
+24
-39
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.12</version>
|
||||
<version>0.25</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>moquette-broker</artifactId>
|
||||
@@ -37,6 +37,12 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
@@ -44,13 +50,6 @@
|
||||
<version>1.2.14</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
@@ -116,36 +115,6 @@
|
||||
-->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.dropwizard.metrics</groupId>
|
||||
<artifactId>metrics-core</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.dropwizard.metrics</groupId>
|
||||
<artifactId>metrics-jvm</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java -->
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>2.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.librato.metrics</groupId>
|
||||
<artifactId>metrics-librato</artifactId>
|
||||
<version>5.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.bugsnag</groupId>
|
||||
<artifactId>bugsnag</artifactId>
|
||||
<version>[3.0,4.0)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
@@ -249,6 +218,22 @@
|
||||
<version>1.4.197</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.13.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.flywaydb/flyway-core -->
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
<version>5.2.4</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -333,7 +318,7 @@
|
||||
<!--指定"git.properties"文件的存放路径(相对于${project.basedir}的一个路径);-->
|
||||
<generateGitPropertiesFilename>config/git.properties</generateGitPropertiesFilename>
|
||||
<!--".git"文件夹未找到时,构建是否失败;若设置true,则构建失败;若设置false,则跳过执行该目标;默认值:true;-->
|
||||
<failOnNoGitDirectory>true</failOnNoGitDirectory>
|
||||
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||
|
||||
<!--git描述配置,可选;由JGit提供实现;-->
|
||||
<gitDescribe>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
CREATE DATABASE IF NOT EXISTS wfchat CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
@@ -1,83 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
show_help_info(){
|
||||
echo "### Usage: ./initial_db.sh -u{user} -p{password}"
|
||||
echo "### 初始化数据库。"
|
||||
echo "###"
|
||||
|
||||
}
|
||||
|
||||
for i in "$@"
|
||||
do
|
||||
PFLAG=`echo $i|cut -b1-2`
|
||||
PPARAM=`echo $i|cut -b3-`
|
||||
if [ $PFLAG = "-u" ]; then
|
||||
USER=${PPARAM}
|
||||
elif [ $PFLAG = "-p" ]; then
|
||||
PASSWORD=${PPARAM}
|
||||
elif [ $PFLAG = "-h" ]; then
|
||||
show_help_info
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo
|
||||
|
||||
if [ "${USER}" = "" ]; then
|
||||
show_help_info
|
||||
exit 1
|
||||
elif [ "${PASSWORD}" = "" ]; then
|
||||
show_help_info
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
mysql -u${USER} -p${PASSWORD} -e"source 1_create_database.sql;"
|
||||
mysql -u${USER} -p${PASSWORD} -e"use wfchat; source 2_create_table.sql; source 3_create_default_chatroom.sql;"
|
||||
|
||||
for((i=0;i<36;i++));
|
||||
do
|
||||
create_message_tbl_sql="USE wfchat;
|
||||
DROP TABLE IF EXISTS \`t_messages_${i}\`;
|
||||
CREATE TABLE \`t_messages_${i}\` (
|
||||
\`id\` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
\`_mid\` bigint(20) NOT NULL,
|
||||
\`_from\` varchar(64) NOT NULL,
|
||||
\`_type\` tinyint NOT NULL DEFAULT 0,
|
||||
\`_target\` varchar(64) NOT NULL,
|
||||
\`_line\` int(11) NOT NULL DEFAULT 0,
|
||||
\`_data\` BLOB NOT NULL,
|
||||
\`_searchable_key\` TEXT DEFAULT NULL,
|
||||
\`_dt\` DATETIME NOT NULL,
|
||||
INDEX \`message_uid_index\` (\`_mid\` DESC)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
"
|
||||
|
||||
echo "create table t_messages_$i"
|
||||
mysql -u${USER} -p${PASSWORD} -e"${create_message_tbl_sql}"
|
||||
done
|
||||
|
||||
|
||||
for((i=0;i<128;i++));
|
||||
do
|
||||
create_user_message_tbl_sql="USE wfchat;
|
||||
DROP TABLE IF EXISTS \`t_user_messages_${i}\`;
|
||||
CREATE TABLE \`t_user_messages_${i}\` (
|
||||
\`id\` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
\`_mid\` bigint(20) NOT NULL,
|
||||
\`_uid\` varchar(64) NOT NULL,
|
||||
\`_seq\` bigint(20) NOT NULL,
|
||||
\`_dt\` DATETIME NOT NULL DEFAULT NOW(),
|
||||
INDEX \`message_seq_uid_index\` (\`_uid\` DESC, \`_seq\` DESC)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
"
|
||||
|
||||
echo "create table t_user_messages_$i"
|
||||
mysql -u${USER} -p${PASSWORD} -e"${create_user_message_tbl_sql}"
|
||||
done
|
||||
@@ -30,14 +30,14 @@ public class ThreadPoolExecutorWrapper {
|
||||
|
||||
public void execute(Runnable task) {
|
||||
int startCount = runCounter.incrementAndGet();
|
||||
LOG.info("Submit task and current taskcount {}", startCount);
|
||||
LOG.debug("Submit task and current task count {}", startCount);
|
||||
final long startTime = System.currentTimeMillis();
|
||||
executor.execute(() -> {
|
||||
try {
|
||||
task.run();
|
||||
} finally {
|
||||
int endCount = runCounter.decrementAndGet();
|
||||
LOG.info("Finish task and current taskcount {} use time {}", endCount, System.currentTimeMillis()-startTime);
|
||||
LOG.debug("Finish task and current task count {} use time {}", endCount, System.currentTimeMillis()-startTime);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
package com.xiaoleilu.loServer;
|
||||
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
public class RestResult {
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ package com.xiaoleilu.loServer.action;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.admin.GetIMTokenAction;
|
||||
import com.xiaoleilu.loServer.annotation.RequireAuthentication;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
@@ -21,10 +20,9 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import win.liyufan.im.DBUtil;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
import static win.liyufan.im.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
/**
|
||||
* 请求处理接口<br>
|
||||
@@ -39,8 +37,6 @@ abstract public class Action {
|
||||
|
||||
public ChannelHandlerContext ctx;
|
||||
|
||||
protected boolean isSync = true;
|
||||
|
||||
public ErrorCode preAction(Request request, Response response) {
|
||||
if (getClass().getAnnotation(RequireAuthentication.class) != null) {
|
||||
//do authentication
|
||||
@@ -50,6 +46,7 @@ abstract public class Action {
|
||||
}
|
||||
public boolean doAction(Request request, Response response) {
|
||||
ErrorCode errorCode = preAction(request, response);
|
||||
boolean isSync = true;
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
//事务逻辑有缺陷,先注释掉
|
||||
// if (isTransactionAction() && !(this instanceof IMAction)) {
|
||||
@@ -63,9 +60,8 @@ abstract public class Action {
|
||||
// throw e;
|
||||
// }
|
||||
// } else {
|
||||
action(request, response);
|
||||
isSync = action(request, response);
|
||||
// }
|
||||
afterAction(request, response);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
if (errorCode == null) {
|
||||
@@ -77,19 +73,12 @@ abstract public class Action {
|
||||
response.send();
|
||||
}
|
||||
|
||||
if(this instanceof IMAction || this instanceof RouteAction || this instanceof GetIMTokenAction) {
|
||||
isSync = false;
|
||||
}
|
||||
return isSync;
|
||||
}
|
||||
public boolean isTransactionAction() {
|
||||
return false;
|
||||
}
|
||||
abstract public void action(Request request, Response response);
|
||||
public void afterAction(Request request, Response response) {
|
||||
|
||||
}
|
||||
|
||||
abstract public boolean action(Request request, Response response);
|
||||
|
||||
protected <T> T getRequestBody(HttpRequest request, Class<T> cls) {
|
||||
if (request instanceof FullHttpRequest) {
|
||||
|
||||
@@ -12,7 +12,8 @@ import io.moquette.spi.IMessagesStore;
|
||||
*/
|
||||
public class DefaultIndexAction extends Action{
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
response.setContent("Welcome to LoServer.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,15 +34,15 @@ public class FileAction extends Action {
|
||||
private static final org.slf4j.Logger Logger = LoggerFactory.getLogger(FileAction.class);
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (false == Request.METHOD_GET.equalsIgnoreCase(request.getMethod())) {
|
||||
response.sendError(HttpResponseStatus.METHOD_NOT_ALLOWED, "Please use GET method to request file!");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(ServerSetting.isRootAvailable() == false){
|
||||
response.sendError(HttpResponseStatus.NOT_FOUND, "404 Root dir not avaliable!");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
final File file = getFileByPath(request.getPath());
|
||||
@@ -51,13 +51,13 @@ public class FileAction extends Action {
|
||||
// 隐藏文件,跳过
|
||||
if (file.isHidden() || !file.exists()) {
|
||||
response.sendError(HttpResponseStatus.NOT_FOUND, "404 File not found!");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
// 非文件,跳过
|
||||
if (false == file.isFile()) {
|
||||
response.sendError(HttpResponseStatus.FORBIDDEN, "403 Forbidden!");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Cache Validation
|
||||
@@ -76,12 +76,13 @@ public class FileAction extends Action {
|
||||
if (ifModifiedSinceDateSeconds == fileLastModifiedSeconds) {
|
||||
Logger.debug("File {} not modified.", file.getPath());
|
||||
response.sendNotModified();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response.setContent(file);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final Pattern INSECURE_URI = Pattern.compile(".*[<>&\"].*");
|
||||
|
||||
@@ -25,7 +25,7 @@ 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.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -35,7 +35,7 @@ import java.util.concurrent.Executor;
|
||||
public class IMAction extends Action {
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
|
||||
FullHttpRequest fullHttpRequest = (FullHttpRequest)request.getNettyRequest();
|
||||
@@ -46,15 +46,15 @@ public class IMAction extends Action {
|
||||
bytes = Base64.getDecoder().decode(str);
|
||||
} catch (IllegalArgumentException e) {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH, null);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
String cid = fullHttpRequest.headers().get("cid");
|
||||
byte[] cbytes = Base64.getDecoder().decode(cid);
|
||||
cbytes = AES.AESDecrypt(cbytes, null, true);
|
||||
cbytes = AES.AESDecrypt(cbytes, "", true);
|
||||
if (cbytes == null) {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH, null);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
cid = new String(cbytes);
|
||||
|
||||
@@ -64,13 +64,13 @@ public class IMAction extends Action {
|
||||
bytes = AES.AESDecrypt(bytes, session.getSecret(), true);
|
||||
} else {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH, null);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (bytes == null) {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH, null);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -102,12 +102,14 @@ public class IMAction extends Action {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
return false;
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_INVALID_DATA, null);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendResponse(Response response, ErrorCode errorCode, byte[] contents) {
|
||||
|
||||
@@ -27,7 +27,8 @@ public class NotFoundAction extends Action{
|
||||
private final static String TEMPLATE_ERROR = "<!DOCTYPE html><html><head><title>LoServer - Error report</title><style>h1,h3 {color:white; background-color: gray;}</style></head><body><h1>HTTP Status {} - {}</h1><hr size=\"1\" noshade=\"noshade\" /><p>{}</p><hr size=\"1\" noshade=\"noshade\" /><h3>LoServer</h3></body></html>";
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
response.sendError(HttpResponseStatus.NOT_FOUND, "404 Not found!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -35,12 +35,15 @@ import java.util.concurrent.Executor;
|
||||
@HttpMethod("POST")
|
||||
public class RouteAction extends Action {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RouteAction.class);
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
|
||||
response.setContentType("application/octet-stream");
|
||||
FullHttpRequest fullHttpRequest = (FullHttpRequest)request.getNettyRequest();
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
FullHttpRequest fullHttpRequest = (FullHttpRequest) request.getNettyRequest();
|
||||
boolean b = false;
|
||||
if ("web".equalsIgnoreCase(fullHttpRequest.headers().get("p"))) {
|
||||
b = true;
|
||||
@@ -55,34 +58,34 @@ public class RouteAction extends Action {
|
||||
bytes = Base64.getDecoder().decode(str);
|
||||
} catch (IllegalArgumentException e) {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH, null, base64Response);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
String cid = fullHttpRequest.headers().get("cid");
|
||||
byte[] cbytes = Base64.getDecoder().decode(cid);
|
||||
cbytes = AES.AESDecrypt(cbytes, null, true);
|
||||
cbytes = AES.AESDecrypt(cbytes, "", true);
|
||||
if (cbytes == null) {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH, null, base64Response);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
cid = new String(cbytes);
|
||||
|
||||
String uid = fullHttpRequest.headers().get("uid");
|
||||
byte[] ubytes = Base64.getDecoder().decode(uid);
|
||||
ubytes = AES.AESDecrypt(ubytes, null, true);
|
||||
ubytes = AES.AESDecrypt(ubytes, "", true);
|
||||
if (ubytes == null) {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH, null, base64Response);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
uid = new String(ubytes);
|
||||
|
||||
|
||||
MemorySessionStore.Session session = sessionsStore.sessionForClientAndUser(uid, cid);
|
||||
if (session == null) {
|
||||
ErrorCode errorCode = sessionsStore.createNewSession(uid, cid, true);
|
||||
ErrorCode errorCode = sessionsStore.createNewSession(uid, cid, true, true);
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, errorCode, null, base64Response);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
session = sessionsStore.sessionForClientAndUser(uid, cid);
|
||||
}
|
||||
@@ -92,13 +95,13 @@ public class RouteAction extends Action {
|
||||
bytes = AES.AESDecrypt(bytes, session.getSecret(), true);
|
||||
} else {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH, null, base64Response);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (bytes == null) {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH, null, base64Response);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,20 +135,26 @@ public class RouteAction extends Action {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
return false;
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_INVALID_DATA, null, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendResponse(Response response, ErrorCode errorCode, byte[] contents, boolean base64Response) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
if(contents == null) {
|
||||
if (contents == null) {
|
||||
ByteBuf ackPayload = Unpooled.buffer();
|
||||
ackPayload.ensureWritable(1).writeByte(errorCode.getCode());
|
||||
response.setContent(ackPayload);
|
||||
contents = ackPayload.array();
|
||||
}
|
||||
if (base64Response) {
|
||||
byte[] base64Data = Base64.getEncoder().encode(contents);
|
||||
response.setContent(base64Data);
|
||||
} else {
|
||||
response.setContent(contents);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ public class UnknownErrorAction extends Action{
|
||||
private final static String TEMPLATE_ERROR = "<!DOCTYPE html><html><head><title>LoServer - Error report</title><style>h1,h3 {color:white; background-color: gray;}</style></head><body><h1>HTTP Status {} - {}</h1><hr size=\"1\" noshade=\"noshade\" /><p>{}</p><hr size=\"1\" noshade=\"noshade\" /><h3>LoServer</h3></body></html>";
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
response.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
|
||||
public boolean action(Request request, Response response) {
|
||||
response.setStatus(HttpResponseStatus.NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class UploadFileAction extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request r, Response response) {
|
||||
public boolean action(Request r, Response response) {
|
||||
if (r.getNettyRequest() instanceof FullHttpRequest) {
|
||||
|
||||
FullHttpRequest request = (FullHttpRequest) r.getNettyRequest();
|
||||
@@ -84,12 +84,13 @@ public class UploadFileAction extends Action {
|
||||
logger.warn("http decode failed!");
|
||||
response.setStatus(HttpResponseStatus.BAD_REQUEST);
|
||||
response.setContent("http decode failed");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
multipartUpload(request, requestId, response);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,23 +9,18 @@
|
||||
package com.xiaoleilu.loServer.action;
|
||||
|
||||
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 com.xiaoleilu.loServer.pojos.InputUserLogin;
|
||||
import com.xiaoleilu.loServer.pojos.OutputLoginData;
|
||||
import io.moquette.spi.impl.Utils;
|
||||
import io.moquette.spi.impl.security.TokenAuthenticator;
|
||||
import cn.wildfirechat.pojos.InputUserLogin;
|
||||
import cn.wildfirechat.pojos.OutputLoginData;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import win.liyufan.im.GitRepositoryState;
|
||||
import win.liyufan.im.Utility;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Route("/api/version")
|
||||
@HttpMethod("GET")
|
||||
@@ -33,16 +28,18 @@ public class VersionAction extends Action {
|
||||
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
|
||||
try {
|
||||
response.setContent(new Gson().toJson(GitRepositoryState.getGitRepositoryState()));
|
||||
|
||||
response.setContent(Utility.formatJson(new Gson().toJson(GitRepositoryState.getGitRepositoryState())));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
response.setContent("{\"version\":\"unknown\"}");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import 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.InputAddGroupMember;
|
||||
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 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 {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
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);
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -13,24 +13,28 @@ import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.Action;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import com.xiaoleilu.loServer.pojos.InputCreateUser;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.spi.impl.Utils;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.RateLimiter;
|
||||
|
||||
abstract public class AdminAction extends Action {
|
||||
private static String SECRET_KEY = "123456";
|
||||
private static boolean NO_CHECK_TIME = false;
|
||||
private final RateLimiter mLimitCounter = new RateLimiter(10, 500);
|
||||
public static void setSecretKey(String secretKey) {
|
||||
SECRET_KEY = secretKey;
|
||||
}
|
||||
|
||||
public static void setNoCheckTime(String noCheckTime) {
|
||||
try {
|
||||
NO_CHECK_TIME = Boolean.parseBoolean(noCheckTime);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode preAction(Request request, Response response) {
|
||||
if (!mLimitCounter.isGranted("admin")) {
|
||||
@@ -51,8 +55,8 @@ abstract public class AdminAction extends Action {
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() - ts > 2 * 60 * 60 * 1000) {
|
||||
// return ErrorCode.ERROR_CODE_SIGN_EXPIRED;
|
||||
if (!NO_CHECK_TIME && System.currentTimeMillis() - ts > 2 * 60 * 60 * 1000) {
|
||||
return ErrorCode.ERROR_CODE_SIGN_EXPIRED;
|
||||
}
|
||||
|
||||
String str = nonce + "|" + SECRET_KEY + "|" + timestamp;
|
||||
|
||||
@@ -8,21 +8,22 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
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 com.xiaoleilu.loServer.pojos.InputOutputUserBlockStatus;
|
||||
import cn.wildfirechat.pojos.InputOutputUserBlockStatus;
|
||||
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.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
@Route("admin/user/status")
|
||||
@Route(APIPath.User_Update_Block_Status)
|
||||
@HttpMethod("POST")
|
||||
public class BlockUserAction extends AdminAction {
|
||||
|
||||
@@ -32,7 +33,7 @@ public class BlockUserAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputOutputUserBlockStatus inputUserBlock = getRequestBody(request.getNettyRequest(), InputOutputUserBlockStatus.class);
|
||||
if (inputUserBlock != null
|
||||
@@ -44,7 +45,9 @@ public class BlockUserAction extends AdminAction {
|
||||
result = RestResult.resultOf(errorCode);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
RPCCenter.getInstance().sendRequest(null, null, RPCCenter.KICKOFF_USER_REQUEST, inputUserBlock.getUserId().getBytes(), inputUserBlock.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, null);
|
||||
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);
|
||||
}
|
||||
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SUCCESS, null);
|
||||
} else {
|
||||
@@ -54,5 +57,6 @@ public class BlockUserAction extends AdminAction {
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.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;
|
||||
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 {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,19 +8,19 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
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 com.xiaoleilu.loServer.pojos.InputGetUserInfo;
|
||||
import com.xiaoleilu.loServer.pojos.OutputCreateUser;
|
||||
import cn.wildfirechat.pojos.InputGetUserInfo;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
@Route("/admin/user/onlinestatus")
|
||||
@Route(APIPath.User_Get_Online_Status)
|
||||
@HttpMethod("POST")
|
||||
public class CheckUserOnlineAction extends AdminAction {
|
||||
|
||||
@@ -30,16 +30,17 @@ public class CheckUserOnlineAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
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())) {
|
||||
RPCCenter.getInstance().sendRequest(null, null, RPCCenter.CHECK_USER_ONLINE_REQUEST, inputUserId.getUserId().getBytes(), inputUserId.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, null);
|
||||
return;
|
||||
RPCCenter.getInstance().sendRequest(null, null, RPCCenter.CHECK_USER_ONLINE_REQUEST, inputUserId.getUserId().getBytes(), inputUserId.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, null, true);
|
||||
return true;
|
||||
} else {
|
||||
sendResponse(response, ErrorCode.INVALID_PARAMETER, null);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -15,17 +16,16 @@ 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 com.xiaoleilu.loServer.pojos.InputCreateChatroom;
|
||||
import com.xiaoleilu.loServer.pojos.OutputCreateChatroom;
|
||||
import cn.wildfirechat.pojos.InputCreateChatroom;
|
||||
import cn.wildfirechat.pojos.OutputCreateChatroom;
|
||||
import io.moquette.spi.impl.Utils;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import win.liyufan.im.UUIDGenerator;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
@Route("/admin/chatroom")
|
||||
@HttpMethod("PUT")
|
||||
@Route(APIPath.Create_Chatroom)
|
||||
@HttpMethod("POST")
|
||||
public class CreateChatroomAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
@@ -34,7 +34,7 @@ public class CreateChatroomAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
FullHttpRequest fullHttpRequest = (FullHttpRequest)request.getNettyRequest();
|
||||
byte[] bytes = Utils.readBytesAndRewind(fullHttpRequest.content());
|
||||
@@ -67,5 +67,6 @@ public class CreateChatroomAction extends AdminAction {
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,27 +9,28 @@
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
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 com.xiaoleilu.loServer.pojos.InputCreateGroup;
|
||||
import com.xiaoleilu.loServer.pojos.OutputCreateGroupResult;
|
||||
import cn.wildfirechat.pojos.InputCreateGroup;
|
||||
import cn.wildfirechat.pojos.OutputCreateGroupResult;
|
||||
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.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route("admin/group")
|
||||
@HttpMethod("PUT")
|
||||
@Route(APIPath.Create_Group)
|
||||
@HttpMethod("POST")
|
||||
public class CreateGroupAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
@@ -38,7 +39,7 @@ public class CreateGroupAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputCreateGroup inputCreateGroup = getRequestBody(request.getNettyRequest(), InputCreateGroup.class);
|
||||
if (inputCreateGroup.isValide()) {
|
||||
@@ -74,12 +75,14 @@ public class CreateGroupAction extends AdminAction {
|
||||
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));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -15,15 +16,15 @@ 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 com.xiaoleilu.loServer.pojos.InputCreateRobot;
|
||||
import com.xiaoleilu.loServer.pojos.OutputCreateRobot;
|
||||
import cn.wildfirechat.pojos.InputCreateRobot;
|
||||
import cn.wildfirechat.pojos.OutputCreateRobot;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.UUIDGenerator;
|
||||
|
||||
@Route("admin/robot/create")
|
||||
@Route(APIPath.Create_Robot)
|
||||
@HttpMethod("POST")
|
||||
public class CreateRobotAction extends AdminAction {
|
||||
|
||||
@@ -33,7 +34,7 @@ public class CreateRobotAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputCreateRobot inputCreateRobot = getRequestBody(request.getNettyRequest(), InputCreateRobot.class);
|
||||
if (inputCreateRobot != null
|
||||
@@ -76,5 +77,6 @@ public class CreateRobotAction extends AdminAction {
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -15,15 +16,15 @@ 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 com.xiaoleilu.loServer.pojos.InputCreateUser;
|
||||
import com.xiaoleilu.loServer.pojos.OutputCreateUser;
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.pojos.OutputCreateUser;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.UUIDGenerator;
|
||||
|
||||
@Route("admin/user/create")
|
||||
@Route(APIPath.Create_User)
|
||||
@HttpMethod("POST")
|
||||
public class CreateUserAction extends AdminAction {
|
||||
|
||||
@@ -33,9 +34,9 @@ public class CreateUserAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputCreateUser inputCreateUser = getRequestBody(request.getNettyRequest(), InputCreateUser.class);
|
||||
InputOutputUserInfo inputCreateUser = getRequestBody(request.getNettyRequest(), InputOutputUserInfo.class);
|
||||
if (inputCreateUser != null
|
||||
&& !StringUtil.isNullOrEmpty(inputCreateUser.getName())) {
|
||||
|
||||
@@ -47,10 +48,6 @@ public class CreateUserAction extends AdminAction {
|
||||
inputCreateUser.setUserId(messagesStore.getShortUUID());
|
||||
}
|
||||
|
||||
if (inputCreateUser.getPortrait() == null || inputCreateUser.getPortrait().length() == 0) {
|
||||
inputCreateUser.setPortrait("https://avatars.io/gravatar/" + inputCreateUser.getUserId());
|
||||
}
|
||||
|
||||
WFCMessage.User.Builder newUserBuilder = WFCMessage.User.newBuilder()
|
||||
.setUid(StringUtil.isNullOrEmpty(inputCreateUser.getUserId()) ? "" : inputCreateUser.getUserId());
|
||||
if (inputCreateUser.getName() != null)
|
||||
@@ -90,5 +87,6 @@ public class CreateUserAction extends AdminAction {
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,21 +8,22 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
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 com.xiaoleilu.loServer.pojos.InputDestoryChatroom;
|
||||
import cn.wildfirechat.pojos.InputDestoryChatroom;
|
||||
import io.moquette.spi.impl.Utils;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
@Route("/admin/chatroom")
|
||||
@HttpMethod("DELETE")
|
||||
@Route(APIPath.Chatroom_Destroy)
|
||||
@HttpMethod("POST")
|
||||
public class DestoryChatroomAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
@@ -31,7 +32,7 @@ public class DestoryChatroomAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
FullHttpRequest fullHttpRequest = (FullHttpRequest)request.getNettyRequest();
|
||||
byte[] bytes = Utils.readBytesAndRewind(fullHttpRequest.content());
|
||||
@@ -54,5 +55,6 @@ public class DestoryChatroomAction extends AdminAction {
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import 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.InputDismissGroup;
|
||||
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 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 {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
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);
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.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 cn.wildfirechat.pojos.InputFriendRequest;
|
||||
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 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 {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputFriendRequest friendAdd = getRequestBody(request.getNettyRequest(), InputFriendRequest.class);
|
||||
if (friendAdd != null
|
||||
&& !StringUtil.isNullOrEmpty(friendAdd.getUserId())
|
||||
&& !StringUtil.isNullOrEmpty(friendAdd.getFriendUid())
|
||||
) {
|
||||
WFCMessage.HandleFriendRequest friendRequest = WFCMessage.HandleFriendRequest.newBuilder().setTargetUid(friendAdd.getFriendUid()).setStatus(friendAdd.getStatus()).build();
|
||||
RPCCenter.getInstance().sendRequest(friendAdd.getUserId(), null, IMTopic.HandleFriendRequestTopic, friendRequest.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);
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import 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 com.xiaoleilu.loServer.model.FriendData;
|
||||
import cn.wildfirechat.pojos.InputGetFriendList;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Route(APIPath.Friend_Get_List)
|
||||
@HttpMethod("POST")
|
||||
public class FriendRelationGetAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputGetFriendList inputGetFriendList = getRequestBody(request.getNettyRequest(), InputGetFriendList.class);
|
||||
List<FriendData> dataList = messagesStore.getFriendList(inputGetFriendList.getUserId(), 0);
|
||||
List<String> list = new ArrayList<>();
|
||||
for (FriendData data : dataList) {
|
||||
if (data.getState() == inputGetFriendList.getStatus()) {
|
||||
list.add(data.getFriendUid());
|
||||
}
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(list);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+11
-9
@@ -8,6 +8,8 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.pojos.*;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -15,14 +17,13 @@ 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 com.xiaoleilu.loServer.pojos.OutputGetChatroomInfo;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
@Route("/admin/chatroom")
|
||||
@HttpMethod("GET")
|
||||
@Route(APIPath.Chatroom_Info)
|
||||
@HttpMethod("POST")
|
||||
public class GetChatroomInfoAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
@@ -31,19 +32,19 @@ public class GetChatroomInfoAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
|
||||
String chatroomid = request.getParam("id");
|
||||
InputGetChatroomInfo getChatroomInfo = getRequestBody(request.getNettyRequest(), InputGetChatroomInfo.class);
|
||||
String chatroomid = getChatroomInfo.getChatroomId();
|
||||
if (!StringUtil.isNullOrEmpty(chatroomid)) {
|
||||
|
||||
WFCMessage.ChatroomInfo info = messagesStore.getChatroomInfo(chatroomid);
|
||||
|
||||
RestResult result;
|
||||
if (info == null) {
|
||||
if (info != null) {
|
||||
result = RestResult.ok(new OutputGetChatroomInfo(chatroomid, messagesStore.getChatroomMemberCount(chatroomid), info));
|
||||
} else {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_SUCCESS);
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
|
||||
@@ -56,5 +57,6 @@ public class GetChatroomInfoAction extends AdminAction {
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputGetGroup;
|
||||
import cn.wildfirechat.pojos.InputGetUserInfo;
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.pojos.PojoGroupInfo;
|
||||
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.Group_Get_Info)
|
||||
@HttpMethod("POST")
|
||||
public class GetGroupInfoAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputGetGroup inputGetGroup = getRequestBody(request.getNettyRequest(), InputGetGroup.class);
|
||||
if (inputGetGroup != null
|
||||
&& (!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);
|
||||
} else {
|
||||
PojoGroupInfo pojoGroupInfo = new PojoGroupInfo();
|
||||
pojoGroupInfo.setExtra(groupInfo.getExtra());
|
||||
pojoGroupInfo.setName(groupInfo.getName());
|
||||
pojoGroupInfo.setOwner(groupInfo.getOwner());
|
||||
pojoGroupInfo.setPortrait(groupInfo.getPortrait());
|
||||
pojoGroupInfo.setTarget_id(groupInfo.getTargetId());
|
||||
pojoGroupInfo.setType(groupInfo.getType());
|
||||
result = RestResult.ok(pojoGroupInfo);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputGetGroup;
|
||||
import cn.wildfirechat.pojos.OutputGroupMemberList;
|
||||
import cn.wildfirechat.pojos.PojoGroupInfo;
|
||||
import cn.wildfirechat.pojos.PojoGroupMember;
|
||||
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;
|
||||
import java.util.List;
|
||||
|
||||
@Route(APIPath.Group_Member_List)
|
||||
@HttpMethod("POST")
|
||||
public class GetGroupMembersAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputGetGroup inputGetGroup = getRequestBody(request.getNettyRequest(), InputGetGroup.class);
|
||||
if (inputGetGroup != null
|
||||
&& (!StringUtil.isNullOrEmpty(inputGetGroup.getGroupId()))) {
|
||||
|
||||
List<WFCMessage.GroupMember> members = new ArrayList<>();
|
||||
ErrorCode errorCode = messagesStore.getGroupMembers(inputGetGroup.getGroupId(), 0, members);
|
||||
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
result = RestResult.resultOf(errorCode);
|
||||
} else {
|
||||
OutputGroupMemberList out = new OutputGroupMemberList();
|
||||
out.setMembers(new ArrayList<>());
|
||||
for (WFCMessage.GroupMember member : members) {
|
||||
PojoGroupMember pm = new PojoGroupMember();
|
||||
pm.setMember_id(member.getMemberId());
|
||||
pm.setAlias(member.getAlias());
|
||||
pm.setType(member.getType());
|
||||
out.getMembers().add(pm);
|
||||
}
|
||||
result = RestResult.ok(out);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,23 +8,24 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
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 com.xiaoleilu.loServer.pojos.InputGetToken;
|
||||
import com.xiaoleilu.loServer.pojos.OutputGetIMTokenData;
|
||||
import cn.wildfirechat.pojos.InputGetToken;
|
||||
import cn.wildfirechat.pojos.OutputGetIMTokenData;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route("/admin/user/token")
|
||||
@Route(APIPath.User_Get_Token)
|
||||
@HttpMethod("POST")
|
||||
public class GetIMTokenAction extends AdminAction {
|
||||
|
||||
@@ -34,7 +35,7 @@ public class GetIMTokenAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputGetToken input = getRequestBody(request.getNettyRequest(), InputGetToken.class);
|
||||
String userId = input.getUserId();
|
||||
@@ -75,7 +76,9 @@ public class GetIMTokenAction extends AdminAction {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
});
|
||||
}, true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -15,15 +16,14 @@ 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 com.xiaoleilu.loServer.pojos.InputCreateUser;
|
||||
import com.xiaoleilu.loServer.pojos.InputGetUserInfo;
|
||||
import com.xiaoleilu.loServer.pojos.OutputCreateUser;
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.pojos.InputGetUserInfo;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
@Route("admin/user/info")
|
||||
@Route(APIPath.User_Get_Info)
|
||||
@HttpMethod("POST")
|
||||
public class GetUserAction extends AdminAction {
|
||||
|
||||
@@ -33,11 +33,11 @@ public class GetUserAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
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.getUserId()) || !StringUtil.isNullOrEmpty(inputUserId.getName()) || !StringUtil.isNullOrEmpty(inputUserId.getMobile()))) {
|
||||
|
||||
WFCMessage.User user = null;
|
||||
if(!StringUtil.isNullOrEmpty(inputUserId.getUserId())) {
|
||||
@@ -53,7 +53,7 @@ public class GetUserAction extends AdminAction {
|
||||
if (user == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
} else {
|
||||
result = RestResult.ok(InputCreateUser.fromPbUser(user));
|
||||
result = RestResult.ok(InputOutputUserInfo.fromPbUser(user));
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
@@ -64,5 +64,6 @@ public class GetUserAction extends AdminAction {
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+8
-3
@@ -8,6 +8,8 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.pojos.OutputUserBlockStatusList;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
@@ -17,7 +19,7 @@ import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
|
||||
@Route("admin/user/statuslist")
|
||||
@Route(APIPath.User_Get_Blocked_List)
|
||||
@HttpMethod("POST")
|
||||
public class GetUserBlockListAction extends AdminAction {
|
||||
|
||||
@@ -27,11 +29,14 @@ public class GetUserBlockListAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(messagesStore.getUserStatusList());
|
||||
OutputUserBlockStatusList list = new OutputUserBlockStatusList();
|
||||
list.setStatusList(messagesStore.getUserStatusList());
|
||||
RestResult result = RestResult.ok(list);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-6
@@ -8,21 +8,21 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
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 com.xiaoleilu.loServer.pojos.InputGetUserInfo;
|
||||
import com.xiaoleilu.loServer.pojos.OutputCreateUser;
|
||||
import com.xiaoleilu.loServer.pojos.OutputUserStatus;
|
||||
import cn.wildfirechat.pojos.InputGetUserInfo;
|
||||
import cn.wildfirechat.pojos.OutputUserStatus;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
@Route("admin/user/checkstatus")
|
||||
@Route(APIPath.User_Check_Block_Status)
|
||||
@HttpMethod("POST")
|
||||
public class GetUserBlockStatusAction extends AdminAction {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class GetUserBlockStatusAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputGetUserInfo inputUserId = getRequestBody(request.getNettyRequest(), InputGetUserInfo.class);
|
||||
if (inputUserId != null
|
||||
@@ -49,5 +49,6 @@ public class GetUserBlockStatusAction extends AdminAction {
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import 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.InputKickoffGroupMember;
|
||||
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 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 {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
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);
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -15,7 +16,7 @@ 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 com.xiaoleilu.loServer.pojos.RecallMessageData;
|
||||
import cn.wildfirechat.pojos.RecallMessageData;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -23,12 +24,12 @@ 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.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route("admin/message/recall")
|
||||
@Route(APIPath.Msg_Recall)
|
||||
@HttpMethod("POST")
|
||||
public class RecallMessageAction extends AdminAction {
|
||||
|
||||
@@ -38,7 +39,7 @@ public class RecallMessageAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
RecallMessageData recallMessageData = getRequestBody(request.getNettyRequest(), RecallMessageData.class);
|
||||
if (recallMessageData != null && !StringUtil.isNullOrEmpty(recallMessageData.getOperator())) {
|
||||
@@ -69,12 +70,14 @@ public class RecallMessageAction extends AdminAction {
|
||||
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));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,26 +9,28 @@
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
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 com.xiaoleilu.loServer.pojos.SendMessageData;
|
||||
import com.xiaoleilu.loServer.pojos.SendMessageResult;
|
||||
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;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route("admin/message/send")
|
||||
@Route(APIPath.Msg_Send)
|
||||
@HttpMethod("POST")
|
||||
public class SendMessageAction extends AdminAction {
|
||||
|
||||
@@ -38,10 +40,10 @@ public class SendMessageAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
SendMessageData sendMessageData = getRequestBody(request.getNettyRequest(), SendMessageData.class);
|
||||
if (SendMessageData.isValide(sendMessageData)) {
|
||||
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) {
|
||||
@@ -73,12 +75,14 @@ public class SendMessageAction extends AdminAction {
|
||||
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));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-8
@@ -8,22 +8,19 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
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 com.xiaoleilu.loServer.pojos.InputOutputSensitiveWords;
|
||||
import com.xiaoleilu.loServer.pojos.InputOutputUserBlockStatus;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import cn.wildfirechat.pojos.InputOutputSensitiveWords;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
@Route("admin/sensitive/add")
|
||||
@Route(APIPath.Sensitive_Add)
|
||||
@HttpMethod("POST")
|
||||
public class SensitiveWordAddAction extends AdminAction {
|
||||
|
||||
@@ -33,7 +30,7 @@ public class SensitiveWordAddAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputOutputSensitiveWords input = getRequestBody(request.getNettyRequest(), InputOutputSensitiveWords.class);
|
||||
if (input != null && input.getWords() != null && !input.getWords().isEmpty()) {
|
||||
@@ -47,5 +44,6 @@ public class SensitiveWordAddAction extends AdminAction {
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -8,18 +8,19 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
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 com.xiaoleilu.loServer.pojos.InputOutputSensitiveWords;
|
||||
import cn.wildfirechat.pojos.InputOutputSensitiveWords;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
@Route("admin/sensitive/del")
|
||||
@Route(APIPath.Sensitive_Del)
|
||||
@HttpMethod("POST")
|
||||
public class SensitiveWordDeleteAction extends AdminAction {
|
||||
|
||||
@@ -29,7 +30,7 @@ public class SensitiveWordDeleteAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputOutputSensitiveWords input = getRequestBody(request.getNettyRequest(), InputOutputSensitiveWords.class);
|
||||
if (input != null && input.getWords() != null && !input.getWords().isEmpty()) {
|
||||
@@ -44,5 +45,6 @@ public class SensitiveWordDeleteAction extends AdminAction {
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-7
@@ -8,20 +8,18 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
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 com.xiaoleilu.loServer.pojos.InputOutputSensitiveWords;
|
||||
import cn.wildfirechat.pojos.InputOutputSensitiveWords;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Route("admin/sensitive/query")
|
||||
@Route(APIPath.Sensitive_Query)
|
||||
@HttpMethod("POST")
|
||||
public class SensitiveWordQueryAction extends AdminAction {
|
||||
|
||||
@@ -31,12 +29,13 @@ public class SensitiveWordQueryAction extends AdminAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
List<String> words = messagesStore.getAllSensitiveWords();
|
||||
InputOutputSensitiveWords out = new InputOutputSensitiveWords();
|
||||
out.setWords(words);
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SUCCESS, out);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import 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.InputTransferGroup;
|
||||
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 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 {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
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);
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -14,14 +14,13 @@ 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.RPCCenter;
|
||||
import io.moquette.spi.impl.Utils;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.RateLimiter;
|
||||
|
||||
abstract public class ChannelAction extends Action {
|
||||
|
||||
@@ -9,30 +9,30 @@
|
||||
package com.xiaoleilu.loServer.action.channel;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
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 com.xiaoleilu.loServer.pojos.Conversation;
|
||||
import com.xiaoleilu.loServer.pojos.SendMessageData;
|
||||
import com.xiaoleilu.loServer.pojos.SendMessageResult;
|
||||
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;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
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("channel/message/send")
|
||||
@Route(APIPath.Channel_Message_Send)
|
||||
@HttpMethod("POST")
|
||||
public class SendMessageAction extends ChannelAction {
|
||||
|
||||
@@ -42,7 +42,7 @@ public class SendMessageAction extends ChannelAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
SendMessageData sendMessageData = getRequestBody(request.getNettyRequest(), SendMessageData.class);
|
||||
sendMessageData.setConv(new Conversation());
|
||||
@@ -81,12 +81,14 @@ public class SendMessageAction extends ChannelAction {
|
||||
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));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
package com.xiaoleilu.loServer.action.robot;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -15,24 +16,23 @@ 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 com.xiaoleilu.loServer.pojos.InputCreateUser;
|
||||
import com.xiaoleilu.loServer.pojos.InputGetUserInfo;
|
||||
import com.xiaoleilu.loServer.pojos.OutputCreateUser;
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.pojos.InputGetUserInfo;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
@Route("admin/robot/user_info")
|
||||
@Route(APIPath.Robot_User_Info)
|
||||
@HttpMethod("POST")
|
||||
public class GetUserAction extends RobotAction {
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
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.getUserId()) || !StringUtil.isNullOrEmpty(inputUserId.getName()) || !StringUtil.isNullOrEmpty(inputUserId.getMobile()))) {
|
||||
|
||||
WFCMessage.User user = null;
|
||||
if(!StringUtil.isNullOrEmpty(inputUserId.getUserId())) {
|
||||
@@ -48,7 +48,7 @@ public class GetUserAction extends RobotAction {
|
||||
if (user == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
} else {
|
||||
result = RestResult.ok(InputCreateUser.fromPbUser(user));
|
||||
result = RestResult.ok(InputOutputUserInfo.fromPbUser(user));
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
@@ -59,5 +59,6 @@ public class GetUserAction extends RobotAction {
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,16 +14,17 @@ 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.RPCCenter;
|
||||
import io.moquette.spi.impl.Utils;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.RateLimiter;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
abstract public class RobotAction extends Action {
|
||||
private final RateLimiter mLimitCounter = new RateLimiter(10, 1000);
|
||||
|
||||
@@ -80,10 +81,15 @@ abstract public class RobotAction extends Action {
|
||||
if (request instanceof FullHttpRequest) {
|
||||
FullHttpRequest fullHttpRequest = (FullHttpRequest) request;
|
||||
byte[] bytes = Utils.readBytesAndRewind(fullHttpRequest.content());
|
||||
String content = new String(bytes);
|
||||
Gson gson = new Gson();
|
||||
T t = gson.fromJson(content, cls);
|
||||
return t;
|
||||
String content = null;
|
||||
try {
|
||||
content = new String(bytes, "UTF-8");
|
||||
Gson gson = new Gson();
|
||||
T t = gson.fromJson(content, cls);
|
||||
return t;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -9,28 +9,27 @@
|
||||
package com.xiaoleilu.loServer.action.robot;
|
||||
|
||||
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
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 com.xiaoleilu.loServer.pojos.SendMessageData;
|
||||
import com.xiaoleilu.loServer.pojos.SendMessageResult;
|
||||
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;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route("admin/robot/send")
|
||||
@Route(APIPath.Robot_Message_Send)
|
||||
@HttpMethod("POST")
|
||||
public class SendMessageAction extends RobotAction {
|
||||
|
||||
@@ -40,7 +39,7 @@ public class SendMessageAction extends RobotAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Request request, Response response) {
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
SendMessageData sendMessageData = getRequestBody(request.getNettyRequest(), SendMessageData.class);
|
||||
sendMessageData.setSender(robot.getUid());
|
||||
@@ -76,12 +75,14 @@ public class SendMessageAction extends RobotAction {
|
||||
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));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Action处理单元
|
||||
*
|
||||
*
|
||||
* @author Looly
|
||||
*/
|
||||
abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
|
||||
@@ -45,7 +45,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
try {
|
||||
//do filter
|
||||
boolean isPass = this.doFilter(request, response);
|
||||
|
||||
|
||||
if(isPass){
|
||||
//do action
|
||||
this.doAction(ctx, request, response);
|
||||
@@ -64,10 +64,10 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
ctx.fireExceptionCaught(e);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
super.exceptionCaught(ctx, cause);
|
||||
@@ -75,7 +75,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
Channel channel = ctx.channel();
|
||||
if(channel.isActive())ctx.close();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------- Private method start
|
||||
/**
|
||||
* 执行过滤
|
||||
@@ -91,7 +91,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//自定义Path过滤器
|
||||
filter = ServerSetting.getFilter(request.getPath());
|
||||
if(null != filter){
|
||||
@@ -99,7 +99,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -110,6 +110,10 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
* @param response 响应对象
|
||||
*/
|
||||
private void doAction(ChannelHandlerContext ctx, Request request, Response response){
|
||||
if( "/route".equalsIgnoreCase(request.getPath()) && "OPTIONS".equalsIgnoreCase(request.getMethod())){
|
||||
handleOptions(ctx, request, response);
|
||||
return;
|
||||
}
|
||||
Action action;
|
||||
if (isValidePath(request.getPath())) {
|
||||
action = ServerSetting.getAction(request.getPath(), request.getMethod().toUpperCase());
|
||||
@@ -141,4 +145,11 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------------------- Private method start
|
||||
|
||||
|
||||
private void handleOptions(ChannelHandlerContext ctx, Request request, Response response){
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Access-Control-Allow-Headers", "*");
|
||||
response.send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,15 @@ import java.io.Serializable;
|
||||
public class FriendData implements Serializable {
|
||||
private String userId;
|
||||
private String friendUid;
|
||||
private String alias;
|
||||
private int state;
|
||||
private long timestamp;
|
||||
|
||||
|
||||
public FriendData(String userId, String friendUid, int state, long timestamp) {
|
||||
public FriendData(String userId, String friendUid, String alias, int state, long timestamp) {
|
||||
this.userId = userId;
|
||||
this.friendUid = friendUid;
|
||||
this.alias = alias;
|
||||
this.state = state;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
@@ -43,6 +45,14 @@ public class FriendData implements Serializable {
|
||||
this.friendUid = friendUid;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
-108
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* 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.pojos;
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.moquette.BrokerConstants;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GroupNotificationBinaryContent {
|
||||
//operator
|
||||
private String o;
|
||||
|
||||
//name
|
||||
private String n;
|
||||
|
||||
//members
|
||||
private List<String> ms;
|
||||
|
||||
//members
|
||||
private String m;
|
||||
|
||||
public GroupNotificationBinaryContent(String o, String n, String m) {
|
||||
this.o = o;
|
||||
this.n = n;
|
||||
this.m = m;
|
||||
}
|
||||
|
||||
public GroupNotificationBinaryContent(String operator, String name, List<String> members) {
|
||||
this.o = operator;
|
||||
this.n = name;
|
||||
this.ms = members;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getO() {
|
||||
return o;
|
||||
}
|
||||
|
||||
public void setO(String o) {
|
||||
this.o = o;
|
||||
}
|
||||
|
||||
public String getN() {
|
||||
return n;
|
||||
}
|
||||
|
||||
public void setN(String n) {
|
||||
this.n = n;
|
||||
}
|
||||
|
||||
public List<String> getMs() {
|
||||
return ms;
|
||||
}
|
||||
|
||||
public void setMs(List<String> ms) {
|
||||
this.ms = ms;
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getGroupNotifyContent(int groupContentType) {
|
||||
return WFCMessage.MessageContent.newBuilder().setType(groupContentType).setData(ByteString.copyFromUtf8(new Gson().toJson(this))).build();
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getAddGroupNotifyContent() {
|
||||
return getGroupNotifyContent(BrokerConstants.MESSAGE_CONTENT_TYPE_ADD_GROUP_MEMBER);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getCreateGroupNotifyContent() {
|
||||
return getGroupNotifyContent(BrokerConstants.MESSAGE_CONTENT_TYPE_CREATE_GROUP);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getDismissGroupNotifyContent() {
|
||||
return getGroupNotifyContent(BrokerConstants.MESSAGE_CONTENT_TYPE_DISMISS_GROUP);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getKickokfMemberGroupNotifyContent() {
|
||||
return getGroupNotifyContent(BrokerConstants.MESSAGE_CONTENT_TYPE_KICKOF_GROUP_MEMBER);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getQuitGroupNotifyContent() {
|
||||
return getGroupNotifyContent(BrokerConstants.MESSAGE_CONTENT_TYPE_QUIT_GROUP);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getTransferGroupNotifyContent() {
|
||||
return getGroupNotifyContent(BrokerConstants.MESSAGE_CONTENT_TYPE_TRANSFER_GROUP_OWNER);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getChangeGroupNameNotifyContent() {
|
||||
return getGroupNotifyContent(BrokerConstants.MESSAGE_CONTENT_TYPE_CHANGE_GROUP_NAME);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getChangeGroupPortraitNotifyContent() {
|
||||
return getGroupNotifyContent(BrokerConstants.MESSAGE_CONTENT_TYPE_CHANGE_GROUP_PORTRAIT);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getModifyGroupMemberAliasNotifyContent() {
|
||||
return getGroupNotifyContent(BrokerConstants.MESSAGE_CONTENT_TYPE_MODIFY_GROUP_ALIAS);
|
||||
}
|
||||
}
|
||||
@@ -60,13 +60,6 @@ public final class BrokerConstants {
|
||||
public static final String NETTY_SO_KEEPALIVE_PROPERTY_NAME = "netty.so_keepalive";
|
||||
public static final String NETTY_CHANNEL_TIMEOUT_SECONDS_PROPERTY_NAME = "netty.channel_timeout.seconds";
|
||||
public static final String NETTY_EPOLL_PROPERTY_NAME = "netty.epoll";
|
||||
public static final String METRICS_ENABLE_PROPERTY_NAME = "use_metrics";
|
||||
public static final String METRICS_LIBRATO_EMAIL_PROPERTY_NAME = "metrics.librato.email";
|
||||
public static final String METRICS_LIBRATO_TOKEN_PROPERTY_NAME = "metrics.librato.token";
|
||||
public static final String METRICS_LIBRATO_SOURCE_PROPERTY_NAME = "metrics.librato.source";
|
||||
|
||||
public static final String BUGSNAG_ENABLE_PROPERTY_NAME = "use_bugsnag";
|
||||
public static final String BUGSNAG_TOKEN_PROPERTY_NAME = "bugsnag.token";
|
||||
|
||||
public static final String STORAGE_CLASS_NAME = "storage_class";
|
||||
|
||||
@@ -100,8 +93,10 @@ public final class BrokerConstants {
|
||||
public static final String HZ_Cluster_Node_External_Short_Port = "node_external_short_port";
|
||||
public static final String HZ_Cluster_Node_ID = "node_id";
|
||||
public static final String HTTP_SERVER_SECRET_KEY = "http.admin.secret_key";
|
||||
public static final String HTTP_SERVER_API_NO_CHECK_TIME = "http.admin.no_check_time";
|
||||
|
||||
public static final String CLIENT_PROTO_SECRET_KEY = "client.proto.secret_key";
|
||||
public static final String TOKEN_SECRET_KEY = "token.key ";
|
||||
public static final String TOKEN_SECRET_KEY = "token.key";
|
||||
|
||||
public static final String EMBED_DB_PROPERTY_NAME = "embed.db";
|
||||
|
||||
@@ -111,19 +106,9 @@ public final class BrokerConstants {
|
||||
|
||||
public static final String MESSAGE_Forward_Url = "message.forward.url";
|
||||
|
||||
public static final String MESSAGE_ROAMING = "message.roaming";
|
||||
|
||||
|
||||
|
||||
|
||||
public static final int MESSAGE_CONTENT_TYPE_CREATE_GROUP = 104;
|
||||
public static final int MESSAGE_CONTENT_TYPE_ADD_GROUP_MEMBER = 105;
|
||||
public static final int MESSAGE_CONTENT_TYPE_KICKOF_GROUP_MEMBER = 106;
|
||||
public static final int MESSAGE_CONTENT_TYPE_QUIT_GROUP = 107;
|
||||
public static final int MESSAGE_CONTENT_TYPE_DISMISS_GROUP = 108;
|
||||
public static final int MESSAGE_CONTENT_TYPE_TRANSFER_GROUP_OWNER = 109;
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_GROUP_NAME = 110;
|
||||
public static final int MESSAGE_CONTENT_TYPE_MODIFY_GROUP_ALIAS = 111;
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_GROUP_PORTRAIT = 112;
|
||||
private BrokerConstants() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,16 +12,16 @@ import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import static win.liyufan.im.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
import static win.liyufan.im.IMTopic.HandleFriendRequestTopic;
|
||||
|
||||
@Handler(IMTopic.AddFriendRequestTopic)
|
||||
public class AddFriendHandler extends GroupHandler<WFCMessage.AddFriendRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.AddFriendRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.AddFriendRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
long[] head = new long[1];
|
||||
ErrorCode errorCode = m_messagesStore.saveAddFriendRequest(fromUser, request, head);
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
@@ -30,7 +30,7 @@ public class AddFriendHandler extends GroupHandler<WFCMessage.AddFriendRequest>
|
||||
publisher.publishNotification(IMTopic.NotifyFriendRequestTopic, request.getTargetUid(), head[0]);
|
||||
} 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);
|
||||
mServer.internalRpcMsg(request.getTargetUid(), null, handleFriendRequest.toByteArray(), 0, fromUser, HandleFriendRequestTopic, false);
|
||||
}
|
||||
}
|
||||
return errorCode;
|
||||
|
||||
@@ -9,26 +9,25 @@
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.xiaoleilu.loServer.pojos.GroupNotificationBinaryContent;
|
||||
import cn.wildfirechat.pojos.GroupNotificationBinaryContent;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import static win.liyufan.im.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@Handler(value = IMTopic.AddGroupMemberTopic)
|
||||
public class AddGroupMember extends GroupHandler<WFCMessage.AddGroupMemberRequest> {
|
||||
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.AddGroupMemberRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = m_messagesStore.addGroupMembers(fromUser, request.getGroupId(), request.getAddedMemberList());
|
||||
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());
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||
} else {
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(fromUser, null, getMemberIdList(request.getAddedMemberList())).getAddGroupNotifyContent();
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, null, getMemberIdList(request.getAddedMemberList())).getAddGroupNotifyContent();
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@ package io.moquette.imhandler;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import static win.liyufan.im.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@Handler(IMTopic.BlackListUserTopic)
|
||||
public class BlackListRequestHandler extends GroupHandler<WFCMessage.BlackUserRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.BlackUserRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.BlackUserRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
long[] head = new long[1];
|
||||
ErrorCode errorCode = m_messagesStore.blackUserRequest(fromUser, request.getUid(), request.getStatus(), head);
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import io.moquette.BrokerConstants;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.IMTopic;
|
||||
import win.liyufan.im.MessageShardingUtil;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ContentType.Text;
|
||||
|
||||
@Handler(value = IMTopic.BroadcastMessageTopic)
|
||||
public class BroadcastMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.Message message, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
if (message != null) {
|
||||
if (!isAdmin) { //only admin can broadcast message
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
long timestamp = System.currentTimeMillis();
|
||||
long messageId = MessageShardingUtil.generateId();
|
||||
message = message.toBuilder().setFromUser(fromUser).setMessageId(messageId).setServerTimestamp(timestamp).setConversation(WFCMessage.Conversation.newBuilder().setTarget(fromUser).setLine(message.getConversation().getLine()).setType(ProtoConstants.ConversationType.ConversationType_Private).build()).build();
|
||||
|
||||
long count = saveAndBroadcast(fromUser, clientID, message);
|
||||
ackPayload = ackPayload.capacity(20);
|
||||
ackPayload.writeLong(messageId);
|
||||
ackPayload.writeLong(count);
|
||||
} else {
|
||||
errorCode = ErrorCode.ERROR_CODE_INVALID_MESSAGE;
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,13 +9,11 @@
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.xiaoleilu.loServer.pojos.GroupNotificationBinaryContent;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import static win.liyufan.im.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
import static win.liyufan.im.IMTopic.PutUserSettingTopic;
|
||||
import static win.liyufan.im.UserSettingScope.kUserSettingListenedChannels;
|
||||
|
||||
@@ -23,11 +21,11 @@ import static win.liyufan.im.UserSettingScope.kUserSettingListenedChannels;
|
||||
public class ChannelListenMember extends IMHandler<WFCMessage.ListenChannel> {
|
||||
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.ListenChannel request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.ListenChannel request, Qos1PublishHandler.IMCallback callback) {
|
||||
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);
|
||||
mServer.internalRpcMsg(fromUser, null, modifyUserSettingReq.toByteArray(), 0, fromUser, PutUserSettingTopic, false);
|
||||
|
||||
publisher.notifyChannelListenStatusChanged(m_messagesStore.getChannelInfo(request.getChannelId()), fromUser, request.getListen() > 0);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ package io.moquette.imhandler;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.List;
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
@Handler(IMTopic.ChannelSearchTopic)
|
||||
public class ChannelSearchHandler extends IMHandler<WFCMessage.SearchUserRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.SearchUserRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.SearchUserRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
List<WFCMessage.ChannelInfo> users = m_messagesStore.searchChannel(request.getKeyword(), request.getFuzzy() > 0, request.getPage());
|
||||
WFCMessage.SearchChannelResult.Builder builder = WFCMessage.SearchChannelResult.newBuilder();
|
||||
builder.addAllChannel(users);
|
||||
|
||||
@@ -10,22 +10,18 @@ package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import com.xiaoleilu.loServer.pojos.GroupNotificationBinaryContent;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import win.liyufan.im.IDUtils;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
import win.liyufan.im.UUIDGenerator;
|
||||
|
||||
import static win.liyufan.im.IMTopic.PutUserSettingTopic;
|
||||
import static win.liyufan.im.UserSettingScope.kUserSettingListenedChannels;
|
||||
import static win.liyufan.im.UserSettingScope.kUserSettingMyChannels;
|
||||
|
||||
@Handler(value = IMTopic.CreateChannelTopic)
|
||||
public class CreateChannelHandler extends GroupHandler<WFCMessage.ChannelInfo> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.ChannelInfo request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.ChannelInfo request, Qos1PublishHandler.IMCallback callback) {
|
||||
WFCMessage.ChannelInfo.Builder builder = request.toBuilder();
|
||||
if (StringUtil.isNullOrEmpty(request.getTargetId())) {
|
||||
builder.setTargetId(m_messagesStore.getShortUUID());
|
||||
@@ -44,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);
|
||||
mServer.internalRpcMsg(fromUser, null, modifyUserSettingReq.toByteArray(), 0, fromUser, PutUserSettingTopic, false);
|
||||
byte[] data = request.getTargetId().getBytes();
|
||||
ackPayload.ensureWritable(data.length).writeBytes(data);
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@@ -9,25 +9,30 @@
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.xiaoleilu.loServer.pojos.GroupNotificationBinaryContent;
|
||||
import cn.wildfirechat.pojos.GroupNotificationBinaryContent;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import static io.moquette.BrokerConstants.MESSAGE_CONTENT_TYPE_CREATE_GROUP;
|
||||
|
||||
@Handler(value = IMTopic.CreateGroupTopic)
|
||||
public class CreateGroupHandler extends GroupHandler<WFCMessage.CreateGroupRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.CreateGroupRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.CreateGroupRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
|
||||
if (!StringUtil.isNullOrEmpty(request.getGroup().getGroupInfo().getTargetId())) {
|
||||
WFCMessage.GroupInfo existGroupInfo = m_messagesStore.getGroupInfo(request.getGroup().getGroupInfo().getTargetId());
|
||||
if (existGroupInfo != null) {
|
||||
return ErrorCode.ERROR_CODE_GROUP_ALREADY_EXIST;
|
||||
}
|
||||
}
|
||||
WFCMessage.GroupInfo groupInfo = m_messagesStore.createGroup(fromUser, request.getGroup().getGroupInfo(), request.getGroup().getMembersList());
|
||||
if (groupInfo != null) {
|
||||
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, groupInfo.getTargetId(), request.getToLineList(), request.getNotifyContent());
|
||||
} else {
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(fromUser, groupInfo.getName(), "").getCreateGroupNotifyContent();
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(groupInfo.getTargetId(), fromUser, groupInfo.getName(), "").getCreateGroupNotifyContent();
|
||||
sendGroupNotification(fromUser, groupInfo.getTargetId(), request.getToLineList(), content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,21 @@ package io.moquette.imhandler;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@Handler(IMTopic.DeleteFriendTopic)
|
||||
public class DeleteFriendHandler extends IMHandler<WFCMessage.IDBuf> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.IDBuf request, Qos1PublishHandler.IMCallback callback) {
|
||||
return m_messagesStore.deleteFriend(fromUser, request.getId());
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.IDBuf request, Qos1PublishHandler.IMCallback callback) {
|
||||
long[] head = new long[2];
|
||||
ErrorCode errorCode = m_messagesStore.deleteFriend(fromUser, request.getId(), head);
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
publisher.publishNotification(IMTopic.NotifyFriendTopic, fromUser, head[0]);
|
||||
publisher.publishNotification(IMTopic.NotifyFriendTopic, request.getId(), head[1]);
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,33 +10,33 @@ package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.xiaoleilu.loServer.pojos.GroupNotificationBinaryContent;
|
||||
import cn.wildfirechat.pojos.GroupNotificationBinaryContent;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
import static win.liyufan.im.IMTopic.DismissGroupTopic;
|
||||
|
||||
@Handler(value = DismissGroupTopic)
|
||||
public class DismissGroupHandler extends GroupHandler<WFCMessage.DismissGroupRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.DismissGroupRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.DismissGroupRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
WFCMessage.GroupInfo groupInfo = m_messagesStore.getGroupInfo(request.getGroupId());
|
||||
ErrorCode errorCode;
|
||||
if (groupInfo == null) {
|
||||
errorCode = m_messagesStore.dismissGroup(fromUser, request.getGroupId());
|
||||
errorCode = m_messagesStore.dismissGroup(fromUser, request.getGroupId(), isAdmin);
|
||||
|
||||
} else if ((groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted)
|
||||
} else if (isAdmin || (groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted)
|
||||
&& groupInfo.getOwner() != null && groupInfo.getOwner().equals(fromUser)) {
|
||||
|
||||
//send notify message first, then dismiss group
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, groupInfo.getTargetId(), request.getToLineList(), request.getNotifyContent());
|
||||
} else {
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(fromUser, null, "").getDismissGroupNotifyContent();
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(groupInfo.getTargetId(), fromUser, null, "").getDismissGroupNotifyContent();
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), content);
|
||||
}
|
||||
errorCode = m_messagesStore.dismissGroup(fromUser, request.getGroupId());
|
||||
errorCode = m_messagesStore.dismissGroup(fromUser, request.getGroupId(), isAdmin);
|
||||
} else {
|
||||
errorCode = ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ package io.moquette.imhandler;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import static win.liyufan.im.IMTopic.PutUserSettingTopic;
|
||||
@@ -20,11 +20,11 @@ import static win.liyufan.im.UserSettingScope.kUserSettingMyChannels;
|
||||
@Handler(value = IMTopic.DestoryChannelInfoTopic)
|
||||
public class DistoryChannelHandler extends GroupHandler<WFCMessage.IDBuf> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.IDBuf request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.IDBuf request, Qos1PublishHandler.IMCallback callback) {
|
||||
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);
|
||||
mServer.internalRpcMsg(fromUser, null, modifyUserSettingReq.toByteArray(), 0, fromUser, PutUserSettingTopic, false);
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import com.xiaoleilu.loServer.model.FriendData;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.List;
|
||||
@@ -20,12 +21,16 @@ import java.util.List;
|
||||
@Handler(IMTopic.FriendPullTopic)
|
||||
public class FriendPullHandler extends IMHandler<WFCMessage.Version> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.Version request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.Version request, Qos1PublishHandler.IMCallback callback) {
|
||||
List<FriendData> friendDatas = m_messagesStore.getFriendList(fromUser, request.getVersion());
|
||||
WFCMessage.GetFriendsResult.Builder builder = WFCMessage.GetFriendsResult.newBuilder();
|
||||
for (FriendData data : friendDatas
|
||||
) {
|
||||
builder.addEntry(WFCMessage.Friend.newBuilder().setState(data.getState()).setUid(data.getFriendUid()).setUpdateDt(data.getTimestamp()).build());
|
||||
WFCMessage.Friend.Builder builder1 = WFCMessage.Friend.newBuilder().setState(data.getState()).setUid(data.getFriendUid()).setUpdateDt(data.getTimestamp());
|
||||
if (!StringUtil.isNullOrEmpty(data.getAlias())) {
|
||||
builder1.setAlias(data.getAlias());
|
||||
}
|
||||
builder.addEntry(builder1.build());
|
||||
}
|
||||
byte[] data = builder.build().toByteArray();
|
||||
ackPayload.ensureWritable(data.length).writeBytes(data);
|
||||
|
||||
@@ -11,7 +11,7 @@ package io.moquette.imhandler;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.List;
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
@Handler(IMTopic.FriendRequestPullTopic)
|
||||
public class FriendRequestPullHandler extends IMHandler<WFCMessage.Version> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.Version request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.Version request, Qos1PublishHandler.IMCallback callback) {
|
||||
List<WFCMessage.FriendRequest> friendDatas = m_messagesStore.getFriendRequestList(fromUser, request.getVersion());
|
||||
WFCMessage.GetFriendRequestResult.Builder builder = WFCMessage.GetFriendRequestResult.newBuilder();
|
||||
builder.addAllEntry(friendDatas);
|
||||
|
||||
@@ -11,13 +11,13 @@ package io.moquette.imhandler;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
@Handler(IMTopic.ChannelPullTopic)
|
||||
public class GetChannelInfoHandler extends IMHandler<WFCMessage.PullChannelInfo> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.PullChannelInfo request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.PullChannelInfo request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
WFCMessage.ChannelInfo info = m_messagesStore.getChannelInfo(request.getChannelId());
|
||||
if (info == null) {
|
||||
|
||||
@@ -11,13 +11,13 @@ package io.moquette.imhandler;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
@Handler(IMTopic.GetChatroomInfoTopic)
|
||||
public class GetChatroomInfoHandler extends IMHandler<WFCMessage.GetChatroomInfoRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.GetChatroomInfoRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.GetChatroomInfoRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
WFCMessage.ChatroomInfo info = m_messagesStore.getChatroomInfo(request.getChatroomId());
|
||||
if (info == null) {
|
||||
|
||||
@@ -11,13 +11,13 @@ package io.moquette.imhandler;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
@Handler(IMTopic.GetChatroomMemberTopic)
|
||||
public class GetChatroomMemberHandler extends IMHandler<WFCMessage.GetChatroomMemberInfoRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.GetChatroomMemberInfoRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.GetChatroomMemberInfoRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
WFCMessage.ChatroomMemberInfo info = m_messagesStore.getChatroomMemberInfo(request.getChatroomId(), request.getMaxCount());
|
||||
if (info != null) {
|
||||
|
||||
@@ -11,7 +11,7 @@ package io.moquette.imhandler;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.List;
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
@Handler(IMTopic.GetGroupInfoTopic)
|
||||
public class GetGroupInfoHandler extends IMHandler<WFCMessage.PullUserRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.PullUserRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.PullUserRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
List<WFCMessage.GroupInfo> infos = m_messagesStore.getGroupInfos(request.getRequestList());
|
||||
|
||||
WFCMessage.PullGroupInfoResult result = WFCMessage.PullGroupInfoResult.newBuilder().addAllInfo(infos).build();
|
||||
|
||||
@@ -11,18 +11,18 @@ package io.moquette.imhandler;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.ErrorCode;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static win.liyufan.im.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@Handler(IMTopic.GetGroupMemberTopic)
|
||||
public class GetGroupMemberHandler extends IMHandler<WFCMessage.PullGroupMemberRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.PullGroupMemberRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.PullGroupMemberRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
List<WFCMessage.GroupMember> members = new ArrayList<>();
|
||||
ErrorCode errorCode = m_messagesStore.getGroupMembers(request.getTarget(), request.getHead(), members);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user