Compare commits

...
87 Commits
Author SHA1 Message Date
heavyrian2012 30cd56aae2 version 0.92 2022-08-19 08:23:19 +08:00
heavyrian2012 6fbecfb0fb 去掉无效的警告 2022-08-19 08:15:03 +08:00
heavyrian2012 d2cb8427bb 解决下载zip包编译失败的问题 2022-08-19 08:05:54 +08:00
heavyrian2012 826bad2d66 add menuid and extra 2022-08-16 20:10:56 +08:00
heavyrian2012 aaccec00e9 add article content 2022-08-16 15:05:30 +08:00
heavyrian2012 3c1c5ce6d3 menu 2022-08-14 22:08:35 +08:00
heavyrian2012 b0fe1636a7 添加配置,在关闭消息漫游时,客户端首次登陆同步多久时间以内的消息 2022-08-14 15:25:00 +08:00
heavyrian2012 014cd3844d 频道只有auto为1时才会回调消息和订阅事件。频道只回调用户发送的消息,自己发送的消息不回调 2022-08-09 15:39:34 +08:00
heavyrian2012 6cc00950f0 SDK部分pojo对象添加无参数构造函数 2022-08-09 12:17:59 +08:00
heavyrian2012 2918c06a01 version 0.91 2022-08-03 12:41:35 +08:00
heavyrian2012 c3b9b9fccf 群组添加成员时,检查是否已经存在群组成员, fix issue #501 2022-08-03 12:19:03 +08:00
heavyrian2012 8c88d5a13f 添加注释 2022-07-29 20:37:53 +08:00
heavyrian2012 967526f5ec 添加发送消息payload错误时的提醒 2022-07-29 20:33:18 +08:00
heavyrian2012 109078abca 参数有效性检查 2022-07-29 20:24:41 +08:00
heavyrian2012 79a58e99aa 添加配置运行回调消息带上客户端信息 2022-07-27 11:36:04 +08:00
heavyrian2012 a394444c86 创建群组时,检查群组类型的有效性 2022-07-21 22:10:39 +08:00
heavyrian2012 dece1d7a1c sdk 添加获取会话阅读时间和消息送达时间接口 2022-07-20 22:25:46 +08:00
heavyrian2012 2b09a7bf84 version 0.90 2022-07-14 20:25:52 +08:00
heavyrian2012 200a6ebd04 添加注释 2022-07-14 20:22:36 +08:00
heavyrian2012 54db1f3b06 触发限频后多调用了一次callback,去掉无用的调用 2022-07-06 10:05:57 +08:00
heavyrian2012 3b90d145a4 去掉绑定IP地址的配置,防止客户误操作 2022-06-28 08:34:17 +08:00
heavyrain.lee e16a116fe4 Merge pull request #487 from wildfirechat/dependabot/maven/broker/mysql-mysql-connector-java-8.0.28
Bump mysql-connector-java from 8.0.19 to 8.0.28 in /broker
2022-06-26 18:34:33 +08:00
dependabot[bot] 7bd0937069 Bump mysql-connector-java from 8.0.19 to 8.0.28 in /broker
Bumps [mysql-connector-java](https://github.com/mysql/mysql-connector-j) from 8.0.19 to 8.0.28.
- [Release notes](https://github.com/mysql/mysql-connector-j/releases)
- [Changelog](https://github.com/mysql/mysql-connector-j/blob/release/8.0/CHANGES)
- [Commits](https://github.com/mysql/mysql-connector-j/compare/8.0.19...8.0.28)

---
updated-dependencies:
- dependency-name: mysql:mysql-connector-java
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-06-21 00:59:19 +00:00
heavyrian2012 c085057032 修正拼写错误 2022-06-09 15:03:56 +08:00
heavyrian2012 eac6648fc0 version 0.89 2022-06-09 09:42:34 +08:00
heavyrian2012 300f9aa0e6 update readme 2022-06-07 21:12:33 +08:00
heavyrian2012 dd40b72ec4 添加允许pc多端的配置 2022-06-06 09:37:37 +08:00
heavyrian2012 556e6ad2a0 解决某些java版本下反序列化IMResult<Void>失败问题 2022-05-27 13:25:21 +08:00
heavyrian2012 473ae32f57 update readme 2022-05-27 10:14:00 +08:00
heavyrian2012 d57ae2ed58 删除群组时清除相关设置 2022-05-27 08:35:12 +08:00
heavyrian2012 1a6907efd3 log4j version 2.17.2 2022-05-25 10:16:40 +08:00
heavyrain.lee 1624c470d6 Merge pull request #480 from wildfirechat/dependabot/maven/common/com.google.code.gson-gson-2.8.9
Bump gson from 2.8.2 to 2.8.9 in /common
2022-05-25 10:10:17 +08:00
heavyrain.lee 5ea6eefe67 Merge pull request #481 from wildfirechat/dependabot/maven/sdk/com.google.code.gson-gson-2.8.9
Bump gson from 2.8.2 to 2.8.9 in /sdk
2022-05-25 10:10:02 +08:00
heavyrian2012 8aebb2537a version 0.88 2022-05-23 14:53:40 +08:00
heavyrian2012 250b0ccebe 解决server api撤回单聊消息无法撤回的问题 2022-05-23 14:20:30 +08:00
heavyrian2012 91669c634f add send articles message builder 2022-05-22 11:26:01 +08:00
dependabot[bot] bf51cb9829 Bump gson from 2.8.2 to 2.8.9 in /sdk
Bumps [gson](https://github.com/google/gson) from 2.8.2 to 2.8.9.
- [Release notes](https://github.com/google/gson/releases)
- [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/gson/compare/gson-parent-2.8.2...gson-parent-2.8.9)

---
updated-dependencies:
- dependency-name: com.google.code.gson:gson
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-20 21:09:22 +00:00
dependabot[bot] baadcac2c6 Bump gson from 2.8.2 to 2.8.9 in /common
Bumps [gson](https://github.com/google/gson) from 2.8.2 to 2.8.9.
- [Release notes](https://github.com/google/gson/releases)
- [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/gson/compare/gson-parent-2.8.2...gson-parent-2.8.9)

---
updated-dependencies:
- dependency-name: com.google.code.gson:gson
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-20 21:09:06 +00:00
heavyrian2012 6c69a5ac96 null 判断 2022-05-19 12:37:01 +08:00
heavyrian2012 eb19ed3301 添加富通知消息的发送测试 2022-05-19 10:29:24 +08:00
heavyrian2012 5be7576bb8 管理端口获取authCode时使用默认的applicationId 2022-05-15 17:16:37 +08:00
heavyrian2012 86d552cd82 管理端口也添加获取应用authCode的方法 2022-05-15 15:07:51 +08:00
heavyrian2012 391f7345c0 add authcode and config api for open platform 2022-05-15 10:19:07 +08:00
heavyrian2012 92fa40f1fd 添加server api和机器人api获取机器人信息的接口 2022-05-13 14:38:26 +08:00
heavyrian2012 3b3c05260c 频道automic状态为1所有消息都不发送到owner,无论callback是否存在 2022-05-12 08:47:26 +08:00
heavyrian2012 4e9cf86302 机器人和频道回调消息带上messageid和时间戳 2022-05-11 09:28:06 +08:00
heavyrian2012 cbb89bbfb5 解决删除用户时,没有回调取消订阅通知的问题 2022-05-07 09:16:15 +08:00
heavyrian2012 537221b0b4 add application token 2022-05-02 22:07:54 +08:00
heavyrian2012 9d23f9c996 优化频道订阅关系缓存逻辑 2022-05-02 11:12:19 +08:00
heavyrian2012 6a25a83857 删除用户或删除频道时,删除对于的订阅关系 2022-05-02 11:05:56 +08:00
heavyrian2012 d0e533ad21 channel add member index 2022-05-02 10:57:46 +08:00
heavyrian2012 cd0e07f32d 优化sql语句 2022-05-01 12:14:07 +08:00
heavyrian2012 a6869c9072 消息表添加会话索引 2022-04-30 21:30:06 +08:00
heavyrian2012 03b3bb2093 同步专业版数据库及错误码 2022-04-30 08:01:45 +08:00
heavyrian2012 304192e303 version 0.87 2022-04-27 18:42:34 +08:00
heavyrian2012 9490226757 update 2022-04-26 20:12:52 +08:00
heavyrian2012 c44062855b 添加获取单条消息的接口 2022-04-26 20:05:35 +08:00
heavyrian2012 9d96fe927f 添加配置,当删除用户时是否保留用户昵称 2022-04-26 19:50:53 +08:00
heavyrian2012 ef21bd6db3 update readme 2022-04-05 15:26:33 +08:00
imndx dc0b718083 Update README.md 2022-04-01 09:12:05 +08:00
heavyrian2012 c0703332d6 在线状态 2022-03-24 09:49:18 +08:00
heavyrian2012 def048836f 在线状态 2022-03-24 08:38:33 +08:00
heavyrian2012 806cd440e3 修正在线状态问题 2022-03-23 21:45:27 +08:00
heavyrian2012 a3f2623d7e 处理disconnect的在线状态 2022-03-23 19:55:58 +08:00
heavyrian2012 4bc5fd6bb9 version 0.86 2022-03-20 20:34:23 +08:00
heavyrian2012 be2979c9a9 获取在线用户结果的变量改成公开的 2022-03-03 14:31:27 +08:00
heavyrian2012 b7a30e1d14 注释 2022-02-24 21:37:05 +08:00
heavyrian2012 beb591fdc5 version 0.85 2022-02-22 16:16:47 +08:00
heavyrian2012 d090244be9 解决可能内存泄漏的问题 2022-02-22 15:31:50 +08:00
heavyrian2012 22708caaaa 不能反复撤回消息 2022-02-22 15:29:53 +08:00
heavyrain2012 2b24fb9f44 添加conference 服务不可用错误码 2022-02-17 14:55:09 +08:00
heavyrain2012 b8ccab5dde update version to 0.84 2022-02-11 20:20:55 +08:00
heavyrian2012 9d29357ffa 解决使用内置存储文件上传时内存释放问题 2022-02-09 23:04:51 +08:00
heavyrian2012 dabb92571a 定向消息,如果目标用户多于1人,取第一个保存到数据库中 2022-02-09 22:58:48 +08:00
heavyrian2012 acb4cf81de version 0.83 2022-01-29 14:03:11 +08:00
heavyrian2012 ace676d215 修改接受好友后通知其他端的问题 2022-01-29 13:47:34 +08:00
heavyrian2012 1170c4209b fix test code 2022-01-29 11:47:19 +08:00
heavyrian2012 57e8814d9c 同步专业版代码 2022-01-29 11:43:44 +08:00
heavyrian2012 e3d9e0d183 处理好友请求后通知客户端更新好友请求信息 2022-01-26 21:53:35 +08:00
heavyrian2012 d6f5614f49 version 0.82 2022-01-26 13:45:29 +08:00
heavyrian2012 9ed4ab7e08 同步专业版SDK 2022-01-17 19:33:32 +08:00
heavyrian2012 4da3d3421d sdk中添加更新消息的接口 2022-01-13 20:57:02 +08:00
heavyrain2012 40ef9abd35 销毁用户时,清理干净所有信息 2022-01-08 16:36:18 +08:00
heavyrian2012 6f5b021c89 解决在线逻辑错误问题 2022-01-06 09:56:46 +08:00
heavyrian2012 f8f225d741 version 0.81 2022-01-05 14:31:37 +08:00
imndx 546110f6d3 修复存储用户消息错误问题 2022-01-05 11:26:40 +08:00
heavyrain2012 c7dbf45af6 当关闭pc在线通知时可以清理掉历史在线状态 2021-12-30 16:47:00 +08:00
109 changed files with 7993 additions and 645 deletions
+89 -44
View File
@@ -1,54 +1,66 @@
## 野火IM解决方案
# 野火IM解决方案
野火IM是专业级的即时通讯和实时音视频整体解决方案,由北京野火无限网络科技有限公司维护和支持。
野火IM是专业级即时通讯和实时音视频整体解决方案,由北京野火无限网络科技有限公司维护和支持。
## 功能特性
* 极致地硬件利用率,IM服务最低128M内存即可运行,上不封顶。
* 协议先进,采用MQTT+Protobuf组合,流量和性能极致优化。
* 性能强大,专业版IM服务支持百万在线和集群部署。
* 部署运维简单,依赖服务少,稍加配置一键启动。
* 安全加密。网络连接AES加密。客户端数据库SqlCipher加密。安全无小事。
* 全平台客户端,四端同时在线(移动端,pc端,web端和小程序端),数据和状态多端完美同步。
* 支持国产化。支持国产化操作系统、国产化芯片和国产操作系统。支持国密加密。
* 客户端使用微信[mars](https://github.com/tencent/mars)连接库,野火IM可能是最适应中国网络国情的即时通讯服务。
* 支持加速点加速,即可用于全球应用,也可用于政企内外双网复杂的网络环境。
* 支持阅读回执和在线状态功能,适用于办公环境。
* 音视频多种解决方案,丰俭由人,可自由选择。
* 高级音视频功能强大,支持9人以上的群组视频通话,支持1080P视频,支持会议模式,支持百人以上会议,支持服务器端录制。
* 全私有部署,可不依赖任何第三方服务,完全内网部署。
* 功能齐全,涵盖所有常见即时通讯功能。另外具有强大的可扩展能力。Demo成熟完善,基本可以做到开箱即用,也可把SDK嵌入其它应用。
* 拥有应用开放平台,可以开发和创建自建应用,扩展您的工作台。
* API丰富,方便与其它服务系统的对接。
* 拥有机器人和频道功能。
主要特性有:私有部署安全可靠,性能强大,功能齐全,全平台支持,开源率高,部署运维简单,二次开发友好,方便与第三方系统对接或者嵌入现有系统中。详细情况请参考[在线文档](https://docs.wildfirechat.cn)。
## 野火开源项目
主要包括以下项目:
主要包括一下项目:
| [GitHub仓库地址](https://github.com/wildfirechat) | [码云仓库地址](https://gitee.com/wfchat) | 说明
| ------------------------------------------------------------ | ----------------------------------------------------- | --------------------------------------------------------------------------
| [im-server](https://github.com/wildfirechat/im-server) | [im-server](https://gitee.com/wfchat/im-server) | 野火社区版IM服务,野火IM的核心服务,处理所有IM相关业务。 |
| [app_server](https://github.com/wildfirechat/app_server) | [app_server](https://gitee.com/wfchat/app_server) | Demo应用服务,模拟客户的应用服登陆处理逻辑及部分二次开发示例。 |
| [robot_server](https://github.com/wildfirechat/robot_server) | [robot_server](https://gitee.com/wfchat/robot_server) | 机器人服务,演示野火机器人对接其它系统的方法。 |
| [push_server](https://github.com/wildfirechat/push_server) | [push_server](https://gitee.com/wfchat/push_server) | 推送服务器,可以对接所有的系统厂商推送服务或者第三方推送服务。 |
| [wf-minio](https://github.com/wildfirechat/WF-minio) | [wf-minio](https://gitee.com/wfchat/WF-minio) | 私有对象存储服务,用来支持野火IM专业版的文件存储。 |
| [wf-janus](https://github.com/wildfirechat/wf-janus ) | [wf-janus](https://gitee.com/wfchat/wf-janus ) | 高级音视频媒体服务。 |
| [open-platform](https://github.com/wildfirechat/open-platform) | [open-platform](https://gitee.com/wfchat/open-platform) | 野火开放平台服务。 |
| [daily-report](https://github.com/wildfirechat/daily-report) | [daily-report](https://github.com/wildfirechat/daily-report) | 野火开放平台日报 demo服务。 |
| [android-chat](https://github.com/wildfirechat/android-chat) | [android-chat](https://gitee.com/wfchat/android-chat) | 野火IM Android SDK源码和App源码。
| [ios-chat](https://github.com/wildfirechat/ios-chat) | [ios-chat](https://gitee.com/wfchat/ios-chat) | 野火IM iOS SDK源码和App源码。
| [pc-chat](https://github.com/wildfirechat/vue-pc-chat) | [pc-chat](https://gitee.com/wfchat/vue-pc-chat) | 基于[Electron](https://electronjs.org/)的PC 端,支持Windows、Mac、Linux(包括国产化linux系统和CPU)。 |
| [web-chat](https://github.com/wildfirechat/vue-chat) | [web-chat](https://gitee.com/wfchat/vue-chat) | 野火IM Web 端, [体验地址](https://web.wildfirechat.cn) |
| [wx-chat](https://github.com/wildfirechat/wx-chat) | [wx-chat](https://gitee.com/wfchat/wx-chat) | 小程序平台的Demo(支持微信、百度、阿里、字节、QQ 等小程序平台) |
| [uni-chat](https://github.com/wildfirechat/uni-chat) | [uni-chat](https://gitee.com/wfchat/uni-chat) | UniApp平台移动端应用(使用原生插件) |
| [uni-wfc-client](https://github.com/wildfirechat/uni-wfc-client) | [uni-wfc-client](https://gitee.com/wfchat/uni-wfc-client) | UniApp平台原生插件 |
| [flutter_imclient](https://github.com/wildfirechat/flutter_imclient) | [flutter_imclient](https://gitee.com/wfchat/flutter_imclient) | Flutter平台原生插件 |
| [docs](https://github.com/wildfirechat/docs) | [docs](https://gitee.com/wfchat/docs) | 野火IM相关文档,包含设计、概念、开发、使用说明,[在线查看](https://docs.wildfirechat.cn/) |
| [GitHub仓库地址(主站)](https://github.com/wildfirechat) | [码云仓库地址(镜像)](https://gitee.com/wfchat) | 说明 | 备注 |
| ------------------------------------------------------------ | ----------------------------------------------------- | ----------------------------------------------------------------------------------------- | ---------------------------------------------- |
| [android-chat](https://github.com/wildfirechat/android-chat) | [android-chat](https://gitee.com/wfchat/android-chat) | 野火IM Android SDK源码和App源码 | 可以很方便地进行二次开发,或集成到现有应用当中 |
| [ios-chat](https://github.com/wildfirechat/ios-chat) | [ios-chat](https://gitee.com/wfchat/ios-chat) | 野火IM iOS SDK源码和App源码 | 可以很方便地进行二次开发,或集成到现有应用当中 |
| [pc-chat](https://github.com/wildfirechat/pc-chat) | [pc-chat](https://gitee.com/wfchat/pc-chat) | 基于[Electron](https://electronjs.org/)开发的PC平台应用 | |
| [web-chat](https://github.com/wildfirechat/web-chat) | [web-chat](https://gitee.com/wfchat/web-chat) | Web平台的Demo, [体验地址](http://web.wildfirechat.cn) | |
| [wx-chat](https://github.com/wildfirechat/wx-chat) | [wx-chat](https://gitee.com/wfchat/wx-chat) | 微信小程序平台的Demo | |
| [server](https://github.com/wildfirechat/server) | [server](https://gitee.com/wfchat/server) | IM server | |
| [app server](https://github.com/wildfirechat/app_server) | [app server](https://gitee.com/wfchat/app_server) | 应用服务端 | |
| [robot_server](https://github.com/wildfirechat/robot_server) | [robot_server](https://gitee.com/wfchat/robot_server) | 机器人服务端 | |
| [push_server](https://github.com/wildfirechat/push_server) | [push_server](https://gitee.com/wfchat/push_server) | 推送服务器 | |
| [docs](https://github.com/wildfirechat/docs) | [docs](https://gitee.com/wfchat/docs) | 野火IM相关文档,包含设计、概念、开发、使用说明,[在线查看](https://docs.wildfirechat.cn/) | | |
## 野火开发文档
[在线文档](https://docs.wildfirechat.cn/)
# server
本工程为野火IM 社区版IM服务软件。野火IM作为一个通用的即时通讯解决方案,既可以直接使用,也可以集成到各种应用中。
开发一套IM系统真的很艰辛,请路过的朋友们给点个star,支持我们坚持下去🙏🙏🙏🙏🙏
### 联系我们
> 商务合作请优先采用邮箱和我们联系。技术问题请到[野火IM论坛](http://bbs.wildfirechat.cn/)发帖交流
1. heavyrain.lee 邮箱: heavyrain.lee@wildfirechat.cn 微信:wildfirechat
2. imndx 邮箱: imndx@wildfirechat.cn 微信:wfchat
### 问题交流
1. 如果大家发现bug,请在GitHub提issue
2. 其他问题,请到[野火IM论坛](http://bbs.wildfirechat.cn/)进行交流学习
3. 微信公众号
<img src="http://static.wildfirechat.cn/wx_wfc_qrcode.jpg" width = 50% height = 50% />
> 强烈建议关注我们的公众号。我们有新版本发布或者有重大更新会通过公众号通知大家,另外我们也会不定期的发布一些关于野火IM的技术介绍。
#### 体验Demo
我们提供了体验demo,请使用微信扫码下载安装体验
## 野火Demo
请使用微信扫码下载安装体验野火IM移动客户端
![野火IM](http://static.wildfirechat.cn/download_qrcode.png)
#### 应用截图
Web客户端点击[这里](https://web.wildfirechat.cn)
PC客户端点[这里](https://github.com/wildfirechat/vue-pc-chat/releases)下载安装。
小程序客户端请用微信扫码
![野火IM](http://static.wildfirechat.net/wx.jpg)
## 应用截图
![ios-demo](http://static.wildfirechat.cn/ios-demo.gif)
<img src="http://static.wildfirechat.cn/ios-message-view.png" width = 50% height = 50% />
@@ -71,16 +83,49 @@
<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```
在安装JDK1.8以上及maven的前提下,在命令行中执行```mvn clean package```,生成的目标文件在```./distribution/target/distribution-xxxx-bundle-tar.tar.gz```
> 由于使用了一个git的maven插件,如果本地没有git信息就会编译出错,请使用```git clone```的方法下载代码,或者下载压缩包解压后在根目录创建```.git```的空目录。建议用```git clone```的方式下载代码。
## 配置
解压```distribution-xxxx-bundle-tar.tar.gz```,修改解压出来的```config```目录下的```wildfirechat.conf```。修改如下部分:
1. 修改```server.ip```为您的服务器的公网IP,或者域名。如果用域名需要做好域名解析。
2. 可以阅读配置文件注释和文档,对其它配置项进行调整。
## 运行
在程序目录运行如下命令:
```
./bin/wildfirechat.sh
```
## 验证
1. 在浏览器中输入地址 ```http://${ip}/api/version```可以看到返回一个json文件。
2. 部署[应用服务](应用服务),配置和编译[Android客户端](https://github.com/wildfirechat/android-chat)和[iOS客户端](https://github.com/wildfirechat/ios-chat)进行验证。详情可参考[快速开始](https://docs.wildfirechat.cn/quick_start/)。
## 升级说明
1. 从0.42 版本增加了群成员数限制,默认为2000。如果您从之前的版本升级到这个版本或以后,需要注意到群成员数的限制。升级之后超出限制的群不受影响,但不能继续加人,如果您想修改默认值,可以在升级版本之后,修改t_setting表,把默认的大小改为您期望的人数。另外修改t_group表,把已经存在的群组max_member_count改成您期望的,然后重启。
2. 0.46和0.47版本升级到0.48及以后版本时,可能会提示flyway migrate 38错误,请执行 [修复脚本](https://github.com/wildfirechat/server/blob/wildfirechat/flyway_repaire_migrate_38.sql) 进行修复。0.46和0.47版本之外的版本不会出现此问题。
3. 从0.54之前版本升级到0.54及以后版本时,会提示flyway migrate错误。因为0.54版本删除了sql脚本中默认敏感词的内容,flyway checksum失败。请执行```update flyway_schema_history set checksum = 0 where script = 'V17__add_default_sensitive_word.sql';```来修复。
4. 从0.59之前的版本升级到之后的版本执行数据库升级时间比较长,请耐心等待提示运行成功,避免中途中断。
## 联系我们
商务合作请使用如下邮箱和微信联系:
邮箱: support@wildfirechat.cn 微信1:wfchat 微信2:wildfirechat
## 问题交流
1. 如果大家发现bug,请在GitHub提issue;如果有需求也请给我们提issue。
2. 其他问题,请到[野火IM论坛](http://bbs.wildfirechat.cn/)进行交流学习
3. 关注我们的公众号。我们有新版本发布或者有重大更新会通过公众号通知大家,另外我们也会不定期的发布一些关于野火IM的技术介绍。
<img src="http://static.wildfirechat.cn/wx_wfc_qrcode.jpg" width = 50% height = 50% />
> 我们有研发工程师轮流值班处理issue和论坛,一般简单问题几个小时就会回复一遍,疑难Bug的修改和新需求的开发我们也会尽快解决。
## 特别感谢
1. [moquette](https://github.com/moquette-io/moquette) 本项目是基于此项目二次开发而来,处理MQTT相关业务。
2. [loServer](https://github.com/looly/loServer) 本项目使用loServer处理HTTP相关业务。
+24 -6
View File
@@ -26,8 +26,8 @@ http.admin.port 18080
##节点ID,当集群部署时,一定不能有重复。
node_id 1
##绑定IP,保持不变即可
host 0.0.0.0
##绑定IP,不要打开,除非有特殊需求才可以打开
#host 0.0.0.0
##本地绑定端口
local_port 80
@@ -38,6 +38,7 @@ embed.db 1
## 是否自动清理历史消息记录,当为true时,IM服务会定时扫描t_messages_x和t_user_messages_x表,清除掉3年前的历史消息。
## 如果不开启自动清理,需要手动清理t_messages_x和t_user_messages_x表内的历史数据,保存数据不能超过3年。
## 如果需要消息保存更长时间,可以把临近销毁的消息转储到别的数据库,客户端在拉取不到服务器消息时,再去转储的数据库拉取。
## 使用mongodb时次开关无效(因为mongodb设置了消息过期时间,会自动清理,仅专业版支持mongodb)。
db.auto_clean_history_messages true
@@ -56,10 +57,13 @@ token.key testim
##token.expire_time 2592000000
##首次登录,是否接收之前的历史消息。
##0 不接收历史消息,只接收5分钟以内的消息,由于服务器没有保存已经收取记录,所以如果有超过5分钟之前未收取的消息也不会收取下拉;
##0 不接收历史消息,只接收${message.compensate_time_limit}毫秒以内的消息,由于服务器没有保存已经收取记录,所以如果有超过${message.compensate_time_limit}毫秒之前未收取的消息也不会收取下拉;
##1接收,会接收 message.max_queue 配置的条数的历史消息
message.roaming 0
## 消息补偿时限,当${message.roaming}为0时,会同步时限以内且小于${message.max_queue}的消息,默认时限为5分钟。当${message.roaming}为1时,会接收 message.max_queue 配置的条数的历史消息。
message.compensate_time_limit 300000
##是否开启拉取远程历史消息。如果为1,客户端在会话内如果本地消息读取完了,可以下拉继续加载在服务器上的该会话的消息;如果为0则不能。
message.remote_history_message 0
@@ -108,6 +112,14 @@ message.global_mute_exception_types 401,402,403,404,405,407,408,410,411
## 当为true时,不转发server api发送的消息;当为false时,转发server api发送的消息。
message.no_forward_admin_message false
## 消息转发功能开启时,转发信息是否带上用户clientId和平台类型。
message.forward_with_client_info false
## 机器人回调信息是否带上用户clientId和平台类型。
robot.callback_with_client_info false
## 频道回调信息是否带上用户clientId和平台类型。
channel.callback_with_client_info false
##禁止搜索用户
friend.disable_search false
@@ -118,13 +130,13 @@ friend.disable_nick_name_search false
##禁止发送好友邀请,通过server api添加好友不受此限制(force参数需要为true)
friend.disable_friend_request false
##好友请求重复发送的间隔,单位是毫秒,默认是7天,0为不限制
##好友请求重复发送的间隔,单位是毫秒,默认是7天,0为无限长期限。
friend.repeat_request_duration 604800000
##好友请求被拒绝后再次发送的间隔,单位是毫秒,默认是30天,0为不限制
##好友请求被拒绝后再次发送的间隔,单位是毫秒,默认是30天,0为不限制。不能小于friend.repeat_request_duration。
friend.reject_request_duration 2592000000
##好友请求过期时间,单位是毫秒,默认是7天,0为不限制
##好友请求过期时间,单位是毫秒,默认是7天,0为无限长期限。
friend.request_expiration_duration 604800000
##添加好友后会发送欢迎消息,比如"你们已经是好友了,可以聊天了"。这个开关控制是用旧的方式还是用新的方式。
@@ -157,6 +169,9 @@ group.visible_quit_or_kickoff_notification 0
## 注意,修改本配置不会对已经同步的信息产生影响。
#user.hide_properties 3,4,5
## 销毁用户时,用户信息会被清空,deleted字段设置为1,这个开关控制是否保留用户昵称,默认为true。
user.keep_display_name_when_destroy true
# 好友/好友请求/用户设置 这三类数据同步的最大条目数。之前是客户第一次登录时,会把所有的对应数据一次下载到客户端,但如果有特别多的信息,会导致无法同步到客户端,
# 因此需要分段多次同步,此开关定义了每次同步的数据的条数。此需要客户端支持,客户端SDK在2021.5.25日后支持此功能。如果确认所有客户端都在这个日志之后才可以打开此设置。
#sync.data_part_size 1000
@@ -235,6 +250,9 @@ local.media.storage.root media
# 建议使用false
server.multi_endpoint false
## 是否支持PC多端登陆,当server.multi_endpoint为true时,此开关无意义,当为false时,可以单独打开PC端多端登录。
server.multi_pc_endpoint false
# 多平台连接状态通知(仅当multi_endpoint为false时有效),true时移动端可以收到pc或web端登录的通知。
server.multi_platform_notification true
+13
View File
@@ -0,0 +1,13 @@
DROP TABLE IF EXISTS `t_secret_chat`;
CREATE TABLE `t_secret_chat` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`_uid` varchar(64) NOT NULL,
`_from` varchar(64) DEFAULT '',
`_from_cid` varchar(64) DEFAULT '',
`_to` varchar(64) DEFAULT '',
`_to_cid` varchar(64) DEFAULT '',
`_state` tinyint NOT NULL DEFAULT 0,
`_dt` bigint(20) NOT NULL,
UNIQUE INDEX `secret_chat_uid_index` (`_uid` DESC)
);
@@ -0,0 +1 @@
alter table `t_messages` add INDEX `messages_conv_index` ( `_type`, `_target`, `_line`);
@@ -0,0 +1 @@
alter table `t_channel_listener` add INDEX `channel_mid_index` ( `_mid`);
+1
View File
@@ -0,0 +1 @@
alter table `t_channel` add column `_menu` BLOB DEFAULT NULL;
+16
View File
@@ -0,0 +1,16 @@
DROP TABLE IF EXISTS `t_secret_chat`;
CREATE TABLE `t_secret_chat` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`_uid` varchar(64) NOT NULL,
`_from` varchar(64) DEFAULT '',
`_from_cid` varchar(64) DEFAULT '',
`_to` varchar(64) DEFAULT '',
`_to_cid` varchar(64) DEFAULT '',
`_state` tinyint NOT NULL DEFAULT 0,
`_dt` bigint(20) NOT NULL,
UNIQUE INDEX `secret_chat_uid_index` (`_uid` DESC)
)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_bin;
@@ -0,0 +1,37 @@
alter table `t_messages` add INDEX `messages_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_0` add INDEX `messages0_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_1` add INDEX `messages1_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_2` add INDEX `messages2_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_3` add INDEX `messages3_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_4` add INDEX `messages4_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_5` add INDEX `messages5_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_6` add INDEX `messages6_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_7` add INDEX `messages7_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_8` add INDEX `messages8_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_9` add INDEX `messages9_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_10` add INDEX `messages10_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_11` add INDEX `messages11_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_12` add INDEX `messages12_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_13` add INDEX `messages13_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_14` add INDEX `messages14_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_15` add INDEX `messages15_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_16` add INDEX `messages16_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_17` add INDEX `messages17_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_18` add INDEX `messages18_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_19` add INDEX `messages19_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_20` add INDEX `messages20_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_21` add INDEX `messages21_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_22` add INDEX `messages22_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_23` add INDEX `messages23_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_24` add INDEX `messages24_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_25` add INDEX `messages25_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_26` add INDEX `messages26_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_27` add INDEX `messages27_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_28` add INDEX `messages28_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_29` add INDEX `messages29_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_30` add INDEX `messages30_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_31` add INDEX `messages31_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_32` add INDEX `messages32_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_33` add INDEX `messages33_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_34` add INDEX `messages34_conv_index` (`_type`, `_target`, `_line`);
alter table `t_messages_35` add INDEX `messages35_conv_index` (`_type`, `_target`, `_line`);
@@ -0,0 +1 @@
alter table `t_channel_listener` add INDEX `channel_mid_index` (`_mid`);
+1
View File
@@ -0,0 +1 @@
alter table `t_channel` add column `_menu` BLOB DEFAULT NULL;
+5 -5
View File
@@ -5,7 +5,7 @@
<relativePath>../</relativePath>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.80</version>
<version>0.92</version>
</parent>
<artifactId>moquette-broker</artifactId>
@@ -27,18 +27,18 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
<version>2.17.2</version>
</dependency>
<!--用于与slf4j保持桥接-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.17.1</version>
<version>2.17.2</version>
</dependency>
<!-- slf4j核心包-->
<dependency>
@@ -56,7 +56,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
<version>8.0.28</version>
</dependency>
<dependency>
@@ -94,13 +94,9 @@ public class PushServer {
pushMessage.deviceToken = session.getDeviceToken();
pushMessage.unReceivedMsg = badge;
pushMessage.userId = session.getUsername();
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS
|| session.getPlatform() == ProtoConstants.Platform.Platform_Android
|| session.getPlatform() == ProtoConstants.Platform.Platform_iPad
|| session.getPlatform() == ProtoConstants.Platform.Platform_APad) {
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS || session.getPlatform() == ProtoConstants.Platform.Platform_Android) {
String url = androidPushServerUrl;
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS
|| session.getPlatform() == ProtoConstants.Platform.Platform_iPad) {
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS) {
url = iOSPushServerUrl;
pushMessage.voipDeviceToken = session.getVoipDeviceToken();
}
@@ -131,7 +131,8 @@ public class UploadFileAction extends Action {
}
readHttpDataChunkByChunk(response, decoder, requestId, HttpHeaders.isKeepAlive(request));
decoder.destroy();
if (chunk instanceof LastHttpContent) {
}
@@ -34,6 +34,10 @@ abstract public class AdminAction extends Action {
SECRET_KEY = secretKey;
}
public static String getSecretKey() {
return SECRET_KEY;
}
public static void setNoCheckTime(String noCheckTime) {
try {
NO_CHECK_TIME = Boolean.parseBoolean(noCheckTime);
@@ -0,0 +1,58 @@
package com.xiaoleilu.loServer.action.admin;
import cn.wildfirechat.common.APIPath;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.pojos.InputApplicationGetUserInfo;
import cn.wildfirechat.pojos.OutputApplicationUserInfo;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
import com.google.gson.Gson;
import com.hazelcast.util.StringUtil;
import com.xiaoleilu.loServer.RestResult;
import com.xiaoleilu.loServer.annotation.HttpMethod;
import com.xiaoleilu.loServer.annotation.Route;
import com.xiaoleilu.loServer.handler.Request;
import com.xiaoleilu.loServer.handler.Response;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpResponseStatus;
@Route(APIPath.User_Application_Get_UserInfo)
@HttpMethod("POST")
public class ApplicationGetUserInfoAction extends AdminAction {
@Override
public boolean isTransactionAction() {
return true;
}
@Override
public boolean action(Request request, Response response) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
InputApplicationGetUserInfo inputUserToken = getRequestBody(request.getNettyRequest(), InputApplicationGetUserInfo.class);
RestResult result;
if (inputUserToken == null || StringUtil.isNullOrEmpty(inputUserToken.getAuthCode())) {
result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
} else {
String userId = messagesStore.verifyApplicationAuthCode(inputUserToken.getAuthCode(), "admin", ProtoConstants.ApplicationType.ApplicationType_Admin);
if(userId != null) {
OutputApplicationUserInfo outputVerifyApplicationUser = new OutputApplicationUserInfo();
outputVerifyApplicationUser.setUserId(userId);
WFCMessage.User user = messagesStore.getUserInfo(userId);
if(user != null) {
outputVerifyApplicationUser.setDisplayName(user.getDisplayName());
outputVerifyApplicationUser.setPortraitUrl(user.getPortrait());
}
result = RestResult.ok(outputVerifyApplicationUser);
} else {
result = RestResult.resultOf(ErrorCode.ERROR_CODE_TOKEN_ERROR);
}
}
response.setStatus(HttpResponseStatus.OK);
response.setContent(new Gson().toJson(result));
}
return true;
}
}
@@ -0,0 +1,56 @@
/*
* 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.InputMessageUid;
import cn.wildfirechat.pojos.OutputMessageData;
import cn.wildfirechat.pojos.RecallMessageData;
import cn.wildfirechat.proto.WFCMessage;
import com.xiaoleilu.loServer.RestResult;
import com.xiaoleilu.loServer.annotation.HttpMethod;
import com.xiaoleilu.loServer.annotation.Route;
import com.xiaoleilu.loServer.handler.Request;
import com.xiaoleilu.loServer.handler.Response;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.util.internal.StringUtil;
import win.liyufan.im.IMTopic;
@Route(APIPath.Msg_GetOne)
@HttpMethod("POST")
public class GetMessageAction extends AdminAction {
@Override
public boolean isTransactionAction() {
return true;
}
@Override
public boolean action(Request request, Response response) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
InputMessageUid inputMessageUid = getRequestBody(request.getNettyRequest(), InputMessageUid.class);
if (inputMessageUid != null && inputMessageUid.messageUid > 0) {
RestResult result;
WFCMessage.Message msg = messagesStore.getMessage(inputMessageUid.messageUid);
if(msg == null) {
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
} else {
result = RestResult.ok(OutputMessageData.fromProtoMessage(msg));
}
setResponseContent(result, response);
} else {
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
}
}
return true;
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package com.xiaoleilu.loServer.action.admin;
import cn.wildfirechat.common.APIPath;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.pojos.InputGetUserInfo;
import cn.wildfirechat.pojos.InputOutputUserInfo;
import cn.wildfirechat.pojos.InputRobotId;
import cn.wildfirechat.pojos.OutputRobot;
import cn.wildfirechat.proto.WFCMessage;
import com.xiaoleilu.loServer.RestResult;
import com.xiaoleilu.loServer.annotation.HttpMethod;
import com.xiaoleilu.loServer.annotation.Route;
import com.xiaoleilu.loServer.handler.Request;
import com.xiaoleilu.loServer.handler.Response;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.util.internal.StringUtil;
@Route(APIPath.User_Get_Robot_Info)
@HttpMethod("POST")
public class GetRobotAction extends AdminAction {
@Override
public boolean isTransactionAction() {
return true;
}
@Override
public boolean action(Request request, Response response) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
InputRobotId inputUserId = getRequestBody(request.getNettyRequest(), InputRobotId.class);
if (inputUserId != null
&& (!StringUtil.isNullOrEmpty(inputUserId.getRobotId()))) {
WFCMessage.User user = messagesStore.getUserInfo(inputUserId.getRobotId());
WFCMessage.Robot robot = messagesStore.getRobot(inputUserId.getRobotId());
RestResult result;
if (user == null || robot == null) {
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
} else {
OutputRobot outputRobot = new OutputRobot();
outputRobot.fromUser(user);
outputRobot.fromRobot(robot, true);
result = RestResult.ok(outputRobot);
}
setResponseContent(result, response);
} else {
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
}
}
return true;
}
}
@@ -0,0 +1,59 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package com.xiaoleilu.loServer.action.channel;
import cn.wildfirechat.common.APIPath;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.pojos.InputApplicationGetUserInfo;
import cn.wildfirechat.pojos.OutputApplicationUserInfo;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
import com.google.gson.Gson;
import com.xiaoleilu.loServer.RestResult;
import com.xiaoleilu.loServer.annotation.HttpMethod;
import com.xiaoleilu.loServer.annotation.Route;
import com.xiaoleilu.loServer.handler.Request;
import com.xiaoleilu.loServer.handler.Response;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.util.internal.StringUtil;
@Route(APIPath.Channel_Application_Get_UserInfo)
@HttpMethod("POST")
public class ApplicationGetUserInfoAction extends ChannelAction {
@Override
public boolean action(Request request, Response response) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
InputApplicationGetUserInfo inputUserToken = getRequestBody(request.getNettyRequest(), InputApplicationGetUserInfo.class);
RestResult result;
if (inputUserToken == null || StringUtil.isNullOrEmpty(inputUserToken.getAuthCode())) {
result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
} else {
String userId = messagesStore.verifyApplicationAuthCode(inputUserToken.getAuthCode(), channelInfo.getTargetId(), ProtoConstants.ApplicationType.ApplicationType_Channel);
if(userId != null) {
OutputApplicationUserInfo outputVerifyApplicationUser = new OutputApplicationUserInfo();
outputVerifyApplicationUser.setUserId(userId);
WFCMessage.User user = messagesStore.getUserInfo(userId);
if(user != null) {
outputVerifyApplicationUser.setDisplayName(user.getDisplayName());
outputVerifyApplicationUser.setPortraitUrl(user.getPortrait());
}
result = RestResult.ok(outputVerifyApplicationUser);
} else {
result = RestResult.resultOf(ErrorCode.ERROR_CODE_APPLICATION_TOKEN_ERROR_OR_TIMEOUT);
}
}
response.setStatus(HttpResponseStatus.OK);
response.setContent(new Gson().toJson(result));
}
return true;
}
}
@@ -0,0 +1,59 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package com.xiaoleilu.loServer.action.robot;
import cn.wildfirechat.common.APIPath;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.pojos.InputApplicationGetUserInfo;
import cn.wildfirechat.pojos.OutputApplicationUserInfo;
import cn.wildfirechat.proto.ProtoConstants;
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.Robot_Application_Get_UserInfo)
@HttpMethod("POST")
public class ApplicationGetUserInfoAction extends RobotAction {
@Override
public boolean action(Request request, Response response) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
InputApplicationGetUserInfo inputUserToken = getRequestBody(request.getNettyRequest(), InputApplicationGetUserInfo.class);
RestResult result;
if (inputUserToken == null || StringUtil.isNullOrEmpty(inputUserToken.getAuthCode())) {
result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
} else {
String userId = messagesStore.verifyApplicationAuthCode(inputUserToken.getAuthCode(), robot.getUid(), ProtoConstants.ApplicationType.ApplicationType_Robot);
if(userId != null) {
OutputApplicationUserInfo outputVerifyApplicationUser = new OutputApplicationUserInfo();
outputVerifyApplicationUser.setUserId(userId);
WFCMessage.User user = messagesStore.getUserInfo(userId);
if(user != null) {
outputVerifyApplicationUser.setDisplayName(user.getDisplayName());
outputVerifyApplicationUser.setPortraitUrl(user.getPortrait());
}
result = RestResult.ok(outputVerifyApplicationUser);
} else {
result = RestResult.resultOf(ErrorCode.ERROR_CODE_APPLICATION_TOKEN_ERROR_OR_TIMEOUT);
}
}
response.setStatus(HttpResponseStatus.OK);
response.setContent(new Gson().toJson(result));
}
return true;
}
}
@@ -0,0 +1,46 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package com.xiaoleilu.loServer.action.robot;
import cn.wildfirechat.common.APIPath;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.pojos.InputGetUserInfo;
import cn.wildfirechat.pojos.InputOutputUserInfo;
import cn.wildfirechat.pojos.OutputRobot;
import cn.wildfirechat.proto.WFCMessage;
import com.xiaoleilu.loServer.RestResult;
import com.xiaoleilu.loServer.annotation.HttpMethod;
import com.xiaoleilu.loServer.annotation.Route;
import com.xiaoleilu.loServer.handler.Request;
import com.xiaoleilu.loServer.handler.Response;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.util.internal.StringUtil;
@Route(APIPath.Robot_Get_Profile)
@HttpMethod("POST")
public class GetProfileAction extends RobotAction {
@Override
public boolean action(Request request, Response response) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
WFCMessage.User user = messagesStore.getUserInfo(robot.getUid());
RestResult result;
if (user == null) {
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
} else {
OutputRobot outputRobot = new OutputRobot();
outputRobot.fromUser(user);
outputRobot.fromRobot(robot, false);
result = RestResult.ok(outputRobot);
}
setResponseContent(result, response);
}
return true;
}
}
@@ -125,11 +125,13 @@ public final class BrokerConstants {
public static final String SERVER_MULTI_ENDPOINT = "server.multi_endpoint";
public static final String SERVER_MULTI_PC_ENDPOINT = "server.multi_pc_endpoint";
public static final String SERVER_MULTI_PLATFROM_NOTIFICATION = "server.multi_platform_notification";
public static final String SERVER_MOBILE_DEFAULT_SILENT_WHEN_PC_ONLINE = "server.mobile_default_silent_when_pc_online";
public static final String SERVER_CLIENT_SUPPORT_KICKOFF_EVENT = "server.client_support_kickoff_event";
public static final String MESSAGE_ROAMING = "message.roaming";
public static final String MESSAGE_Compensate_Time_Limit = "message.compensate_time_limit";
public static final String MESSAGE_Remote_History_Message = "message.remote_history_message";
public static final String MESSAGE_Remote_Chatroom_History_Message = "message.chatroom_remote_history_message";
@@ -141,6 +143,10 @@ public final class BrokerConstants {
public static final String MESSAGE_NO_Forward_Admin_Message = "message.no_forward_admin_message";
public static final String MESSAGE_Forward_With_Client_Info = "message.forward_with_client_info";
public static final String ROBOT_Callback_With_Client_Info = "robot.callback_with_client_info";
public static final String CHANNEL_Callback_With_Client_Info = "channel.callback_with_client_info";
public static final String FRIEND_Disable_Search = "friend.disable_search";
public static final String FRIEND_Disable_NickName_Search = "friend.disable_nick_name_search";
public static final String FRIEND_Disable_Friend_Request = "friend.disable_friend_request";
@@ -160,6 +166,8 @@ public final class BrokerConstants {
public static final String GROUP_Visible_Quit_Kickoff_Notification = "group.visible_quit_or_kickoff_notification";
public static final String USER_HIDE_PROPERTIES = "user.hide_properties";
public static final String USER_KEEP_DISPLAY_NAME_WHEN_DESTROY = "user.keep_display_name_when_destroy";
public static final String SYNC_Data_Part_Size = "sync.data_part_size";
public static final String MESSAGES_FORBIDDEN_CLIENT_SEND_TYPES = "message.forbidden_client_send_types";
@@ -27,8 +27,6 @@ public class ChannelListenMember extends IMHandler<WFCMessage.ListenChannel> {
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.onApiMessage(fromUser, null, modifyUserSettingReq.toByteArray(), 0, fromUser, PutUserSettingTopic, requestSourceType);
publisher.notifyChannelListenStatusChanged(m_messagesStore.getChannelInfo(request.getChannelId()), fromUser, request.getListen() > 0);
}
return errorCode;
}
@@ -0,0 +1,28 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package io.moquette.imhandler;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
import io.moquette.spi.impl.Qos1PublishHandler;
import io.netty.buffer.ByteBuf;
import win.liyufan.im.IMTopic;
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
@Handler(IMTopic.ApplicationConfigRequestTopic)
public class ConfigApplicationHandler extends IMHandler<WFCMessage.ApplicationConfigRequest> {
@Override
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.ApplicationConfigRequest request, Qos1PublishHandler.IMCallback callback) {
ErrorCode errorCode = m_messagesStore.configApplication(request.getAppId(), request.getAppType(), request.getTimestamp(), request.getNonce(), request.getSignature());
return errorCode;
}
}
@@ -21,6 +21,9 @@ import win.liyufan.im.IMTopic;
public class CreateGroupHandler extends GroupHandler<WFCMessage.CreateGroupRequest> {
@Override
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.CreateGroupRequest request, Qos1PublishHandler.IMCallback callback) {
if(request.getGroup().getGroupInfo().getType() < 0 || request.getGroup().getGroupInfo().getType() > 2) {
return ErrorCode.ERROR_CODE_INVALID_DATA;
}
if (!StringUtil.isNullOrEmpty(request.getGroup().getGroupInfo().getTargetId())) {
WFCMessage.GroupInfo existGroupInfo = m_messagesStore.getGroupInfo(request.getGroup().getGroupInfo().getTargetId());
@@ -19,11 +19,11 @@ import static win.liyufan.im.IMTopic.PutUserSettingTopic;
import static win.liyufan.im.UserSettingScope.kUserSettingMyChannels;
@Handler(value = IMTopic.DestroyChannelInfoTopic)
public class DistroyChannelHandler extends GroupHandler<WFCMessage.IDBuf> {
public class DestroyChannelHandler extends GroupHandler<WFCMessage.IDBuf> {
@Override
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.IDBuf request, Qos1PublishHandler.IMCallback callback) {
boolean isAdmin = requestSourceType == ProtoConstants.RequestSourceType.Request_From_Admin;
ErrorCode errorCode = m_messagesStore.distoryChannel(fromUser, request.getId(), isAdmin);
ErrorCode errorCode = m_messagesStore.destroyChannel(fromUser, request.getId(), isAdmin);
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
WFCMessage.ModifyUserSettingReq modifyUserSettingReq = WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingMyChannels).setKey(request.getId()).setValue("0").build();
mServer.onApiMessage(fromUser, null, modifyUserSettingReq.toByteArray(), 0, fromUser, PutUserSettingTopic, requestSourceType);
@@ -11,9 +11,7 @@ package io.moquette.imhandler;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
import io.moquette.persistence.MemorySessionStore;
import io.moquette.spi.impl.Qos1PublishHandler;
import io.moquette.spi.impl.security.TokenAuthenticator;
import io.netty.buffer.ByteBuf;
import win.liyufan.im.IMTopic;
@@ -30,7 +28,7 @@ public class DestroyUserHandler extends IMHandler<WFCMessage.IDBuf> {
m_messagesStore.clearUserFriend(fromUser);
m_messagesStore.clearUserGroups(fromUser);
m_messagesStore.clearUserChannels(fromUser);
m_messagesStore.destoryUser(fromUser);
m_messagesStore.destroyUser(fromUser);
m_messagesStore.destroyRobot(fromUser);
});
@@ -0,0 +1,33 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package io.moquette.imhandler;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
import io.moquette.spi.impl.Qos1PublishHandler;
import io.netty.buffer.ByteBuf;
import win.liyufan.im.IMTopic;
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
@Handler(IMTopic.GetApplicationTokenRequestTopic)
public class GetApplicationTokenHandler extends IMHandler<WFCMessage.AuthCodeRequest> {
@Override
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.AuthCodeRequest request, Qos1PublishHandler.IMCallback callback) {
String authCode = m_messagesStore.getApplicationAuthCode(fromUser, request.getTargetId(), request.getType(), request.getHost());
if(authCode != null) {
byte[] data = WFCMessage.IDBuf.newBuilder().setId(authCode).build().toByteArray();
ackPayload.ensureWritable(data.length).writeBytes(data);
return ERROR_CODE_SUCCESS;
}
return ErrorCode.INVALID_PARAMETER;
}
}
@@ -28,7 +28,7 @@ public class HandleFriendRequestHandler extends IMHandler<WFCMessage.HandleFrien
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.HandleFriendRequest request, Qos1PublishHandler.IMCallback callback) {
WFCMessage.Message.Builder builder = WFCMessage.Message.newBuilder();
builder.setFromUser(request.getTargetUid());
long[] heads = new long[2];
long[] heads = new long[4];
boolean isAdmin = requestSourceType == ProtoConstants.RequestSourceType.Request_From_Admin;
ErrorCode errorCode = m_messagesStore.handleFriendRequest(fromUser, request, builder, heads, isAdmin);
@@ -84,6 +84,14 @@ public class HandleFriendRequestHandler extends IMHandler<WFCMessage.HandleFrien
publisher.publishNotification(IMTopic.NotifyFriendTopic, request.getTargetUid(), heads[0]);
publisher.publishNotification(IMTopic.NotifyFriendTopic, fromUser, heads[1]);
}
if(!isAdmin) {
if(heads[2] > 0) {
publisher.publishNotification(IMTopic.NotifyFriendRequestTopic, request.getTargetUid(), heads[2], fromUser, null);
}
if(heads[3] > 0) {
publisher.publishNotification(IMTopic.NotifyFriendRequestTopic, fromUser, heads[3], fromUser, null);
}
}
}
if(errorCode == ERROR_CODE_ALREADY_FRIENDS) {
errorCode = ERROR_CODE_SUCCESS;
@@ -166,14 +166,6 @@ abstract public class IMHandler<T> {
public ErrorCode preAction(String clientID, String fromUser, String topic, Qos1PublishHandler.IMCallback callback, ProtoConstants.RequestSourceType requestSourceType) {
LOG.info("imHandler fromUser={}, clientId={}, topic={}", fromUser, clientID, topic);
if(requestSourceType == ProtoConstants.RequestSourceType.Request_From_User && !mLimitCounter.isGranted(clientID + fromUser + topic)) {
ByteBuf ackPayload = Unpooled.buffer();
ackPayload.ensureWritable(1).writeByte(ERROR_CODE_OVER_FREQUENCY.getCode());
try {
callback.onIMHandled(ERROR_CODE_OVER_FREQUENCY, ackPayload);
} catch (Exception e) {
e.printStackTrace();
Utility.printExecption(LOG, e);
}
return ErrorCode.ERROR_CODE_OVER_FREQUENCY;
}
return ErrorCode.ERROR_CODE_SUCCESS;
@@ -34,7 +34,7 @@ public class RecallMessageHandler extends IMHandler<WFCMessage.INT64Buf> {
return ErrorCode.ERROR_CODE_NOT_EXIST;
}
publish(fromUser, clientID, message, requestSourceType);
publish(message.getFromUser(), clientID, message, requestSourceType);
return errorCode;
}
@@ -9,11 +9,13 @@
package io.moquette.imhandler;
import cn.wildfirechat.pojos.MessagePayload;
import cn.wildfirechat.pojos.OutputClient;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
import com.google.gson.Gson;
import com.hazelcast.util.StringUtil;
import io.moquette.BrokerConstants;
import io.moquette.persistence.MemorySessionStore;
import io.moquette.spi.impl.Qos1PublishHandler;
import io.netty.buffer.ByteBuf;
import cn.wildfirechat.common.ErrorCode;
@@ -171,12 +173,20 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
}
message = message.toBuilder().setFromUser(fromUser).setMessageId(messageId).setServerTimestamp(timestamp).build();
OutputClient outputClient = null;
if(m_messagesStore.isForwardMessageWithClientInfo() && requestSourceType == ProtoConstants.RequestSourceType.Request_From_User && !StringUtil.isNullOrEmpty(clientID)) {
MemorySessionStore.Session session = m_sessionsStore.getSession(clientID);
if(session != null && session.getUsername().equals(fromUser)) {
outputClient = new OutputClient(session.getPlatform(), clientID);
}
}
if (!StringUtil.isNullOrEmpty(mForwardUrl) && (mForwardMessageTypes.isEmpty() || mForwardMessageTypes.contains(message.getContent().getType())) && !(isAdmin && mNoForwardAdminMessage)) {
publisher.forwardMessage(message, mForwardUrl);
publisher.forwardMessage(message, mForwardUrl, outputClient);
}
if(!StringUtil.isNullOrEmpty(mMentionForwardUrl) && message.hasContent() && message.getContent().getMentionedType() != 0 && !(isAdmin && mNoForwardAdminMessage)) {
publisher.forwardMessage(message, mMentionForwardUrl);
publisher.forwardMessage(message, mMentionForwardUrl, outputClient);
}
if (!isAdmin) {
@@ -24,7 +24,7 @@ public class UploadDeviceTokenHandler extends IMHandler<WFCMessage.UploadDeviceT
MemorySessionStore.Session session = m_sessionsStore.getSession(clientID);
session.setPlatform(request.getPlatform());
session.setAppName(request.getAppName());
if ((request.getPlatform() == ProtoConstants.Platform.Platform_iOS || request.getPlatform() == ProtoConstants.Platform.Platform_iPad) && request.getPushType() == 2) {
if (request.getPlatform() == ProtoConstants.Platform.Platform_iOS && request.getPushType() == 2) {
session.setVoipDeviceToken(request.getDeviceToken());
m_sessionsStore.updateSessionToken(session, true);
} else {
@@ -553,7 +553,7 @@ public class DatabaseStore {
statement.setInt(index++, message.getContent().getType());
String to = message.getToUser();
if (StringUtil.isNullOrEmpty(message.getToUser())) {
if (message.getToList()!= null && message.getToList().size() == 1) {
if (message.getToList().size() > 0) {
to = message.getToList().get(0);
}
}
@@ -914,20 +914,24 @@ public class DatabaseStore {
return false;
}
void persistUserMessage(final String userId, final long messageId, final long messageSeq, final int messageContentType) {
void persistUserMessage(final String userId, final long messageId, final long messageSeq, int type, String target, int line, boolean directing, final int messageContentType) {
mScheduler.execute(()->{
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "insert into " + getUserMessageTable(userId) + " (`_mid`, `_uid`, `_seq`, `_cont_type`) values(?, ?, ?, ?)";
String sql = "insert into " + getUserMessageTable(userId) + " (`_mid`, `_uid`, `_seq`, `_type`, `_target`, `_line`, `_directing`, `_cont_type`) values(?, ?, ?, ?, ?, ?, ?, ?)";
statement = connection.prepareStatement(sql);
int index = 1;
statement.setLong(index++, messageId);
statement.setString(index++, userId);
statement.setLong(index++, messageSeq);
statement.setInt(index++, type);
statement.setString(index++, target);
statement.setInt(index++, line);
statement.setInt(index++, directing ? 1 :0);
statement.setInt(index++, messageContentType);
int count = statement.executeUpdate();
LOG.info("Update rows {}", count);
@@ -990,7 +994,7 @@ public class DatabaseStore {
}
sb.append(")");
sb.append(" and _scope = 6 and _key = ?");
sb.append(" and _scope in (5,6,26) and _key = ?");
statement = connection.prepareStatement(sb.toString());
int index = 1;
@@ -1138,23 +1142,21 @@ public class DatabaseStore {
try {
connection = DBUtil.getConnection();
StringBuilder sb = new StringBuilder("delete from t_user_setting where _scope in (1,3,5,7) and _uid in (");
StringBuilder sb = new StringBuilder("delete from t_user_setting where _scope in (1,3,5,6,7,19) and _uid in (");
for (int i = 0; i < users.size(); i++) {
sb.append("?");
if (i != users.size() - 1) {
sb.append(",");
}
}
sb.append(") and _key like '1-_-");
sb.append(groupId);
sb.append("'");
sb.append(") and _key like ?");
statement = connection.prepareStatement(sb.toString());
int index = 1;
for (String userId:users) {
statement.setString(index++, userId);
}
statement.setString(index++, "1-_-" + groupId);
int count = statement.executeUpdate();
LOG.info("Update rows {}", count);
@@ -1573,8 +1575,6 @@ public class DatabaseStore {
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and (`_platform` = ? or `_platform` = ? or `_platform` = ?) and `_cid` <> ? and `_deleted` = 0";
} else if(platform == ProtoConstants.Platform.Platform_iOS || platform == ProtoConstants.Platform.Platform_Android) {
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and (`_platform` = ? or `_platform` = ?) and `_cid` <> ? and `_deleted` = 0";
} else if(platform == ProtoConstants.Platform.Platform_iPad || platform == ProtoConstants.Platform.Platform_APad) {
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and (`_platform` = ? or `_platform` = ?) and `_cid` <> ? and `_deleted` = 0";
} else {
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and `_platform` = ? and `_cid` <> ? and `_deleted` = 0";
}
@@ -1596,9 +1596,6 @@ public class DatabaseStore {
} else if(platform == ProtoConstants.Platform.Platform_iOS || platform == ProtoConstants.Platform.Platform_Android) {
statement.setInt(index++, ProtoConstants.Platform.Platform_iOS);
statement.setInt(index++, ProtoConstants.Platform.Platform_Android);
} else if(platform == ProtoConstants.Platform.Platform_iPad || platform == ProtoConstants.Platform.Platform_APad) {
statement.setInt(index++, ProtoConstants.Platform.Platform_iPad);
statement.setInt(index++, ProtoConstants.Platform.Platform_APad);
} else {
statement.setInt(index++, platform);
}
@@ -2975,7 +2972,8 @@ public class DatabaseStore {
", `_secret`" +
", `_callback`" +
", `_automatic`" +
", `_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
", `_menu`" +
", `_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
" ON DUPLICATE KEY UPDATE `_name`=?" +
", `_portrait`=?" +
", `_owner`=?" +
@@ -2985,12 +2983,20 @@ public class DatabaseStore {
", `_secret`=?" +
", `_callback`=?" +
", `_automatic`=?" +
", `_menu`=?" +
", `_dt`=?";
statement = connection.prepareStatement(sql);
int index = 1;
WFCMessage.ChannelMenuList.Builder builder = WFCMessage.ChannelMenuList.newBuilder();
if (!channelInfo.getMenuList().isEmpty()) {
for (WFCMessage.ChannelMenu menuBtn:channelInfo.getMenuList()) {
builder.addMenu(menuBtn);
}
}
byte[] menuBytes = builder.build().toByteArray();
int index = 1;
statement.setString(index++, channelInfo.getTargetId());
statement.setString(index++, channelInfo.getName());
statement.setString(index++, channelInfo.getPortrait());
@@ -3001,6 +3007,7 @@ public class DatabaseStore {
statement.setString(index++, channelInfo.getSecret());
statement.setString(index++, channelInfo.getCallback());
statement.setInt(index++, channelInfo.getAutomatic());
statement.setBytes(index++, menuBytes);
statement.setLong(index++, channelInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : channelInfo.getUpdateDt());
statement.setString(index++, channelInfo.getName());
@@ -3012,6 +3019,7 @@ public class DatabaseStore {
statement.setString(index++, channelInfo.getSecret());
statement.setString(index++, channelInfo.getCallback());
statement.setInt(index++, channelInfo.getAutomatic());
statement.setBytes(index++, menuBytes);
statement.setLong(index++, channelInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : channelInfo.getUpdateDt());
int count = statement.executeUpdate();
@@ -3064,6 +3072,7 @@ public class DatabaseStore {
", `_secret`" +
", `_callback`" +
", `_automatic`" +
", `_menu`" +
", `_dt` from t_channel where `_cid` = ?";
statement = connection.prepareStatement(sql);
@@ -3114,6 +3123,21 @@ public class DatabaseStore {
intValue = rs.getInt(index++);
builder.setAutomatic(intValue);
try {
byte[] bytes = null;
Blob blob = rs.getBlob(index++);
if (blob != null) {
bytes = toByteArray(blob.getBinaryStream());
}
WFCMessage.ChannelMenuList menuButtonList = WFCMessage.ChannelMenuList.parseFrom(bytes);
if (menuButtonList.getMenuCount() > 0) {
builder.addAllMenu(menuButtonList.getMenuList());
}
} catch (IOException e) {
e.printStackTrace();
}
long longValue = rs.getLong(index++);
builder.setUpdateDt(longValue);
@@ -3335,6 +3359,57 @@ public class DatabaseStore {
});
}
List<String> getUserChannels(String userId) {
List<String> out = new ArrayList<>();
Connection connection = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "select _cid from t_channel_listener where _mid = ?";
statement = connection.prepareStatement(sql);
int index = 1;
statement.setString(index++, userId);
rs = statement.executeQuery();
while (rs.next()) {
String value = rs.getString(1);
if (!StringUtil.isNullOrEmpty(value)) {
out.add(value);
}
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Utility.printExecption(LOG, e, RDBS_Exception);
} finally {
DBUtil.closeDB(connection, statement, rs);
}
return out;
}
void clearChannelListener(final String channelId) {
LOG.info("Database remove channel {}", channelId);
Connection connection = null;
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "delete from t_channel_listener where _cid=?";
statement = connection.prepareStatement(sql);
statement.setString(1, channelId);
int count = statement.executeUpdate();
LOG.info("Update rows {}", count);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Utility.printExecption(LOG, e, RDBS_Exception);
} finally {
DBUtil.closeDB(connection, statement);
}
}
public Set<String> getSensitiveWord() {
Connection connection = null;
PreparedStatement statement = null;
@@ -23,6 +23,7 @@ import com.google.gson.Gson;
import com.google.protobuf.ByteString;
import com.hazelcast.core.*;
import com.hazelcast.util.StringUtil;
import com.xiaoleilu.loServer.action.admin.AdminAction;
import com.xiaoleilu.loServer.model.FriendData;
import cn.wildfirechat.common.ErrorCode;
import io.moquette.BrokerConstants;
@@ -31,14 +32,18 @@ import io.moquette.server.Constants;
import io.moquette.server.Server;
import io.moquette.spi.IMatchingCondition;
import io.moquette.spi.IMessagesStore;
import io.moquette.spi.impl.security.AES;
import io.moquette.spi.security.Tokenor;
import io.moquette.spi.impl.subscriptions.Topic;
import io.netty.handler.codec.mqtt.MqttVersion;
import org.apache.commons.codec.digest.DigestUtils;
import org.json.simple.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import win.liyufan.im.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
@@ -91,6 +96,7 @@ public class MemoryMessagesStore implements IMessagesStore {
private static final String CHANNEL_LISTENERS = "channel_listeners";
private static boolean IS_MESSAGE_ROAMING = true;
private static long msgCompensateTimeLimit = 300000;
private static boolean IS_MESSAGE_REMOTE_HISTORY_MESSAGE = true;
private static boolean IS_CHATROOM_MESSAGE_REMOTE_HISTORY_MESSAGE = true;
@@ -160,6 +166,11 @@ public class MemoryMessagesStore implements IMessagesStore {
private boolean mGroupAllowRobotCustomOperationNotification;
private int mGroupVisibleQuitKickoffNotification;
private int mSyncDataPartSize = 0;
private boolean keepDisplayNameWhenDestroyUser = true;
private boolean mForwardMessageWithClientInfo = false;
private boolean mRobotCallbackWithClientInfo = false;
private boolean mChannelCallbackWithClientInfo = false;
private Set<Integer> mUserHideProperties = new HashSet<>();
@@ -168,6 +179,11 @@ public class MemoryMessagesStore implements IMessagesStore {
this.databaseStore = databaseStore;
IS_MESSAGE_ROAMING = "1".equals(m_Server.getConfig().getProperty(MESSAGE_ROAMING));
try {
msgCompensateTimeLimit = Long.parseLong(m_Server.getConfig().getProperty(MESSAGE_Compensate_Time_Limit, "300000"));
} catch (NumberFormatException e) {
}
IS_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_History_Message));
IS_CHATROOM_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_Chatroom_History_Message, "1"));
Constants.MAX_MESSAGE_QUEUE = Integer.parseInt(m_Server.getConfig().getProperty(MESSAGE_Max_Queue));
@@ -418,6 +434,11 @@ public class MemoryMessagesStore implements IMessagesStore {
mSyncDataPartSize = Integer.parseInt(server.getConfig().getProperty(SYNC_Data_Part_Size, "0"));
} catch (Exception e) {
}
try {
keepDisplayNameWhenDestroyUser = Boolean.parseBoolean(server.getConfig().getProperty(USER_KEEP_DISPLAY_NAME_WHEN_DESTROY, "true"));
} catch (Exception e) {
}
@@ -436,6 +457,21 @@ public class MemoryMessagesStore implements IMessagesStore {
e.printStackTrace();
}
try {
mForwardMessageWithClientInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_With_Client_Info, "false"));
} catch (Exception e) {
}
try {
mRobotCallbackWithClientInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.ROBOT_Callback_With_Client_Info, "false"));
} catch (Exception e) {
}
try {
mChannelCallbackWithClientInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.CHANNEL_Callback_With_Client_Info, "false"));
} catch (Exception e) {
}
}
@@ -558,8 +594,7 @@ public class MemoryMessagesStore implements IMessagesStore {
if (channelInfo != null) {
if (channelInfo.getOwner().equals(fromUser)) {
if(requestSourceType == ProtoConstants.RequestSourceType.Request_From_Channel
&& !StringUtil.isNullOrEmpty(channelInfo.getCallback())
&& channelInfo.getAutomatic() == 1) {
&& channelInfo.getAutomatic() != 0) {
LOG.info("Channel api message not send to the owner when automatic");
} else {
notifyReceivers.add(fromUser);
@@ -589,8 +624,10 @@ public class MemoryMessagesStore implements IMessagesStore {
}
} else {
notifyReceivers.add(fromUser);
if (StringUtil.isNullOrEmpty(channelInfo.getCallback()) || channelInfo.getAutomatic() == 0) {
if (channelInfo.getAutomatic() == 0) {
notifyReceivers.add(channelInfo.getOwner());
} else {
LOG.info("Channel api message not send to the owner when automatic");
}
}
} else {
@@ -708,7 +745,7 @@ public class MemoryMessagesStore implements IMessagesStore {
}
}
if (noRoaming && (System.currentTimeMillis() - bundle.getMessage().getServerTimestamp() > 5 * 60 * 1000)) {
if (noRoaming && (System.currentTimeMillis() - bundle.getMessage().getServerTimestamp() > msgCompensateTimeLimit)) {
continue;
}
@@ -866,7 +903,7 @@ public class MemoryMessagesStore implements IMessagesStore {
}
@Override
public long insertUserMessages(String sender, int conversationType, String target, int line, int messageContentType, String user, long messageId) {
public long insertUserMessages(String sender, int conversationType, String target, int line, int messageContentType, String user, long messageId, boolean directing) {
// messageId是全局的,messageSeq是跟个人相关的,理论上messageId的增长数度远远大于seq。
// 考虑到一种情况,当服务器发生变化,用户发生迁移后,messageSeq还需要保持有序。 要么把Seq持久化,要么在迁移后Seq取一个肯定比以前更大的数字(这个数字就是messageId)
// 这里选择使用后面一种情况
@@ -906,7 +943,7 @@ public class MemoryMessagesStore implements IMessagesStore {
mWriteLock.unlock();
}
databaseStore.persistUserMessage(user, messageId, messageSeq, messageContentType);
databaseStore.persistUserMessage(user, messageId, messageSeq, conversationType, target, line, directing, messageContentType);
return messageSeq;
}
@@ -1269,11 +1306,31 @@ public class MemoryMessagesStore implements IMessagesStore {
}
}
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
Collection<WFCMessage.GroupMember> members = groupMembers.get(groupId);
if (members == null || members.size() == 0) {
members = loadGroupMemberFromDB(hzInstance, groupId);
}
ArrayList<String> existMemberIds = new ArrayList<>();
for (WFCMessage.GroupMember member : members) {
if (member.getType() != GroupMemberType_Removed) {
existMemberIds.add(member.getMemberId());
}
}
long updateDt = System.currentTimeMillis();
List<WFCMessage.GroupMember> tmp = new ArrayList<>();
ArrayList<String> newInviteUsers = new ArrayList<>();
int newMemberCount = 0;
for (WFCMessage.GroupMember member : memberList) {
if (existMemberIds.contains(member.getMemberId()) && member.getType() != GroupMemberType_Removed) {
if(!isAdmin)
continue;
} else {
newMemberCount++;
}
WFCMessage.GroupMember.Builder builder = member.toBuilder();
builder.setUpdateDt(updateDt).setCreateDt(updateDt);
if (member.getMemberId().equals(groupInfo.getOwner())) {
@@ -1293,29 +1350,23 @@ public class MemoryMessagesStore implements IMessagesStore {
}
member = builder.build();
tmp.add(member);
newInviteUsers.add(member.getMemberId());
updateDt++;
}
memberList = tmp;
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
Collection<WFCMessage.GroupMember> members = groupMembers.get(groupId);
if (members == null || members.size() == 0) {
members = loadGroupMemberFromDB(hzInstance, groupId);
}
if (maxCount != Integer.MAX_VALUE) {
int existCount = 0;
for (WFCMessage.GroupMember member : members) {
if (member.getType() != GroupMemberType_Removed) {
existCount++;
}
if (memberList.size() == 0) {
if (!isAdmin) {
return ErrorCode.ERROR_CODE_ALREADY_IN_GROUP;
} else {
return ErrorCode.ERROR_CODE_SUCCESS;
}
if (existCount + newInviteUsers.size() > maxCount) {
} else {
if (existMemberIds.size() + newMemberCount > maxCount) {
return ErrorCode.ERROR_CODE_GROUP_EXCEED_MAX_MEMBER_COUNT;
}
}
databaseStore.persistGroupMember(groupId, memberList, true);
databaseStore.updateGroupMemberCountDt(groupId);
@@ -2077,6 +2128,10 @@ public class MemoryMessagesStore implements IMessagesStore {
if (!canRecall) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
if(message.getContent().getType() == 80) {
return ErrorCode.ERROR_CODE_SUCCESS;
}
JSONObject json = new JSONObject();
json.put("s", message.getFromUser());
@@ -2313,6 +2368,24 @@ public class MemoryMessagesStore implements IMessagesStore {
}
public void forceCleanOnlineStatus(String userId, String clientId) {
if (m_Server.isShutdowning()) {
return;
}
if(!mMultiPlatformNotification || m_Server.getStore().sessionsStore().isMultiEndpointSupported()) {
WFCMessage.UserSettingEntry pcentry = getUserSetting(userId, kUserSettingPCOnline, "PC");
if (pcentry != null && !StringUtil.isNullOrEmpty(pcentry.getValue()) && pcentry.getValue().contains(clientId)) {
updateUserSettings(userId, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue("").build(), clientId);
}
WFCMessage.UserSettingEntry padentry = getUserSetting(userId, kUserSettingPCOnline, "Pad");
if (padentry != null && !StringUtil.isNullOrEmpty(padentry.getValue()) && padentry.getValue().contains(clientId)) {
updateUserSettings(userId, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("Pad").setValue("").build(), clientId);
}
}
}
@Override
public void updateUserOnlineSetting(MemorySessionStore.Session session, boolean online) {
if(!mMultiPlatformNotification) {
@@ -2327,7 +2400,6 @@ public class MemoryMessagesStore implements IMessagesStore {
}
String pcValue = null;
String padValue = null;
for (MemorySessionStore.Session s : m_Server.getStore().sessionsStore().sessionForUser(session.username)) {
if (s.getDeleted() != 0 || !m_Server.getConnectionsManager().isConnected(s.getClientID())) {
continue;
@@ -2339,10 +2411,6 @@ public class MemoryMessagesStore implements IMessagesStore {
case Platform_OSX:
pcValue = System.currentTimeMillis() + "|" + s.getPlatform() + "|" + s.getClientID() + "|" + s.getPhoneName();
break;
case Platform_iPad:
case Platform_APad:
padValue = System.currentTimeMillis() + "|" + s.getPlatform() + "|" + s.getClientID() + "|" + s.getPhoneName();
break;
default:
break;
}
@@ -2358,17 +2426,6 @@ public class MemoryMessagesStore implements IMessagesStore {
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue("").build(), session.clientID);
}
}
WFCMessage.UserSettingEntry padentry = getUserSetting(session.getUsername(), kUserSettingPCOnline, "Pad");
if (padValue != null) {
if (padentry == null || StringUtil.isNullOrEmpty(padentry.getValue())) {
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("Pad").setValue(padValue).build(), session.clientID);
}
} else {
if (padentry != null && !StringUtil.isNullOrEmpty(padentry.getValue())) {
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("Pad").setValue("").build(), session.clientID);
}
}
}
@Override
@@ -2481,12 +2538,42 @@ public class MemoryMessagesStore implements IMessagesStore {
}
@Override
public void destoryUser(String userId) {
public void destroyUser(String userId) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
IMap<String, WFCMessage.User> mUserMap = hzInstance.getMap(USERS);
WFCMessage.User us = mUserMap.get(userId);
if (us != null) {
us = WFCMessage.User.newBuilder().setUid(userId).setUpdateDt(System.currentTimeMillis()).setDisplayName("").setName(userId).setDeleted(1).build();
if (keepDisplayNameWhenDestroyUser) {
us = WFCMessage.User.newBuilder()
.setUid(userId)
.setUpdateDt(System.currentTimeMillis())
.setName(userId)
.setDeleted(1)
.clearAddress()
.clearCompany()
.clearEmail()
.clearExtra()
.clearMobile()
.clearPortrait()
.clearSocial()
.build();
} else {
us = WFCMessage.User.newBuilder()
.setUid(userId)
.setUpdateDt(System.currentTimeMillis())
.setName(userId)
.setDeleted(1)
.clearDisplayName()
.clearAddress()
.clearCompany()
.clearEmail()
.clearExtra()
.clearMobile()
.clearPortrait()
.clearSocial()
.build();
}
try {
databaseStore.updateUser(us);
} catch (Exception e) {
@@ -3017,6 +3104,8 @@ public class MemoryMessagesStore implements IMessagesStore {
return ErrorCode.ERROR_CODE_FRIEND_REQUEST_EXPIRED;
} else {
existRequest = existRequest.toBuilder().setStatus(request.getStatus()).setUpdateDt(System.currentTimeMillis()).build();
heads[2] = existRequest.getUpdateDt();
heads[3] = existRequest.getUpdateDt();
databaseStore.persistOrUpdateFriendRequest(existRequest);
if (request.getStatus() == ProtoConstants.FriendRequestStatus.RequestStatus_Accepted) {
@@ -3257,6 +3346,156 @@ public class MemoryMessagesStore implements IMessagesStore {
return true;
}
private String ensureSecretLength(String secret) {
while ( secret.length() < 16) {
secret += "w";
secret += secret;
}
return secret;
}
@Override
public String getApplicationAuthCode(String fromUser, String applicationId, int type, String host) {
String secret = null;
if(type == ProtoConstants.ApplicationType.ApplicationType_Robot) {
WFCMessage.Robot robotData = getRobot(applicationId);
if(robotData != null && !StringUtil.isNullOrEmpty(robotData.getCallback()) && !StringUtil.isNullOrEmpty(robotData.getSecret())) {
try {
URL url = new URL(robotData.getCallback());
if(url.getHost().equals(host)) {
secret = robotData.getSecret();
} else {
LOG.warn("get application auth code error, request host is not the same host with callback host");
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
} else {
String errorReason;
if(robotData == null) {
errorReason = "Robot not exist.";
} else if(StringUtil.isNullOrEmpty(robotData.getCallback())) {
errorReason = "Robot no callback address";
} else {
errorReason = "Robot no secret";
}
LOG.warn("get application auth code error, reason {}", errorReason);
}
} else if(type == ProtoConstants.ApplicationType.ApplicationType_Channel) {
WFCMessage.ChannelInfo channelData = getChannelInfo(applicationId);
if(channelData != null && !StringUtil.isNullOrEmpty(channelData.getCallback()) && !StringUtil.isNullOrEmpty(channelData.getSecret())) {
try {
URL url = new URL(channelData.getCallback());
if(url.getHost().equals(host)) {
secret = channelData.getSecret();
} else {
LOG.warn("get application auth code error, request host is not the same host with callback host");
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
} else {
String errorReason;
if(channelData == null) {
errorReason = "Channel not exist.";
} else if(StringUtil.isNullOrEmpty(channelData.getCallback())) {
errorReason = "Channel no callback address";
} else {
errorReason = "Channel no secret";
}
LOG.warn("get application auth code error, reason {}", errorReason);
}
} else if(type == ProtoConstants.ApplicationType.ApplicationType_Admin) {
secret = AdminAction.getSecretKey();
applicationId = "wfadmin";
}
if(!StringUtil.isNullOrEmpty(secret)) {
secret = ensureSecretLength(secret);
byte[] token = AES.AESEncrypt(fromUser + "?|?" + System.currentTimeMillis() + "?|?" + applicationId + "?|?" + type, secret);
return new String(Base64.getEncoder().encode(token));
}
return null;
}
@Override
public String verifyApplicationAuthCode(String authCode, String applicationId, int type) {
String secret = null;
if(type == ProtoConstants.ApplicationType.ApplicationType_Robot) {
WFCMessage.Robot robotData = getRobot(applicationId);
if(robotData != null && !StringUtil.isNullOrEmpty(robotData.getCallback()) && !StringUtil.isNullOrEmpty(robotData.getSecret())) {
secret = robotData.getSecret();
}
} else if(type == ProtoConstants.ApplicationType.ApplicationType_Channel) {
WFCMessage.ChannelInfo channelData = getChannelInfo(applicationId);
if(channelData != null && !StringUtil.isNullOrEmpty(channelData.getCallback()) && !StringUtil.isNullOrEmpty(channelData.getSecret())) {
secret = channelData.getSecret();
}
} else if(type == ProtoConstants.ApplicationType.ApplicationType_Admin) {
secret = AdminAction.getSecretKey();
applicationId = "wfadmin";
}
secret = ensureSecretLength(secret);
byte[] data = Base64.getDecoder().decode(authCode);
data = AES.AESDecrypt(data, secret, true);
if (data == null || data.length == 0) {
return null;
} else {
String str = new String(data);
String[] strArr = str.split("\\?\\|\\?");
if (strArr.length == 4) {
if (applicationId.equals(strArr[2])) {
long timestamp= Long.parseLong(strArr[1]);
if(System.currentTimeMillis() - timestamp > 60*1000) {
return null;
}
return strArr[0];
}
}
}
return null;
}
@Override
public ErrorCode configApplication(String appId, int appType, long timestamp, String nonce, String signature) {
String secret;
if(System.currentTimeMillis()/1000 - timestamp > 300) {
return ErrorCode.ERROR_CODE_SIGN_EXPIRED;
}
if(appType == ProtoConstants.ApplicationType.ApplicationType_Robot) {
WFCMessage.Robot robotData = getRobot(appId);
if(robotData != null) {
secret = robotData.getSecret();
} else {
return ErrorCode.ERROR_CODE_NOT_EXIST;
}
} else if(appType == ProtoConstants.ApplicationType.ApplicationType_Channel) {
WFCMessage.ChannelInfo channelData = getChannelInfo(appId);
if(channelData != null) {
secret = channelData.getSecret();
} else {
return ErrorCode.ERROR_CODE_NOT_EXIST;
}
} else {
LOG.error("Config application type only support 0 or 1");
return ErrorCode.INVALID_PARAMETER;
}
String str = nonce + "|" + appId + "|" + timestamp + "|" + secret;
String sign = DigestUtils.sha1Hex(str);
if(sign.equals(signature)) {
return ErrorCode.ERROR_CODE_SUCCESS;
}
return ErrorCode.ERROR_CODE_AUTH_FAILURE;
}
@Override
public boolean isNewFriendWelcomeMessage() {
return mFriendNewWelcomeMessage;
@@ -3607,7 +3846,7 @@ public class MemoryMessagesStore implements IMessagesStore {
@Override
public void clearUserChannels(String userId) {
databaseStore.getUserChannels(userId).forEach(s -> listenChannel(userId, s, false));
}
@@ -3649,9 +3888,15 @@ public class MemoryMessagesStore implements IMessagesStore {
e.printStackTrace();
Utility.printExecption(LOG, e);
}
} else if(modifyType == Modify_Channel_Menu) {
OutputGetChannelInfo.OutputMenuList outputMenuButtons = new Gson().fromJson(value, OutputGetChannelInfo.OutputMenuList.class);
if (!outputMenuButtons.isEmpty()) {
for (OutputGetChannelInfo.OutputMenu outputMenuButton : outputMenuButtons) {
newInfoBuilder.addMenu(outputMenuButton.toPbInfo());
}
}
}
newInfoBuilder.setUpdateDt(System.currentTimeMillis());
mIMap.put(channelId, newInfoBuilder.build());
callbackChannelInfoUpdateEvent(operator, channelId, Channel_Event_Update);
@@ -3687,7 +3932,7 @@ public class MemoryMessagesStore implements IMessagesStore {
}
@Override
public ErrorCode distoryChannel(String operator, String channelId, boolean isAdmin) {
public ErrorCode destroyChannel(String operator, String channelId, boolean isAdmin) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
IMap<String, WFCMessage.ChannelInfo> mIMap = hzInstance.getMap(CHANNELS);
@@ -3707,6 +3952,8 @@ public class MemoryMessagesStore implements IMessagesStore {
newInfoBuilder.setStatus(oldInfo.getStatus() | Channel_State_Mask_Deleted);
newInfoBuilder.setUpdateDt(System.currentTimeMillis());
mIMap.put(channelId, newInfoBuilder.build());
databaseStore.clearChannelListener(channelId);
hzInstance.getMultiMap(CHANNEL_LISTENERS).remove(channelId);
callbackChannelInfoUpdateEvent(operator, channelId, Channel_Event_Destroy);
return ErrorCode.ERROR_CODE_SUCCESS;
@@ -3724,18 +3971,18 @@ public class MemoryMessagesStore implements IMessagesStore {
IMap<String, WFCMessage.ChannelInfo> mIMap = hzInstance.getMap(CHANNELS);
WFCMessage.ChannelInfo channelInfo = mIMap.get(channelId);
if(channelInfo != null && (channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Private) > 0) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
return ErrorCode.ERROR_CODE_NOT_EXIST;
}
getChannelListener(channelId);
if (listen) {
listeners.put(channelId, operator);
} else {
listeners.remove(channelId, operator);
try {
mWriteLock.lock();
databaseStore.updateChannelListener(channelId, operator, listen);
listeners.remove(channelId);
} finally {
mWriteLock.unlock();
}
databaseStore.updateChannelListener(channelId, operator, listen);
IMHandler.getPublisher().notifyChannelListenStatusChanged(channelInfo, operator, listen);
return ErrorCode.ERROR_CODE_SUCCESS;
}
@@ -3744,9 +3991,14 @@ public class MemoryMessagesStore implements IMessagesStore {
MultiMap<String, String> listeners = hzInstance.getMultiMap(CHANNEL_LISTENERS);
Collection<String> result = listeners.get(channelId);
if (result.isEmpty()) {
result = databaseStore.getChannelListener(channelId);
for (String userId : result) {
listeners.put(channelId, userId);
try {
mWriteLock.lock();
result = databaseStore.getChannelListener(channelId);
for (String userId : result) {
listeners.put(channelId, userId);
}
} finally {
mWriteLock.unlock();
}
}
return result;
@@ -3775,12 +4027,7 @@ public class MemoryMessagesStore implements IMessagesStore {
}
Collection<String> channelMembers = getChannelListener(channelId);
if (channelMembers == null) {
return false;
}
Collection<String> chatroomMembers = getChannelListener(channelId);
if (chatroomMembers == null || !chatroomMembers.contains(user)) {
if (channelMembers == null || !channelMembers.contains(user)) {
return false;
}
@@ -3806,12 +4053,7 @@ public class MemoryMessagesStore implements IMessagesStore {
@Override
public Collection<String> getChannelSubscriber(String channelId) {
MultiMap<String, String> channelMembers = m_Server.getHazelcastInstance().getMultiMap(CHANNEL_LISTENERS);
if (channelMembers == null) {
return new ArrayList<>();
}
return channelMembers.get(channelId);
return getChannelListener(channelId);
}
@Override
@@ -3871,6 +4113,20 @@ public class MemoryMessagesStore implements IMessagesStore {
return mGroupVisibleQuitKickoffNotification;
}
@Override
public boolean isForwardMessageWithClientInfo() {
return mForwardMessageWithClientInfo;
}
@Override
public boolean isRobotCallbackWithClientInfo() {
return mRobotCallbackWithClientInfo;
}
@Override
public boolean isChannelCallbackWithClientInfo() {
return mChannelCallbackWithClientInfo;
}
@Override
public List<Integer> getClientForbiddenSendTypes() {
@@ -39,6 +39,7 @@ public class MemorySessionStore implements ISessionsStore {
private static final Logger LOG = LoggerFactory.getLogger(MemorySessionStore.class);
private boolean supportMultiEndpoint = false;
private boolean supportMultiPCEndpoint = false;
private boolean clientSupportKickoff = false;
public static class Session implements Comparable<Session>{
@@ -287,6 +288,11 @@ public class MemorySessionStore implements ISessionsStore {
Utility.printExecption(LOG, e);
}
try {
supportMultiPCEndpoint = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_MULTI_PC_ENDPOINT, "false"));
} catch (Exception e) {
}
try {
clientSupportKickoff = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_CLIENT_SUPPORT_KICKOFF_EVENT, "false"));
} catch (Exception e) {
@@ -385,7 +391,12 @@ public class MemorySessionStore implements ISessionsStore {
}
databaseStore.clearMultiUser(username, clientID);
if (!supportMultiEndpoint && platform > 0) {
if (!supportMultiEndpoint
&& platform > 0
&& !(platform == ProtoConstants.Platform.Platform_Windows && supportMultiPCEndpoint)
&& !(platform == ProtoConstants.Platform.Platform_LINUX && supportMultiPCEndpoint)
&& !(platform == ProtoConstants.Platform.Platform_OSX && supportMultiPCEndpoint)
) {
databaseStore.clearMultiEndpoint(username, clientID, platform);
if (userSessions.get(username) != null) {
Iterator<String> it = userSessions.get(username).iterator();
@@ -407,10 +418,6 @@ public class MemorySessionStore implements ISessionsStore {
if (s.getPlatform() == ProtoConstants.Platform.Platform_OSX || s.getPlatform() == ProtoConstants.Platform.Platform_Windows || platform == ProtoConstants.Platform.Platform_LINUX) {
remove = true;
}
} else if(platform == ProtoConstants.Platform.Platform_iPad || platform == ProtoConstants.Platform.Platform_APad) {
if (s.getPlatform() == ProtoConstants.Platform.Platform_iPad || s.getPlatform() == ProtoConstants.Platform.Platform_APad) {
remove = true;
}
} else {
if (s.getPlatform() ==platform) {
remove = true;
@@ -729,14 +736,13 @@ public class MemorySessionStore implements ISessionsStore {
if (session != null) {
if(!operator.equals(session.getUsername())) {
LOG.error("kickoffPCClient failure, user {} don't have client {}", operator, pcClientId);
return ErrorCode.ERROR_CODE_NOT_RIGHT;
mServer.getProcessor().getMessagesStore().forceCleanOnlineStatus(operator, pcClientId);
return ErrorCode.ERROR_CODE_SUCCESS;
}
if (session.getPlatform() == ProtoConstants.Platform.Platform_LINUX
|| session.getPlatform() == ProtoConstants.Platform.Platform_WEB
|| session.getPlatform() == ProtoConstants.Platform.Platform_Windows
|| session.getPlatform() == ProtoConstants.Platform.Platform_OSX
|| session.getPlatform() == ProtoConstants.Platform.Platform_iPad
|| session.getPlatform() == ProtoConstants.Platform.Platform_APad
) {
|| session.getPlatform() == ProtoConstants.Platform.Platform_OSX) {
databaseStore.updateSessionDeleted(operator, pcClientId, 1);
sessions.remove(pcClientId);
mServer.getProcessor().kickoffSession(session);
@@ -746,6 +752,7 @@ public class MemorySessionStore implements ISessionsStore {
}
} else {
LOG.error("Can't find the session for client <{}>", pcClientId);
mServer.getProcessor().getMessagesStore().forceCleanOnlineStatus(operator, pcClientId);
}
return ErrorCode.ERROR_CODE_SUCCESS;
}
@@ -755,10 +762,12 @@ public class MemorySessionStore implements ISessionsStore {
public void disableSession(String userId, String clientId) {
Session session = sessions.get(clientId);
if (session != null && session.getDeleted() == 0 && (userId == null || session.getUsername().equals(userId))) {
databaseStore.updateSessionDeleted(session.getUsername(), clientId, 1);
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
sessionSet.remove(clientId);
sessions.remove(clientId);
mServer.getProcessor().processOffline(session, true, () -> {
databaseStore.updateSessionDeleted(session.getUsername(), clientId, 1);
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
sessionSet.remove(clientId);
sessions.remove(clientId);
});
}
}
@@ -776,23 +785,25 @@ public class MemorySessionStore implements ISessionsStore {
return;
}
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
sessionSet.remove(clientID);
mServer.getProcessor().processOffline(session, true, () -> {
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
sessionSet.remove(clientID);
// remove also the messages stored of type QoS1/2
LOG.info("Removing stored messages with QoS 1 and 2. ClientId={}", clientID);
// remove also the messages stored of type QoS1/2
LOG.info("Removing stored messages with QoS 1 and 2. ClientId={}", clientID);
session.secondPhaseStore.clear();
session.outboundFlightMessages.clear();
session.inboundFlightMessages.clear();
session.secondPhaseStore.clear();
session.outboundFlightMessages.clear();
session.inboundFlightMessages.clear();
LOG.info("Wiping existing subscriptions. ClientId={}", clientID);
LOG.info("Wiping existing subscriptions. ClientId={}", clientID);
//remove also the enqueued messages
dropQueue(clientID);
//remove also the enqueued messages
dropQueue(clientID);
// TODO this missing last step breaks the junit test
sessions.remove(clientID);
// TODO this missing last step breaks the junit test
sessions.remove(clientID);
});
}
@Override
public boolean isMultiEndpointSupported() {
@@ -369,9 +369,6 @@ public class Server {
private String getServerIp(IConfig config) {
String serverIp = config.getProperty(BrokerConstants.SERVER_IP_PROPERTY_NAME);
if (serverIp == null || serverIp.equals("0.0.0.0")) {
String warning = "警告:无效配置,server.ip不能为空,需要配置服务的公网IP地址或者域名才能在公网使用!!!\nIM服务将使用本地地址,只能在局域网内使用!";
System.out.println(warning);
LOG.error(warning);
serverIp = Utility.getLocalAddress().getHostAddress();
}
return serverIp;
@@ -160,7 +160,7 @@ public class NettyAcceptor implements ServerAcceptor {
IConfig props) throws IOException {
LOG.info("Configuring TCP MQTT transport");
final MoquetteIdleTimeoutHandler timeoutHandler = new MoquetteIdleTimeoutHandler();
String host = props.getProperty(BrokerConstants.HOST_PROPERTY_NAME);
String host = props.getProperty(BrokerConstants.HOST_PROPERTY_NAME, "0.0.0.0");
String tcpPortProp = props.getProperty(PORT_PROPERTY_NAME, DISABLED_PORT_BIND);
if (DISABLED_PORT_BIND.equals(tcpPortProp)) {
LOG.info("Property {} has been set to {}. TCP MQTT will be disabled", BrokerConstants.PORT_PROPERTY_NAME,
@@ -106,7 +106,7 @@ public interface IMessagesStore {
Set<String> getAllEnds();
WFCMessage.PullMessageResult fetchMessage(String user, String exceptClientId, long fromMessageId, int pullType);
WFCMessage.PullMessageResult loadRemoteMessages(String user, WFCMessage.Conversation conversation, long beforeUid, int count, Collection<Integer> contentTypes);
long insertUserMessages(String sender, int conversationType, String target, int line, int messageContentType, String userId, long messageId);
long insertUserMessages(String sender, int conversationType, String target, int line, int messageContentType, String userId, long messageId, boolean directing);
WFCMessage.GroupInfo createGroup(String operator, WFCMessage.GroupInfo groupInfo, List<WFCMessage.GroupMember> memberList, String memberExtra, boolean isAdmin);
ErrorCode addGroupMembers(String operator, boolean isAdmin, String groupId, List<WFCMessage.GroupMember> memberList, String extra);
ErrorCode kickoffGroupMembers(String operator, boolean isAdmin, String groupId, List<String> memberList);
@@ -140,6 +140,8 @@ public interface IMessagesStore {
ErrorCode modifyUserInfo(String userId, WFCMessage.ModifyMyInfoRequest request) throws Exception;
void forceCleanOnlineStatus(String userId, String clientId);
void updateUserOnlineSetting(MemorySessionStore.Session session, boolean online);
ErrorCode modifyUserStatus(String userId, int status);
@@ -148,7 +150,7 @@ public interface IMessagesStore {
ErrorCode updateUserInfo(InputOutputUserInfo userInfo, int flag);
void addUserInfo(WFCMessage.User user, String password) throws Exception;
void destoryUser(String userId);
void destroyUser(String userId);
void updateUserInfo(WFCMessage.User user) throws Exception;
WFCMessage.User getUserInfo(String userId);
WFCMessage.User getUserInfoByName(String name);
@@ -191,6 +193,11 @@ public interface IMessagesStore {
boolean checkChatroomParticipantIdelTime(MemorySessionStore.Session session);
String getApplicationAuthCode(String fromUser, String applicationId, int appType, String host);
String verifyApplicationAuthCode(String token, String applicationId, int type);
ErrorCode configApplication(String appId, int appType, long timestamp, String nonce, String signature);
ErrorCode getUserSettings(String userId, long version, WFCMessage.GetUserSettingResult.Builder builder);
WFCMessage.UserSettingEntry getUserSetting(String userId, int scope, String key);
List<WFCMessage.UserSettingEntry> getUserSetting(String userId, int scope);
@@ -207,7 +214,7 @@ public interface IMessagesStore {
void clearUserChannels(String userId);
ErrorCode modifyChannelInfo(String operator, String channelId, int modifyType, String value);
ErrorCode transferChannel(String operator, String channelId, String newOwner);
ErrorCode distoryChannel(String operator, String channelId, boolean isAdmin);
ErrorCode destroyChannel(String operator, String channelId, boolean isAdmin);
List<WFCMessage.ChannelInfo> searchChannel(String keyword, boolean buzzy, int page);
ErrorCode listenChannel(String operator, String channelId, boolean listen);
WFCMessage.ChannelInfo getChannelInfo(String channelId);
@@ -226,6 +233,10 @@ public interface IMessagesStore {
boolean isAllowRobotCustomGroupNotification();
int getVisibleQuitKickoffNotification();
boolean isForwardMessageWithClientInfo();
boolean isRobotCallbackWithClientInfo();
boolean isChannelCallbackWithClientInfo();
List<Integer> getClientForbiddenSendTypes();
List<Integer> getBlackListExceptionTypes();
List<Integer> getGroupMuteExceptionTypes();
@@ -16,6 +16,7 @@
package io.moquette.spi.impl;
import cn.wildfirechat.pojos.OutputClient;
import cn.wildfirechat.pojos.OutputMessageData;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
@@ -24,7 +25,6 @@ import com.google.gson.Gson;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.util.StringUtil;
import cn.wildfirechat.pojos.OutputNotifyChannelSubscribeStatus;
import cn.wildfirechat.pojos.SendMessageData;
import com.xiaoleilu.loServer.model.FriendData;
import io.moquette.persistence.*;
import io.moquette.persistence.MemorySessionStore.Session;
@@ -160,7 +160,7 @@ public class MessagesPublisher {
}
}
private void publish2Receivers(String sender, int conversationType, String target, int line, long messageId, Collection<String> receivers, String pushContent, String pushData, String exceptClientId, int pullType, int messageContentType, long serverTime, int mentionType, List<String> mentionTargets, int persistFlag) {
private void publish2Receivers(String sender, int conversationType, String target, int line, long messageId, Collection<String> receivers, String pushContent, String pushData, String exceptClientId, int pullType, int messageContentType, long serverTime, int mentionType, List<String> mentionTargets, int persistFlag, boolean directing) {
if (persistFlag == Transparent) {
publishTransparentMessage2Receivers(messageId, receivers, pullType, exceptClientId);
return;
@@ -176,10 +176,19 @@ public class MessagesPublisher {
if (message == null) {
message = m_messagesStore.getMessage(messageId);
}
OutputClient outputClient = null;
if(m_messagesStore.isRobotCallbackWithClientInfo() && !StringUtil.isNullOrEmpty(exceptClientId)) {
Session session = m_sessionsStore.getSession(exceptClientId);
if(session != null && session.getUsername().equals(sender)) {
outputClient = new OutputClient(session.getPlatform(), exceptClientId);
}
}
final WFCMessage.Message finalMsg = message;
OutputClient finalOutputClient = outputClient;
Server.getServer().getCallbackScheduler().execute(() -> {
try {
HttpUtils.httpJsonPost(robot.getCallback(), new Gson().toJson(SendMessageData.fromProtoMessage(finalMsg), SendMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Robot_Message_Callback);
HttpUtils.httpJsonPost(robot.getCallback(), new Gson().toJson(OutputMessageData.fromProtoMessage(finalMsg, finalOutputClient), OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Robot_Message_Callback);
} catch (Exception e) {
e.printStackTrace();
Utility.printExecption(LOG, e, EVENT_CALLBACK_Exception);
@@ -191,7 +200,7 @@ public class MessagesPublisher {
}
long messageSeq;
if (pullType != ProtoConstants.PullType.Pull_ChatRoom) {
messageSeq = m_messagesStore.insertUserMessages(sender, conversationType, target, line, messageContentType, user, messageId);
messageSeq = m_messagesStore.insertUserMessages(sender, conversationType, target, line, messageContentType, user, messageId, directing);
} else {
messageSeq = m_messagesStore.insertChatroomMessages(user, line, messageId);
}
@@ -213,9 +222,7 @@ public class MessagesPublisher {
if (targetSession.getPlatform() == ProtoConstants.Platform.Platform_WEB
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_Windows
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_LINUX
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_OSX
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_iPad
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_APad) {
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_OSX) {
boolean targetIsActive = this.connectionDescriptors.isConnected(targetSession.getClientSession().clientID);
if (targetIsActive) {
isPcOnline = true;
@@ -597,10 +604,19 @@ public class MessagesPublisher {
public void publish2Receivers(WFCMessage.Message message, Set<String> receivers, String exceptClientId, int pullType) {
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel) {
WFCMessage.ChannelInfo channelInfo = m_messagesStore.getChannelInfo(message.getConversation().getTarget());
if (channelInfo != null && !StringUtil.isNullOrEmpty(channelInfo.getCallback())) {
if (channelInfo != null && !StringUtil.isNullOrEmpty(channelInfo.getCallback()) && channelInfo.getAutomatic() == 1 && !message.getFromUser().equals(channelInfo.getOwner())) {
OutputClient outputClient = null;
if(m_messagesStore.isChannelCallbackWithClientInfo() && !StringUtil.isNullOrEmpty(exceptClientId)) {
Session session = m_sessionsStore.getSession(exceptClientId);
if(session != null && session.getUsername().equals(message.getFromUser())) {
outputClient = new OutputClient(session.getPlatform(), exceptClientId);
}
}
OutputClient finalOutputClient = outputClient;
Server.getServer().getCallbackScheduler().execute(() -> {
try {
HttpUtils.httpJsonPost(channelInfo.getCallback() + "/message", new Gson().toJson(SendMessageData.fromProtoMessage(message), SendMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Channel_Message_Callback);
HttpUtils.httpJsonPost(channelInfo.getCallback() + "/message", new Gson().toJson(OutputMessageData.fromProtoMessage(message, finalOutputClient), OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Channel_Message_Callback);
} catch (Exception e) {
e.printStackTrace();
Utility.printExecption(LOG, e, EVENT_CALLBACK_Exception);
@@ -629,8 +645,8 @@ public class MessagesPublisher {
pushContent = "[语音]";
} else if(type == ProtoConstants.ContentType.Video) {
pushContent = "[视频]";
} else if(type == ProtoConstants.ContentType.RichMedia) {
pushContent = "[图文]";
} else if(type == ProtoConstants.ContentType.Link) {
pushContent = "[链接]";
} else if(type == ProtoConstants.ContentType.File) {
pushContent = "[文件]";
} else if(type == ProtoConstants.ContentType.Sticker) {
@@ -646,14 +662,14 @@ public class MessagesPublisher {
message.getConversation().getType(), message.getConversation().getTarget(), message.getConversation().getLine(),
messageId,
receivers,
pushContent, message.getContent().getPushData(), exceptClientId, pullType, message.getContent().getType(), message.getServerTimestamp(), message.getContent().getMentionedType(), message.getContent().getMentionedTargetList(), message.getContent().getPersistFlag());
pushContent, message.getContent().getPushData(), exceptClientId, pullType, message.getContent().getType(), message.getServerTimestamp(), message.getContent().getMentionedType(), message.getContent().getMentionedTargetList(), message.getContent().getPersistFlag(), message.hasToUser() || !message.getToList().isEmpty());
}
public void forwardMessage(final WFCMessage.Message message, String forwardUrl) {
public void forwardMessage(final WFCMessage.Message message, String forwardUrl, OutputClient outputClient) {
Server.getServer().getCallbackScheduler().execute(() -> {
try {
HttpUtils.httpJsonPost(forwardUrl, new Gson().toJson(OutputMessageData.fromProtoMessage(message), OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Forward_Message_Callback);
HttpUtils.httpJsonPost(forwardUrl, new Gson().toJson(OutputMessageData.fromProtoMessage(message, outputClient), OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Forward_Message_Callback);
} catch (Exception e) {
e.printStackTrace();
Utility.printExecption(LOG, e, EVENT_CALLBACK_Exception);
@@ -685,7 +701,7 @@ public class MessagesPublisher {
}
public void notifyChannelListenStatusChanged(WFCMessage.ChannelInfo channelInfo, String user, boolean listen) {
if (channelInfo == null || StringUtil.isNullOrEmpty(channelInfo.getCallback())) {
if (channelInfo == null || StringUtil.isNullOrEmpty(channelInfo.getCallback()) || channelInfo.getAutomatic() == 0) {
return;
}
@@ -620,15 +620,27 @@ public class ProtocolProcessor {
String username = NettyUtils.userName(channel);
MemorySessionStore.Session session = m_sessionsStore.getSession(clientID);
if(session != null) {
session.refreshLastActiveTime();
forwardOnlineStatusEvent(username, clientID, session.getPlatform(), clearSession ? UserOnlineStatus.LOGOUT : UserOnlineStatus.OFFLINE, session.getAppName());
processOffline(session, clearSession, () -> {
ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel);
if(connectionDescriptors.removeConnection(oldConnDescr)) {
m_interceptor.notifyClientConnectionLost(clientID, username);
}
});
} else {
ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel);
if(connectionDescriptors.removeConnection(oldConnDescr)) {
m_interceptor.notifyClientConnectionLost(clientID, username);
}
}
}
ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel);
if(connectionDescriptors.removeConnection(oldConnDescr)) {
m_interceptor.notifyClientConnectionLost(clientID, username);
}
public void processOffline(MemorySessionStore.Session session, boolean logout, Runnable runnable) {
if(session != null) {
session.refreshLastActiveTime();
forwardOnlineStatusEvent(session.getUsername(), session.getClientID(), session.getPlatform(), logout ? UserOnlineStatus.LOGOUT : UserOnlineStatus.OFFLINE, session.getAppName());
if(runnable != null) {
runnable.run();
}
m_messagesStore.updateUserOnlineSetting(session, false);
}
}
@@ -165,14 +165,17 @@ public class Qos1PublishHandler extends QosPublishHandler {
if (session != null && session.getUsername().equals(fromUser)) {
if (data.length > 7*1024 && session.getMqttVersion().protocolLevel() >= MqttVersion.Wildfire_1.protocolLevel()) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
GZIPOutputStream gzip;
GZIPOutputStream gzip = null;
try {
gzip = new GZIPOutputStream(out);
gzip.write(data);
gzip.close();
} catch (Exception e) {
e.printStackTrace();
Utility.printExecption(LOG, e);
} finally {
if(gzip != null) {
gzip.close();
}
}
data = out.toByteArray();
code = (byte)ErrorCode.ERROR_CODE_SUCCESS_GZIPED.code;
@@ -54,7 +54,7 @@ public class DBUtil {
if (embedDB != null && embedDB.equals("1")) {
IsEmbedDB = true;
LOG.info("Use h2 database");
String warning = "您正在使用内置h2数据库,建议仅在开发验证或者用户数小于100人时才使用此数据库,其它情况建议使用MySQL。";
String warning = "您正在使用h2数据库,建议仅在开发验证或者用户数小于100人时才使用此数据库。正式上线时建议切换到MySQL数据库。";
System.out.println(warning);
LOG.warn(warning);
} else {
@@ -83,4 +83,7 @@ public interface IMTopic {
String KickoffPCClientTopic = "KPCC";
String ClearSessionTopic = "CST";
String GetApplicationTokenRequestTopic = "ATR";
String ApplicationConfigRequestTopic = "ACR";
}
+8 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.80</version>
<version>0.92</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -29,7 +29,13 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
@@ -26,12 +26,16 @@ public interface APIPath {
String User_Get_Token = "/admin/user/get_token";
String User_Update_Block_Status = "/admin/user/update_block_status";
String User_Get_Info = "/admin/user/get_info";
String User_Get_Robot_Info = "/admin/user/get_robot_info";
String User_Get_Blocked_List = "/admin/user/get_blocked_list";
String User_Check_Block_Status = "/admin/user/check_block_status";
String User_Get_Online_Status = "/admin/user/onlinestatus";
String User_Put_Setting = "/admin/user/put_setting";
String User_Get_Setting = "/admin/user/get_setting";
String User_Kickoff_Client = "/admin/user/kickoff_client";
String User_Online_Count = "/admin/user/online_count";
String User_Online_List = "/admin/user/online_list";
String User_Application_Get_UserInfo = "/admin/user/app_get_user_info";
String Friend_Update_Status = "/admin/friend/status";
String Friend_Get_List = "/admin/friend/list";
@@ -47,10 +51,14 @@ public interface APIPath {
String Msg_Send = "/admin/message/send";
String Msg_Recall = "/admin/message/recall";
String Msg_Delete = "/admin/message/delete";
String Msg_Update = "/admin/message/update";
String Msg_GetOne = "/admin/message/get_one";
String Msg_Broadcast = "/admin/message/broadcast";
String Msg_Multicast = "/admin/message/multicast";
String Msg_RecallBroadCast = "/admin/message/recall_broadcast";
String Msg_RecallMultiCast = "/admin/message/recall_multicast";
String Msg_ConvRead = "/admin/message/conv_read";
String Msg_Delivery = "/admin/message/delivery";
String Create_Group = "/admin/group/create";
String Group_Dismiss = "/admin/group/del";
@@ -87,17 +95,16 @@ public interface APIPath {
String Channel_Message_Send = "/channel/message/send";
String Channel_Subscribe = "/channel/subscribe";
String Channel_Subscriber_List = "/channel/subscriber_list";
String Channel_Application_Get_UserInfo = "/channel/application/get_user_info";
String Robot_User_Info = "/robot/user_info";
String Robot_Get_Profile = "/robot/profile";
String Robot_Message_Send = "/robot/message/send";
String Robot_Set_Callback = "/robot/set_callback";
String Robot_Get_Callback = "/robot/get_callback";
String Robot_Delete_Callback = "/robot/delete_callback";
String Robot_Update_Profile = "/robot/update_profile";
String Robot_Verify_Application_User = "/robot/user/verify";
String Robot_Application_Get_UserInfo = "/robot/application/get_user_info";
String Robot_Group_Member_Add = "/robot/group/member/add";
String Robot_Group_Allow_Member = "/robot/group/manager/allow";
String Robot_Create_Group = "/robot/group/create";
@@ -28,7 +28,8 @@ public enum ErrorCode {
ERROR_CODE_INVALID_MESSAGE(10, "invalid message"),
//Group error
ERROR_CODE_GROUP_ALREADY_EXIST(11, "group aleady exist"),
ERROR_CODE_GROUP_ALREADY_EXIST(11, "group already exist"),
ERROR_CODE_ALREADY_IN_GROUP(12, "member already in group"),
//user error
ERROR_CODE_FRIEND_ALREADY_REQUEST(16, "already send request"),
@@ -48,6 +49,19 @@ public enum ErrorCode {
ERROR_CODE_ROBOT_NO_TOKEN(27, "robot no token"),
ERROR_CODE_WS_NOT_CONFIGURED_CORRECTLY(28, "ws not configured correctly"),
ERROR_CODE_CONFERENCE_ROOM_NOT_EXIST(60, "conference room not exist"),
ERROR_CODE_CONFERENCE_SERVICE_NOT_AVAILABLE(61, "conference service not available"),
ERROR_CODE_APPLICATION_TOKEN_ERROR_OR_TIMEOUT(70, "application token error or timeout"),
ERROR_CODE_SECRET_CHAT_ACCEPTED_BY_OTHER_CLIENT(81, "secret chat accepted by other client"),
ERROR_CODE_SECRET_CHAT_SESSION_NOT_EXIST(82, "secret chat session not exist"),
ERROR_CODE_SECRET_CHAT_NOT_SESSION_CLIENT(83, "not secret chat session client"),
ERROR_CODE_SECRET_CHAT_SESSION_NOT_READY(84, "secret chat session not ready"),
ERROR_CODE_SECRET_CHAT_SESSION_DESTROYED(85, "secret chat session destroyed"),
ERROR_CODE_SECRET_CHAT_MO_DISABLED(86, "origin side disable secret chat"),
ERROR_CODE_SECRET_CHAT_MT_DISABLED(87, "target side disable secret chat"),
ERROR_CODE_FUNCTION_DISABLED(220, "function disabled"),
ERROR_CODE_CHANNEL_NO_EXIST(236, "channel no exist"),
ERROR_CODE_CHANNEL_NO_SECRET(237, "channel no secret"),
@@ -0,0 +1,83 @@
package cn.wildfirechat.messagecontentbuilder;
import cn.wildfirechat.pojos.MessagePayload;
import cn.wildfirechat.proto.ProtoConstants;
import io.netty.util.internal.StringUtil;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.function.Consumer;
public class ArticlesContentBuilder extends MessageContentBuilder{
public static class Article {
public String id;
public String cover;
public String title;
public String url;
public boolean readReport;
}
public Article topArticle;
public List<Article> subArticles;
public static ArticlesContentBuilder newBuilder(String id, String cover, String title, String url, boolean readReport) {
ArticlesContentBuilder builder = new ArticlesContentBuilder();
builder.topArticle = new Article();
builder.topArticle.id = id;
builder.topArticle.cover = cover;
builder.topArticle.title = title;
builder.topArticle.url = url;
builder.topArticle.readReport = readReport;
return builder;
}
public ArticlesContentBuilder addSubArticle(String id, String cover, String title, String url, boolean readReport) {
Article article = new Article();
article.id = id;
article.cover = cover;
article.title = title;
article.url = url;
article.readReport = readReport;
if(subArticles == null) {
subArticles = new ArrayList<>();
}
subArticles.add(article);
return this;
}
private static JSONObject toJSON(Article article) {
JSONObject top = new JSONObject();
if(!StringUtil.isNullOrEmpty(article.id))
top.put("id", article.id);
if(!StringUtil.isNullOrEmpty(article.cover))
top.put("cover", article.cover);
if(!StringUtil.isNullOrEmpty(article.title))
top.put("title", article.title);
if(!StringUtil.isNullOrEmpty(article.url))
top.put("url", article.url);
if(article.readReport)
top.put("rr", article.readReport);
return top;
}
@Override
public MessagePayload build() {
MessagePayload payload = encodeBase();
payload.setType(ProtoConstants.ContentType.Articles);
payload.setPersistFlag(ProtoConstants.PersistFlag.Persist_And_Count);
payload.setSearchableContent(topArticle.title);
JSONObject jsonObject = new JSONObject();
jsonObject.put("top", toJSON(topArticle));
if(subArticles != null && !subArticles.isEmpty()) {
JSONArray jsonArray = new JSONArray();
subArticles.forEach(article -> jsonArray.add(toJSON(article)));
jsonObject.put("subArticles", jsonArray);
}
payload.setBase64edData(Base64.getEncoder().encodeToString(jsonObject.toJSONString().getBytes(StandardCharsets.UTF_8)));
return payload;
}
}
@@ -0,0 +1,19 @@
package cn.wildfirechat.messagecontentbuilder;
import cn.wildfirechat.pojos.MessagePayload;
abstract public class MediaMessageContentBuilder extends MessageContentBuilder{
private String remoteMediaUrl;
public MediaMessageContentBuilder remoteMediaUrl(String remoteMediaUrl) {
this.remoteMediaUrl = remoteMediaUrl;
return this;
}
@Override
protected MessagePayload encodeBase() {
MessagePayload payload = super.encodeBase();
payload.setRemoteMediaUrl(remoteMediaUrl);
return payload;
}
}
@@ -0,0 +1,33 @@
package cn.wildfirechat.messagecontentbuilder;
import cn.wildfirechat.pojos.MessagePayload;
import java.util.List;
public abstract class MessageContentBuilder {
private int mentionedType;
private List<String> mentionedTargets;
private String extra;
public MessageContentBuilder mentionedType(int mentionedType) {
this.mentionedType = mentionedType;
return this;
}
public MessageContentBuilder mentionedTargets(List<String> mentionedTargets) {
this.mentionedTargets = mentionedTargets;
return this;
}
public MessageContentBuilder extra(String extra) {
this.extra = extra;
return this;
}
protected MessagePayload encodeBase() {
MessagePayload payload = new MessagePayload();
payload.setMentionedType(mentionedType);
payload.setMentionedTarget(mentionedTargets);
payload.setExtra(extra);
return payload;
}
abstract public MessagePayload build();
}
@@ -0,0 +1,88 @@
package cn.wildfirechat.messagecontentbuilder;
import cn.wildfirechat.pojos.MessagePayload;
import cn.wildfirechat.proto.ProtoConstants;
import io.netty.util.internal.StringUtil;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
public class RichNotificationContentBuilder extends MessageContentBuilder{
private String title;
private String desc;
private String remark;
private JSONArray datas;
private String exName;
private String exPortrait;
private String exUrl;
private String appId;
public static RichNotificationContentBuilder newBuilder(String title, String desc, String exUrl) {
RichNotificationContentBuilder builder = new RichNotificationContentBuilder();
builder.title = title;
builder.desc = desc;
builder.exUrl = exUrl;
return builder;
}
public RichNotificationContentBuilder remark(String remark) {
this.remark = remark;
return this;
}
public RichNotificationContentBuilder exName(String exName) {
this.exName = exName;
return this;
}
public RichNotificationContentBuilder exPortrait(String exPortrait) {
this.exPortrait = exPortrait;
return this;
}
public RichNotificationContentBuilder appId(String appId) {
this.appId = appId;
return this;
}
public RichNotificationContentBuilder addItem(String key, String value) {
return addItem(key, value, null);
}
public RichNotificationContentBuilder addItem(String key, String value, String color) {
if(this.datas == null) {
this.datas = new JSONArray();
}
JSONObject item = new JSONObject();
item.put("key", key);
item.put("value", value == null ? "" : value);
if(!StringUtil.isNullOrEmpty(color)) {
item.put("color", color);
}
this.datas.add(item);
return this;
}
@Override
public MessagePayload build() {
MessagePayload payload = encodeBase();
payload.setType(ProtoConstants.ContentType.Rich_Notification);
payload.setPersistFlag(ProtoConstants.PersistFlag.Persist_And_Count);
payload.setPushContent(title);
payload.setContent(desc);
JSONObject jsonObject = new JSONObject();
if(!StringUtil.isNullOrEmpty(remark))
jsonObject.put("remark", remark);
if(!StringUtil.isNullOrEmpty(exName))
jsonObject.put("exName", exName);
if(!StringUtil.isNullOrEmpty(exPortrait))
jsonObject.put("exPortrait", exPortrait);
if(!StringUtil.isNullOrEmpty(exUrl))
jsonObject.put("exUrl", exUrl);
if(!StringUtil.isNullOrEmpty(appId))
jsonObject.put("appId", appId);
if(datas != null && !datas.isEmpty())
jsonObject.put("datas", datas);
payload.setBase64edData(Base64.getEncoder().encodeToString(jsonObject.toJSONString().getBytes(StandardCharsets.UTF_8)));
return payload;
}
}
@@ -0,0 +1,25 @@
package cn.wildfirechat.messagecontentbuilder;
import cn.wildfirechat.pojos.MessagePayload;
import cn.wildfirechat.proto.ProtoConstants;
import org.json.simple.JSONObject;
public class SoundMessageContentBuilder extends MediaMessageContentBuilder {
private int duration;
public static SoundMessageContentBuilder newBuilder(int duration) {
SoundMessageContentBuilder builder = new SoundMessageContentBuilder();
builder.duration = duration;
return builder;
}
@Override
public MessagePayload build() {
MessagePayload payload = encodeBase();
payload.setType(ProtoConstants.ContentType.Voice);
payload.setMediaType(ProtoConstants.MessageMediaType.VOICE);
payload.setPersistFlag(ProtoConstants.PersistFlag.Persist_And_Count);
JSONObject jsonObject = new JSONObject();
jsonObject.put("duration", duration);
payload.setContent(jsonObject.toJSONString());
return payload;
}
}
@@ -0,0 +1,21 @@
package cn.wildfirechat.messagecontentbuilder;
import cn.wildfirechat.pojos.MessagePayload;
import cn.wildfirechat.proto.ProtoConstants;
public class TextMessageContentBuilder extends MessageContentBuilder{
private String text;
public static TextMessageContentBuilder newBuilder(String text) {
TextMessageContentBuilder builder = new TextMessageContentBuilder();
builder.text = text;
return builder;
}
@Override
public MessagePayload build() {
MessagePayload payload = encodeBase();
payload.setType(ProtoConstants.ContentType.Text);
payload.setPersistFlag(ProtoConstants.PersistFlag.Persist_And_Count);
payload.setSearchableContent(text);
return payload;
}
}
@@ -0,0 +1,53 @@
package cn.wildfirechat.pojos;
import com.google.gson.Gson;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
public class ArticleContent {
public static class Article {
public String id;
public String cover;
public String title;
public String url;
public boolean rr;
public Article() {
}
public Article(String id, String cover, String title, String url, boolean rr) {
this.id = id;
this.cover = cover;
this.title = title;
this.url = url;
this.rr = rr;
}
}
public Article top;
public List<Article> subArticles;
public ArticleContent() {
}
public ArticleContent(String id, String cover, String title, String url, boolean rr) {
this.top = new Article(id, cover, title, url, rr);
}
public ArticleContent addSubArticle(String id, String cover, String title, String url, boolean rr) {
if (subArticles == null)
subArticles = new ArrayList<>();
subArticles.add(new Article(id, cover, title, url, rr));
return this;
}
public MessagePayload toPayload() {
MessagePayload payload = new MessagePayload();
payload.setType(13);
payload.setSearchableContent(top.title);
payload.setBase64edData(Base64.getEncoder().encodeToString(new Gson().toJson(this).getBytes(StandardCharsets.UTF_8)));
return payload;
}
}
@@ -3,4 +3,5 @@ package cn.wildfirechat.pojos;
public class ConferenceJoinEvent {
public String userId;
public String roomId;
public boolean screenSharing;
}
@@ -3,4 +3,5 @@ package cn.wildfirechat.pojos;
public class ConferenceLeaveEvent {
public String userId;
public String roomId;
public boolean screenSharing;
}
@@ -4,4 +4,5 @@ public class ConferencePublishEvent {
public String userId;
public boolean video;
public String roomId;
public boolean screenSharing;
}
@@ -3,4 +3,5 @@ package cn.wildfirechat.pojos;
public class ConferenceUnpublishEvent {
public String userId;
public String roomId;
public boolean screenSharing;
}
@@ -13,6 +13,15 @@ public class Conversation {
private String target;
private int line;
public Conversation() {
}
public Conversation(int type, String target, int line) {
this.type = type;
this.target = target;
this.line = line;
}
public int getType() {
return type;
}
@@ -18,6 +18,9 @@ public class ForwardDeviceMessageData {
private int type;
private byte[] data;
public ForwardDeviceMessageData() {
}
public ForwardDeviceMessageData(String deviceId, int type, byte[] data) {
this.deviceId = deviceId;
this.type = type;
@@ -0,0 +1,10 @@
package cn.wildfirechat.pojos;
import java.util.ArrayList;
public class GetOnlineUserCountResult extends ArrayList<GetOnlineUserCountResult.Node> {
public static class Node {
public int node;
public int count;
}
}
@@ -0,0 +1,9 @@
package cn.wildfirechat.pojos;
import java.util.ArrayList;
public class GetOnlineUserRequest {
public int nodeId;
public int offset;
public int count;
}
@@ -0,0 +1,15 @@
package cn.wildfirechat.pojos;
import java.util.ArrayList;
public class GetOnlineUserResult {
public static class UserClient {
public String userId;
public String clientId;
public int platform;
}
public ArrayList<GetOnlineUserResult.UserClient> userClients;
public int totalCount;
public int offset;
}
@@ -31,6 +31,9 @@ public class GroupNotificationBinaryContent {
//value2(member or something)
private String m;
public GroupNotificationBinaryContent() {
}
public GroupNotificationBinaryContent(String g, String o, String n, String m) {
this.g = g;
this.o = o;
@@ -8,14 +8,14 @@
package cn.wildfirechat.pojos;
public class OutputVerifyApplicationUser {
private String userId;
public class InputApplicationGetUserInfo {
private String authCode;
public String getUserId() {
return userId;
public String getAuthCode() {
return authCode;
}
public void setUserId(String userId) {
this.userId = userId;
public void setAuthCode(String authCode) {
this.authCode = authCode;
}
}
@@ -13,6 +13,9 @@ public class InputChatroomMute {
private String chatroomId;
private int status;
public InputChatroomMute() {
}
public InputChatroomMute(String chatroomId, int status) {
this.chatroomId = chatroomId;
this.status = status;
@@ -67,16 +67,18 @@ public class InputCreateGroup extends InputGroupBase {
}
groupBuilder.setGroupInfo(groupInfoBuilder);
for (PojoGroupMember pojoGroupMember : group.getMembers()) {
WFCMessage.GroupMember.Builder groupMemberBuilder = WFCMessage.GroupMember.newBuilder().setMemberId(pojoGroupMember.getMember_id());
if (!StringUtil.isNullOrEmpty(pojoGroupMember.getAlias())) {
groupMemberBuilder.setAlias(pojoGroupMember.getAlias());
if(group.getMembers() != null) {
for (PojoGroupMember pojoGroupMember : group.getMembers()) {
WFCMessage.GroupMember.Builder groupMemberBuilder = WFCMessage.GroupMember.newBuilder().setMemberId(pojoGroupMember.getMember_id());
if (!StringUtil.isNullOrEmpty(pojoGroupMember.getAlias())) {
groupMemberBuilder.setAlias(pojoGroupMember.getAlias());
}
groupMemberBuilder.setType(pojoGroupMember.getType());
if (!StringUtil.isNullOrEmpty(pojoGroupMember.getExtra())) {
groupMemberBuilder.setExtra(pojoGroupMember.extra);
}
groupBuilder.addMembers(groupMemberBuilder);
}
groupMemberBuilder.setType(pojoGroupMember.getType());
if(!StringUtil.isNullOrEmpty(pojoGroupMember.getExtra())) {
groupMemberBuilder.setExtra(pojoGroupMember.extra);
}
groupBuilder.addMembers(groupMemberBuilder);
}
WFCMessage.CreateGroupRequest.Builder createGroupReqBuilder = WFCMessage.CreateGroupRequest.newBuilder();
@@ -0,0 +1,58 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
public class InputGetConvReadTime {
private String userId;
private int conversationType;
private String target;
private int line;
public InputGetConvReadTime() {
}
public InputGetConvReadTime(String userId, int conversationType, String target, int line) {
this.userId = userId;
this.conversationType = conversationType;
this.target = target;
this.line = line;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public int getConversationType() {
return conversationType;
}
public void setConversationType(int conversationType) {
this.conversationType = conversationType;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public int getLine() {
return line;
}
public void setLine(int line) {
this.line = line;
}
}
@@ -5,6 +5,9 @@ public class InputGetToken {
private String clientId;
private Integer platform;
public InputGetToken() {
}
public InputGetToken(String userId, String clientId, int platform) {
this.userId = userId;
this.clientId = clientId;
@@ -13,6 +13,9 @@ public class InputGetUserInfo {
private String name;
private String mobile;
public InputGetUserInfo() {
}
public InputGetUserInfo(String userId, String name, String mobile) {
this.userId = userId;
this.name = name;
@@ -0,0 +1,12 @@
package cn.wildfirechat.pojos;
public class InputMessageUid {
public long messageUid;
public InputMessageUid() {
}
public InputMessageUid(long messageUid) {
this.messageUid = messageUid;
}
}
@@ -13,6 +13,9 @@ public class InputOutputUserBlockStatus {
private String userId;
private int status;
public InputOutputUserBlockStatus() {
}
public InputOutputUserBlockStatus(String userId, int status) {
this.userId = userId;
this.status = status;
@@ -8,14 +8,14 @@
package cn.wildfirechat.pojos;
public class InputVerifyApplicationUser {
private String token;
public class InputRobotId {
private String robotId;
public String getToken() {
return token;
public String getRobotId() {
return robotId;
}
public void setToken(String token) {
this.token = token;
public void setRobotId(String robotId) {
this.robotId = robotId;
}
}
@@ -11,6 +11,13 @@ package cn.wildfirechat.pojos;
public class InputUserId {
private String userId;
public InputUserId() {
}
public InputUserId(String userId) {
this.userId = userId;
}
public String getUserId() {
return userId;
}
@@ -0,0 +1,57 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
public class OutputApplicationConfigData {
private String appId;
private int appType;
private long timestamp;
private String nonceStr;
private String signature;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public int getAppType() {
return appType;
}
public void setAppType(int appType) {
this.appType = appType;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public String getNonceStr() {
return nonceStr;
}
public void setNonceStr(String nonceStr) {
this.nonceStr = nonceStr;
}
public String getSignature() {
return signature;
}
public void setSignature(String signature) {
this.signature = signature;
}
}
@@ -0,0 +1,39 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
public class OutputApplicationUserInfo {
private String userId;
private String displayName;
private String portraitUrl;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getPortraitUrl() {
return portraitUrl;
}
public void setPortraitUrl(String portraitUrl) {
this.portraitUrl = portraitUrl;
}
}
@@ -0,0 +1,40 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
import java.util.List;
public class OutputClient {
private int platform;
private String clientId;
public OutputClient() {
}
public OutputClient(int platform, String clientId) {
this.platform = platform;
this.clientId = clientId;
}
public int getPlatform() {
return platform;
}
public void setPlatform(int platform) {
this.platform = platform;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
}
@@ -13,6 +13,9 @@ public class OutputCreateDevice {
private String token;
private String secret;
public OutputCreateDevice() {
}
public OutputCreateDevice(String userId, String token, String secret) {
this.deviceId = userId;
this.token = token;
@@ -12,6 +12,9 @@ public class OutputCreateRobot {
private String userId;
private String secret;
public OutputCreateRobot() {
}
public OutputCreateRobot(String userId, String secret) {
this.userId = userId;
this.secret = secret;
@@ -12,6 +12,9 @@ public class OutputCreateUser {
private String userId;
private String name;
public OutputCreateUser() {
}
public OutputCreateUser(String userId, String name) {
this.userId = userId;
this.name = name;
@@ -20,6 +20,9 @@ public class OutputDevice {
private List<String> owners;
private String extra;
public OutputDevice() {
}
public OutputDevice(String deviceId, String token, String secret) {
this.deviceId = deviceId;
this.token = token;
@@ -10,8 +10,69 @@ package cn.wildfirechat.pojos;
import cn.wildfirechat.proto.WFCMessage;
import io.netty.util.internal.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class OutputGetChannelInfo {
public static class OutputMenu {
public String menuId;
public String type;
public String name;
public String key;
public String url;
public String mediaId;
public String articleId;
public String appId;
public String appPage;
public String extra;
public List<OutputMenu> subMenus;
public static OutputMenu fromPbInfo(WFCMessage.ChannelMenu channelMenuMenu) {
OutputMenu out = new OutputMenu();
out.menuId = channelMenuMenu.getMenuId();
out.type = channelMenuMenu.getType();
out.name = channelMenuMenu.getName();
out.key = channelMenuMenu.getKey();
out.url = channelMenuMenu.getUrl();
out.mediaId = channelMenuMenu.getMediaId();
out.articleId = channelMenuMenu.getArticleId();
out.appId = channelMenuMenu.getAppId();
out.appPage = channelMenuMenu.getAppPage();
out.extra = channelMenuMenu.getExtra();
if (channelMenuMenu.getSubMenuCount() > 0) {
out.subMenus = new ArrayList<>();
for (WFCMessage.ChannelMenu menuMenu : channelMenuMenu.getSubMenuList()) {
out.subMenus.add(fromPbInfo(menuMenu));
}
}
return out;
}
public WFCMessage.ChannelMenu.Builder toPbInfo() {
WFCMessage.ChannelMenu.Builder builder = WFCMessage.ChannelMenu.newBuilder();
builder.setType(type);
builder.setName(name);
if (!StringUtil.isNullOrEmpty(menuId)) builder.setMenuId(menuId);
if (!StringUtil.isNullOrEmpty(key)) builder.setKey(key);
if (!StringUtil.isNullOrEmpty(url)) builder.setUrl(url);
if (!StringUtil.isNullOrEmpty(mediaId)) builder.setMediaId(mediaId);
if (!StringUtil.isNullOrEmpty(articleId)) builder.setArticleId(articleId);
if (!StringUtil.isNullOrEmpty(appId)) builder.setAppId(appId);
if (!StringUtil.isNullOrEmpty(appPage)) builder.setAppPage(appPage);
if (!StringUtil.isNullOrEmpty(extra)) builder.setExtra(extra);
if (subMenus != null && !subMenus.isEmpty()) {
subMenus.forEach(menuMenu -> builder.addSubMenu(menuMenu.toPbInfo()));
}
return builder;
}
}
public static class OutputMenuList extends ArrayList<OutputMenu> {
}
private String channelId;
private String name;
private String desc;
@@ -19,13 +80,12 @@ public class OutputGetChannelInfo {
private String extra;
private String owner;
private int state;
//此字段已经废弃,为了兼容旧的SDK版本,以后会移除
@Deprecated()
private int status;
private long updateDt;
private String callback;
private int automatic;
private String secret;
public List<OutputMenu> menus;
public String getChannelId() {
return channelId;
@@ -115,6 +175,14 @@ public class OutputGetChannelInfo {
this.status = status;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public static OutputGetChannelInfo fromPbInfo(WFCMessage.ChannelInfo channelInfo) {
OutputGetChannelInfo out = new OutputGetChannelInfo();
out.automatic = channelInfo.getAutomatic();
@@ -126,8 +194,16 @@ public class OutputGetChannelInfo {
out.owner = channelInfo.getOwner();
out.portrait = channelInfo.getPortrait();
out.state = channelInfo.getStatus();
out.status = out.state;
out.status = channelInfo.getStatus();;
out.updateDt = channelInfo.getUpdateDt();
out.secret = channelInfo.getSecret();
if (channelInfo.getMenuCount() > 0) {
out.menus = new ArrayList<>();
for (WFCMessage.ChannelMenu channelMenuMenu : channelInfo.getMenuList()) {
out.menus.add(OutputMenu.fromPbInfo(channelMenuMenu));
}
}
return out;
}
}
@@ -14,6 +14,9 @@ public class OutputLoginData {
private String userId;
private String token;
public OutputLoginData() {
}
public OutputLoginData(String userId, String token) {
this.userId = userId;
this.token = token;
@@ -20,6 +20,7 @@ public class OutputMessageData {
private MessagePayload payload;
private List<String> toUsers;
private long timestamp;
private OutputClient client;
public String getSender() {
return sender;
@@ -69,7 +70,19 @@ public class OutputMessageData {
this.timestamp = timestamp;
}
public OutputClient getClient() {
return client;
}
public void setClient(OutputClient client) {
this.client = client;
}
public static OutputMessageData fromProtoMessage(WFCMessage.Message protoMessage) {
return fromProtoMessage(protoMessage, null);
}
public static OutputMessageData fromProtoMessage(WFCMessage.Message protoMessage, OutputClient fromClient) {
OutputMessageData data = new OutputMessageData();
data.messageId = protoMessage.getMessageId();
data.sender = protoMessage.getFromUser();
@@ -80,6 +93,7 @@ public class OutputMessageData {
data.payload = MessagePayload.fromProtoMessageContent(protoMessage.getContent());
data.timestamp = protoMessage.getServerTimestamp();
data.toUsers = protoMessage.getToList();
data.client = fromClient;
return data;
}
}
@@ -13,6 +13,9 @@ public class OutputNotifyChannelSubscribeStatus {
private String channelId;
private int status;
public OutputNotifyChannelSubscribeStatus() {
}
public OutputNotifyChannelSubscribeStatus(String userId, String channelId, boolean subscirbed) {
this.userId = userId;
this.channelId = channelId;
@@ -0,0 +1,184 @@
package cn.wildfirechat.pojos;
import cn.wildfirechat.proto.WFCMessage;
public class OutputRobot {
private String userId;
private String name;
private String password;
private String displayName;
private String portrait;
private int gender;
private String mobile;
private String email;
private String address;
private String company;
private String social;
private String extra;
private long updateDt;
private String owner;
private String secret;
private String callback;
private String robotExtra;
public String getSocial() {
return social;
}
public void setSocial(String social) {
this.social = social;
}
public long getUpdateDt() {
return updateDt;
}
public void setUpdateDt(long updateDt) {
this.updateDt = updateDt;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getPortrait() {
return portrait;
}
public void setPortrait(String portrait) {
this.portrait = portrait;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getExtra() {
return extra;
}
public void setExtra(String extra) {
this.extra = extra;
}
public int getGender() {
return gender;
}
public void setGender(int gender) {
this.gender = gender;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public String getCallback() {
return callback;
}
public void setCallback(String callback) {
this.callback = callback;
}
public String getRobotExtra() {
return robotExtra;
}
public void setRobotExtra(String robotExtra) {
this.robotExtra = robotExtra;
}
public void fromUser(WFCMessage.User user) {
userId = user.getUid();
name = user.getName();
displayName = user.getDisplayName();
portrait = user.getPortrait();
gender = user.getGender();
mobile = user.getMobile();
email = user.getEmail();
address = user.getAddress();
company = user.getCompany();
social = user.getSocial();
extra = user.getExtra();
updateDt = user.getUpdateDt();
}
public void fromRobot(WFCMessage.Robot robot, boolean withSecret) {
setOwner(robot.getOwner());
if(withSecret) {
setSecret(robot.getSecret());
}
setCallback(robot.getCallback());
setRobotExtra(robot.getExtra());
}
}
@@ -16,6 +16,9 @@ public class OutputRouteData { ;
private int shortPort;
private String secret;
public OutputRouteData() {
}
public OutputRouteData(List<String> serverIPs, int longPort, int shortPort, String secret) {
this.serverIPs = serverIPs;
this.longPort = longPort;
@@ -0,0 +1,28 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
public class OutputTimestamp {
private long timestamp;
public OutputTimestamp() {
}
public OutputTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
}
@@ -8,4 +8,5 @@ public class PojoConferenceCreate {
public int bitrate;
public boolean advance;
public boolean recording;
public boolean permanent;
}
@@ -0,0 +1,57 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
public class UpdateMessageContentData {
private String operator;
private long messageUid;
private MessagePayload payload;
private int distribute;
private int updateTimestamp;
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public long getMessageUid() {
return messageUid;
}
public void setMessageUid(long messageUid) {
this.messageUid = messageUid;
}
public MessagePayload getPayload() {
return payload;
}
public void setPayload(MessagePayload payload) {
this.payload = payload;
}
public int getDistribute() {
return distribute;
}
public void setDistribute(int distribute) {
this.distribute = distribute;
}
public int getUpdateTimestamp() {
return updateTimestamp;
}
public void setUpdateTimestamp(int updateTimestamp) {
this.updateTimestamp = updateTimestamp;
}
}
@@ -84,7 +84,60 @@ public class ProtoConstants {
int File = 5;
int Video = 6;
int Sticker = 7;
int RichMedia = 8;
int Link = 8;
int P_TEXT = 9;
int Name_Card = 10;
int Composited = 11;
int Rich_Notification = 12;
int Articles = 13;
int Enter_Channel_Chat = 71;
int Leave_Channel_Chat = 72;
int Recall = 80;
int Delete = 81;
int Tip = 90;
int Typing = 91;
int Friend_Greeting = 92;
int Friend_Added = 93;
int PC_Login_Request = 94;
int Create_Group = 104;
int Add_Group_Member = 105;
int Kickoff_Group_Member = 106;
int Quit_Group = 107;
int Dismiss_Group = 108;
int Transfer_Group_Owner = 109;
int Change_Group_Name = 110;;
int Modify_Group_Alias = 111;
int Change_Group_Portrait = 112;
int Change_Group_Mute = 113;
int Change_Group_JoinType = 114;
int Change_Group_PrivateChat = 115;
int Change_Group_Searchable = 116;
int Set_Group_Manager = 117;
int Mute_Group_Member = 118;
int Allow_Group_Member = 119;
int Kickoff_Group_Member_Visible_Notification = 120;
int Quit_Group_Visible_Notification = 121;
int Modify_Group_Extra = 122;
int Modify_Group_Member_Extra = 123;
}
public interface MessagePersistFlag {
int NOT_PERSIST = 0;
int PERSIST = 1;
int PERSIST_AND_COUNT = 3;
int TRANSPARENT = 4;
}
public interface MessageMediaType {
int GENERAL = 0;
int IMAGE = 1;
int VOICE = 2;
int VIDEO = 3;
int FILE = 4;
int PORTRAIT = 5;
int FAVORITE = 6;
int STICKER = 7;
int MOMENTS = 8;
}
//ModifyGroupInfoRequest -> type
@@ -120,6 +173,7 @@ public class ProtoConstants {
int Modify_Channel_Secret = 4;
int Modify_Channel_Callback = 5;
int Modify_Channel_OnlyCallback = 6;
int Modify_Channel_Menu = 7;
}
//Channel -> status
@@ -129,7 +183,7 @@ public class ProtoConstants {
//第3位表示是否允许给非订阅用户发送消息
//第4位表示是否私有,不可以被用户搜索和主动订阅
//第6位表示是否删除
//第8位表示是否是全局频道,全局频道没有订阅关系,会发送给系统内所有成员。
//第8位表示是否是全局频道,全局频道没有订阅关系,会发送给系统内所有成员。可以给非订阅用户单独发消息。
public interface ChannelState {
int Channel_State_Mask_FullInfo = 0x01;
int Channel_State_Mask_Unsubscribed_User_Access = 0x02;
@@ -230,6 +284,12 @@ public class ProtoConstants {
Request_From_Channel;
}
public interface ApplicationType {
int ApplicationType_Robot = 0;
int ApplicationType_Channel = 1;
int ApplicationType_Admin = 2;
}
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;
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -6,7 +6,7 @@
<!--<relativePath>../pom.xml</relativePath>-->
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.80</version>
<version>0.92</version>
</parent>
<artifactId>distribution</artifactId>
@@ -51,7 +51,7 @@
<!--指定"git.properties"文件的存放路径(相对于${project.basedir}的一个路径);-->
<generateGitPropertiesFilename>src/main/resources/git.properties</generateGitPropertiesFilename>
<!--".git"文件夹未找到时,构建是否失败;若设置true,则构建失败;若设置false,则跳过执行该目标;默认值:true;-->
<failOnNoGitDirectory>true</failOnNoGitDirectory>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<!--git描述配置,可选;由JGit提供实现;-->
<gitDescribe>
+6 -26
View File
@@ -24,6 +24,11 @@
<directory>../broker/config/i18n/</directory>
<outputDirectory>/config/i18n</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/resources/</directory>
<outputDirectory>config/</outputDirectory>
</fileSet>
</fileSets>
<files>
@@ -40,32 +45,7 @@
</file>
<file>
<source>src/main/resources/log4j2.xml</source>
<outputDirectory>config/</outputDirectory>
<destName>log4j2.xml</destName>
</file>
<file>
<source>src/main/resources/wildfirechat.conf</source>
<outputDirectory>config/</outputDirectory>
</file>
<file>
<source>src/main/resources/hazelcast.xml</source>
<outputDirectory>config/</outputDirectory>
</file>
<file>
<source>src/main/resources/c3p0-config.xml</source>
<outputDirectory>config/</outputDirectory>
</file>
<file>
<source>src/main/resources/README.txt</source>
</file>
<file>
<source>src/main/resources/git.properties</source>
<outputDirectory>config/</outputDirectory>
<source>src/main/files/README.txt</source>
</file>
<file>
@@ -10,10 +10,11 @@
#(如果您部署云服务器上或者具有独立公网出口的服务器上,请改为对应的公网IP;如果您部署在在内网环境下,在内网使用,这个地方改成内网地址)
server.ip 0.0.0.0
##原生客户端长链接端口。如果使用4层的反向代理或者类似组件,需要设置长链接保持时间为10分钟。
##原生客户端长链接端口。如果使用4层的反向代理或者类似组件,需要设置长链接保持时间为10分钟。不支持7层代理。
port 1883
##客户端短链接端口,客户端固定使用80端口,不要修改此端口。
##客户端短链接端口,客户端固定使用80端口不能修改。
##如果是国企事业单位等因为政策原因无法使用80端口,可以联系野火解决。
http_port 80
#管理端口
@@ -22,8 +23,8 @@ http.admin.port 18080
##节点ID,当集群部署时,一定不能有重复。
node_id 1
##绑定IP,保持不变即可
host 0.0.0.0
##绑定IP,不要打开,除非有特殊需求才可以打开
#host 0.0.0.0
##本地绑定端口
local_port 80
@@ -34,6 +35,7 @@ embed.db 1
## 是否自动清理历史消息记录,当为true时,IM服务会定时扫描t_messages_x和t_user_messages_x表,清除掉3年前的历史消息。
## 如果不开启自动清理,需要手动清理t_messages_x和t_user_messages_x表内的历史数据,保存数据不能超过3年。
## 如果需要消息保存更长时间,可以把临近销毁的消息转储到别的数据库,客户端在拉取不到服务器消息时,再去转储的数据库拉取。
## 使用mongodb时次开关无效(因为mongodb设置了消息过期时间,会自动清理,仅专业版支持mongodb)。
db.auto_clean_history_messages true
@@ -51,10 +53,13 @@ token.key testim
##token.expire_time 2592000000
##首次登录,是否接收之前的历史消息。
##0 不接收历史消息,只接收5分钟以内的消息,由于服务器没有保存已经收取记录,所以如果有超过5分钟之前未收取的消息也不会收取下拉;
##0 不接收历史消息,只接收${message.compensate_time_limit}毫秒以内的消息,由于服务器没有保存已经收取记录,所以如果有超过${message.compensate_time_limit}毫秒之前未收取的消息也不会收取下拉;
##1接收,会接收 message.max_queue 配置的条数的历史消息
message.roaming 0
## 消息补偿时限,当${message.roaming}为0时,会同步时限以内且小于${message.max_queue}的消息,默认时限为5分钟。当${message.roaming}为1时,会接收 message.max_queue 配置的条数的历史消息。
message.compensate_time_limit 300000
##是否开启拉取远程历史消息。如果为1,客户端在会话内如果本地消息读取完了,可以下拉继续加载在服务器上的该会话的消息;如果为0则不能。
message.remote_history_message 0
@@ -103,6 +108,14 @@ message.global_mute_exception_types 401,402,403,404,405,407,408,410,411
## 当为true时,不转发server api发送的消息;当为false时,转发server api发送的消息。
message.no_forward_admin_message false
## 消息转发功能开启时,转发信息是否带上用户clientId和平台类型。
message.forward_with_client_info false
## 机器人回调信息是否带上用户clientId和平台类型。
robot.callback_with_client_info false
## 频道回调信息是否带上用户clientId和平台类型。
channel.callback_with_client_info false
##禁止搜索用户
friend.disable_search false
@@ -113,13 +126,13 @@ friend.disable_nick_name_search false
##禁止发送好友邀请,通过server api添加好友不受此限制(force参数需要为true)
friend.disable_friend_request false
##好友请求重复发送的间隔,单位是毫秒,默认是7天,0为不限制
##好友请求重复发送的间隔,单位是毫秒,默认是7天,0为无限长期限。
friend.repeat_request_duration 604800000
##好友请求被拒绝后再次发送的间隔,单位是毫秒,默认是30天,0为不限制
##好友请求被拒绝后再次发送的间隔,单位是毫秒,默认是30天,0为不限制。不能小于friend.repeat_request_duration。
friend.reject_request_duration 2592000000
##好友请求过期时间,单位是毫秒,默认是7天,0为不限制
##好友请求过期时间,单位是毫秒,默认是7天,0为无限长期限。
friend.request_expiration_duration 604800000
##添加好友后会发送欢迎消息,比如"你们已经是好友了,可以聊天了"。这个开关控制是用旧的方式还是用新的方式。
@@ -233,6 +246,9 @@ local.media.storage.root ./media
# 建议使用false
server.multi_endpoint false
## 是否支持PC多端登陆,当server.multi_endpoint为true时,此开关无意义,当为false时,可以单独打开PC端多端登录。
server.multi_pc_endpoint false
# 多平台连接状态通知(仅当multi_endpoint为false时有效),true时移动端可以收到pc或web端登录的通知。
server.multi_platform_notification true
+1 -1
View File
@@ -12,7 +12,7 @@
<artifactId>wildfirechat-parent</artifactId>
<packaging>pom</packaging>
<version>0.80</version>
<version>0.92</version>
<name>Wildfire Chat</name>
<description>Wildfire Chat Server</description>
<inceptionYear>2019</inceptionYear>
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.80</version>
<version>0.92</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -15,7 +15,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
<version>2.8.9</version>
</dependency>
<dependency>
+1 -1
View File
@@ -9,7 +9,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
<version>2.8.9</version>
</dependency>
<dependency>
@@ -4,33 +4,37 @@ import cn.wildfirechat.common.APIPath;
import cn.wildfirechat.pojos.*;
import cn.wildfirechat.sdk.model.IMResult;
import cn.wildfirechat.sdk.utilities.ChannelHttpUtils;
import org.apache.commons.codec.digest.DigestUtils;
import java.util.List;
import static cn.wildfirechat.proto.ProtoConstants.ApplicationType.ApplicationType_Channel;
import static cn.wildfirechat.proto.ProtoConstants.ApplicationType.ApplicationType_Robot;
//仅专业版支持,社区版不支持
public class ChannelServiceApi {
private final ChannelHttpUtils httpUtils;
private final ChannelHttpUtils channelHttpUtils;
public ChannelServiceApi(String imurl, String channelId, String secret) {
httpUtils = new ChannelHttpUtils(imurl, channelId, secret);
channelHttpUtils = new ChannelHttpUtils(imurl, channelId, secret);
}
public IMResult<InputOutputUserInfo> getUserInfo(String userId) throws Exception {
String path = APIPath.Channel_User_Info;
InputGetUserInfo getUserInfo = new InputGetUserInfo(userId, null, null);
return httpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
return channelHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
}
public IMResult<InputOutputUserInfo> getUserInfoByName(String userName) throws Exception {
String path = APIPath.Channel_User_Info;
InputGetUserInfo getUserInfo = new InputGetUserInfo(null, userName, null);
return httpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
return channelHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
}
public IMResult<InputOutputUserInfo> getUserInfoByMobile(String mobile) throws Exception {
String path = APIPath.Channel_User_Info;
InputGetUserInfo getUserInfo = new InputGetUserInfo(null, null, mobile);
return httpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
return channelHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
}
public IMResult<Void> modifyChannelInfo(/*ProtoConstants.ModifyChannelInfoType*/int type, String value) throws Exception {
@@ -38,12 +42,12 @@ public class ChannelServiceApi {
InputModifyChannelInfo modifyChannelInfo = new InputModifyChannelInfo();
modifyChannelInfo.setType(type);
modifyChannelInfo.setValue(value);
return httpUtils.httpJsonPost(path, modifyChannelInfo, Void.class);
return channelHttpUtils.httpJsonPost(path, modifyChannelInfo, Void.class);
}
public IMResult<OutputGetChannelInfo> getChannelInfo() throws Exception {
String path = APIPath.Channel_Get_Profile;
return httpUtils.httpJsonPost(path, null, OutputGetChannelInfo.class);
return channelHttpUtils.httpJsonPost(path, null, OutputGetChannelInfo.class);
}
public IMResult<SendMessageResult> sendMessage(int line, List<String> targets, MessagePayload payload) throws Exception {
@@ -52,7 +56,7 @@ public class ChannelServiceApi {
messageData.setLine(0);
messageData.setTargets(targets);
messageData.setPayload(payload);
return httpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
return channelHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
}
public IMResult<Void> subscribe(String userId) throws Exception {
@@ -60,7 +64,7 @@ public class ChannelServiceApi {
InputChannelSubscribe input = new InputChannelSubscribe();
input.setTarget(userId);
input.setSubscribe(1);
return httpUtils.httpJsonPost(path, input, Void.class);
return channelHttpUtils.httpJsonPost(path, input, Void.class);
}
public IMResult<Void> unsubscribe(String userId) throws Exception {
@@ -68,12 +72,33 @@ public class ChannelServiceApi {
InputChannelSubscribe input = new InputChannelSubscribe();
input.setTarget(userId);
input.setSubscribe(0);
return httpUtils.httpJsonPost(path, input, Void.class);
return channelHttpUtils.httpJsonPost(path, input, Void.class);
}
public IMResult<OutputStringList> getSubscriberList() throws Exception {
String path = APIPath.Channel_Subscriber_List;
return httpUtils.httpJsonPost(path, null, OutputStringList.class);
return channelHttpUtils.httpJsonPost(path, null, OutputStringList.class);
}
public IMResult<OutputApplicationUserInfo> applicationGetUserInfo(String authCode) throws Exception {
String path = APIPath.Channel_Application_Get_UserInfo;
InputApplicationGetUserInfo input = new InputApplicationGetUserInfo();
input.setAuthCode(authCode);
return channelHttpUtils.httpJsonPost(path, input, OutputApplicationUserInfo.class);
}
public OutputApplicationConfigData getApplicationSignature() {
int nonce = (int)(Math.random() * 100000 + 3);
long timestamp = System.currentTimeMillis()/1000;
String str = nonce + "|" + channelHttpUtils.getChannelId() + "|" + timestamp + "|" + channelHttpUtils.getChannelSecret();
String sign = DigestUtils.sha1Hex(str);
OutputApplicationConfigData configData = new OutputApplicationConfigData();
configData.setAppId(channelHttpUtils.getChannelId());
configData.setAppType(ApplicationType_Channel);
configData.setTimestamp(timestamp);
configData.setNonceStr(nonce+"");
configData.setSignature(sign);
return configData;
}
}

Some files were not shown because too many files have changed in this diff Show More