Commit d9f5e117 by giaogiao

Merge branch '1.3' of https://gitlab.aillo.cc/hewei/wecloud_im_server into 1.4_rtc

parents 61a0ab9d 9c6e3560
...@@ -30,6 +30,9 @@ docker run -p 3306:3306 --name mysql57 -v $PWD/dockerData/mysql57/data:/var/lib/ ...@@ -30,6 +30,9 @@ docker run -p 3306:3306 --name mysql57 -v $PWD/dockerData/mysql57/data:/var/lib/
--- ---
tail -f /data0/java_projects_jenkins/logs/spring-boot-plus-error.log
## 开发规范 ## 开发规范
### 关于模块 ### 关于模块
......
...@@ -65,6 +65,16 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> { ...@@ -65,6 +65,16 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
*/ */
Integer getRepetitionConversation(@Param("clientId1") Long clientId1, @Param("clientId2") Long clientId2); Integer getRepetitionConversation(@Param("clientId1") Long clientId1, @Param("clientId2") Long clientId2);
/**
* 判断重复会话中的Attributes是否一样
*
* @param clientId1
* @param clientId2
* @param attributes
* @return 大于等于1为有重复会话
*/
Long getRepetitionConversationAttributes(@Param("clientId1") Long clientId1, @Param("clientId2") Long clientId2, @Param("attributes") String attributes);
/** /**
* 查询已经存在的会话信息 * 查询已经存在的会话信息
......
...@@ -42,4 +42,12 @@ public interface ImInboxMapper extends BaseMapper<ImInbox> { ...@@ -42,4 +42,12 @@ public interface ImInboxMapper extends BaseMapper<ImInbox> {
Long updateImMsgReceivedByIds(@Param("clientId") Long clientId, @Param("msgIds") List<Long> msgIds); Long updateImMsgReceivedByIds(@Param("clientId") Long clientId, @Param("msgIds") List<Long> msgIds);
Long updateImMsgReadByIds(@Param("clientId") Long clientId, @Param("msgIds") List<Long> msgIds); Long updateImMsgReadByIds(@Param("clientId") Long clientId, @Param("msgIds") List<Long> msgIds);
/**
* 统计未读消息数量
*
* @param clientId
* @return
*/
Integer countMyNotReadCount(@Param("clientId") Long clientId);
} }
...@@ -102,5 +102,15 @@ public interface ImConversationService extends BaseService<ImConversation> { ...@@ -102,5 +102,15 @@ public interface ImConversationService extends BaseService<ImConversation> {
*/ */
Integer getRepetitionConversation(Long clientId1, Long clientId2); Integer getRepetitionConversation(Long clientId1, Long clientId2);
/**
* 判断重复会话中的Attributes是否一样
*
* @param clientId1
* @param clientId2
* @param attributes
* @return 大于等于1为有重复会话
*/
Long getRepetitionConversationAttributes(Long clientId1, Long clientId2, String attributes);
} }
...@@ -70,6 +70,14 @@ public interface ImInboxService extends BaseService<ImInbox> { ...@@ -70,6 +70,14 @@ public interface ImInboxService extends BaseService<ImInbox> {
ApiResult<Boolean> updateImMsgReceived(ImMsgReceivedStatusUpdate imMsgReceivedUpdate); ApiResult<Boolean> updateImMsgReceived(ImMsgReceivedStatusUpdate imMsgReceivedUpdate);
/** /**
* 统计未读消息数量
*
* @param clientId
* @return
*/
Integer countMyNotReadCount(Long clientId);
/**
* 消息修改为已读状态 * 消息修改为已读状态
* *
* @return * @return
......
...@@ -123,37 +123,30 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -123,37 +123,30 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
} }
} else { } else {
//创建重复会话时对比扩展字段 0不 1是 //创建重复会话时对比扩展字段 1是
if (imApplication.getContrastExtendedFieldStatus() == 1) { if (imApplication.getContrastExtendedFieldStatus() == 1) {
// 被邀请client // 被邀请client
ImClient inviteClient = imClientService.getOne(new QueryWrapper<ImClient>().lambda() ImClient inviteClient = imClientService.getOne(new QueryWrapper<ImClient>().lambda()
.eq(ImClient::getFkAppid, createClient.getFkAppid()) .eq(ImClient::getFkAppid, createClient.getFkAppid())
.eq(ImClient::getClientId, imConversationCreate.getClientIds().get(0))); .eq(ImClient::getClientId, imConversationCreate.getClientIds().get(0)));
JsonMapper jsonMapper = new JsonMapper();
String asString = jsonMapper.writeValueAsString(imConversationCreate.getAttributes());
log.info("RequestAttributes:" + asString);
// 是否存在重复会话
Integer repetitionConversation = getRepetitionConversation(createClient.getId(), inviteClient.getId());
if (repetitionConversation != 0) {
ImConversation repetitionConversationInfo = imConversationMapper.getRepetitionConversationInfo(createClient.getId(), inviteClient.getId());
log.info("出现Conversation重复");
JsonMapper jsonMapper = new JsonMapper(); Long repetitionConversation = getRepetitionConversationAttributes(createClient.getId(), inviteClient.getId(), asString);
HashMap dbAttributesMap = jsonMapper.readValue(repetitionConversationInfo.getAttributes(), HashMap.class);
log.info("DBAttributes:" + repetitionConversationInfo.getAttributes()); // 存在重复会话
log.info("RequestAttributes:" + jsonMapper.writeValueAsString(imConversationCreate.getAttributes())); if (repetitionConversation != null) {
log.info("出现Attributes重复");
ImConversationCreateVo imConversationCreateVo = new ImConversationCreateVo();
if (dbAttributesMap.equals(imConversationCreate.getAttributes())) { imConversationCreateVo.setId(repetitionConversation);
log.info("出现Attributes重复"); // 为重复
ImConversationCreateVo imConversationCreateVo = new ImConversationCreateVo(); return ApiResult.ok(imConversationCreateVo);
imConversationCreateVo.setId(repetitionConversationInfo.getId());
// 为重复
return ApiResult.ok(imConversationCreateVo);
}
} }
} }
} }
// 会话id // 会话id
...@@ -289,4 +282,9 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -289,4 +282,9 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
return imConversationMapper.getRepetitionConversation(clientId1, clientId2); return imConversationMapper.getRepetitionConversation(clientId1, clientId2);
} }
@Override
public Long getRepetitionConversationAttributes(Long clientId1, Long clientId2, String attributes) {
return imConversationMapper.getRepetitionConversationAttributes(clientId1, clientId2, attributes);
}
} }
...@@ -118,6 +118,19 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox> ...@@ -118,6 +118,19 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox>
return ApiResult.ok(); return ApiResult.ok();
} }
/**
* 统计未读消息数量
*
* @param clientId
* @return
*/
@Override
public Integer countMyNotReadCount(Long clientId) {
return imInboxMapper.countMyNotReadCount(clientId);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ApiResult<Boolean> updateImMsgRead(ImMsgReadStatusUpdate imMsgReadStatusUpdate) { public ApiResult<Boolean> updateImMsgRead(ImMsgReadStatusUpdate imMsgReadStatusUpdate) {
......
...@@ -7,6 +7,7 @@ import com.wecloud.im.entity.ImApplication; ...@@ -7,6 +7,7 @@ import com.wecloud.im.entity.ImApplication;
import com.wecloud.im.entity.ImClient; import com.wecloud.im.entity.ImClient;
import com.wecloud.im.entity.ImIosApns; import com.wecloud.im.entity.ImIosApns;
import com.wecloud.im.push.PushUtils; import com.wecloud.im.push.PushUtils;
import com.wecloud.im.service.ImInboxService;
import com.wecloud.im.service.ImIosApnsService; import com.wecloud.im.service.ImIosApnsService;
import com.wecloud.im.ws.model.request.PushModel; import com.wecloud.im.ws.model.request.PushModel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -35,6 +36,10 @@ public class SystemPush { ...@@ -35,6 +36,10 @@ public class SystemPush {
@Autowired @Autowired
private ImIosApnsService imIosApnsService; private ImIosApnsService imIosApnsService;
@Autowired
private ImInboxService imInboxService;
/** /**
* 谷歌推送地址 * 谷歌推送地址
*/ */
...@@ -50,6 +55,9 @@ public class SystemPush { ...@@ -50,6 +55,9 @@ public class SystemPush {
*/ */
private static final String PUSH_BODY = "Click to view"; private static final String PUSH_BODY = "Click to view";
private static final String title = "title";
private static final String subTitle = "subTitle";
/** /**
* 异步系统推送 * 异步系统推送
* *
...@@ -61,12 +69,12 @@ public class SystemPush { ...@@ -61,12 +69,12 @@ public class SystemPush {
PushModel pushModel = new PushModel(); PushModel pushModel = new PushModel();
if (pushMap.isEmpty()) { if (pushMap == null || pushMap.isEmpty()) {
pushModel.setTitle(PUSH_TITLE); pushModel.setTitle(PUSH_TITLE);
pushModel.setSubTitle(PUSH_BODY); pushModel.setSubTitle(PUSH_BODY);
} else { } else {
pushModel.setTitle(pushMap.get("title")); pushModel.setTitle(pushMap.get(title));
pushModel.setSubTitle(pushMap.get("subTitle")); pushModel.setSubTitle(pushMap.get(subTitle));
} }
// 校验参数 // 校验参数
...@@ -207,7 +215,8 @@ public class SystemPush { ...@@ -207,7 +215,8 @@ public class SystemPush {
String deviceToken = imClientReceiver.getDeviceToken(); String deviceToken = imClientReceiver.getDeviceToken();
String alertTitle = pushModel.getTitle(); String alertTitle = pushModel.getTitle();
String alertBody = pushModel.getSubTitle(); String alertBody = pushModel.getSubTitle();
int badge = 1; // 统计未读消息数量
int badge = imInboxService.countMyNotReadCount(imClientReceiver.getId());
String topicBundleId = apns.getBundleId(); String topicBundleId = apns.getBundleId();
String certificatePassword = apns.getPwd(); String certificatePassword = apns.getPwd();
boolean contentAvailable = false; boolean contentAvailable = false;
......
...@@ -72,6 +72,25 @@ ...@@ -72,6 +72,25 @@
) AS r1 ) AS r1
WHERE members_count = 2 WHERE members_count = 2
</select> </select>
<select id="getRepetitionConversationAttributes" resultType="java.lang.Long">
SELECT *
FROM im_conversation
WHERE id IN (
SELECT im_conversation_members.fk_conversation_id
FROM im_conversation_members
INNER JOIN (SELECT *
FROM im_conversation_members
WHERE im_conversation_members.fk_client_id = #{clientId2}) AS im_conversation_members2
ON im_conversation_members.fk_conversation_id =
im_conversation_members2.fk_conversation_id
WHERE im_conversation_members.fk_client_id = #{clientId1}
)
AND attributes = CAST(#{attributes} AS json) LIMIT 1
</select>
<select id="getRepetitionConversationInfo" resultType="com.wecloud.im.entity.ImConversation"> <select id="getRepetitionConversationInfo" resultType="com.wecloud.im.entity.ImConversation">
SELECT im_conversation.* SELECT im_conversation.*
FROM im_conversation_members FROM im_conversation_members
......
...@@ -46,5 +46,11 @@ ...@@ -46,5 +46,11 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from im_Inbox from im_Inbox
</select> </select>
<select id="countMyNotReadCount" resultType="java.lang.Integer">
SELECT COUNT(id)
FROM im_inbox
WHERE receiver = #{clientId}
AND read_msg_status = 0
</select>
</mapper> </mapper>
...@@ -19,6 +19,11 @@ spring: ...@@ -19,6 +19,11 @@ spring:
username: root username: root
password: 123 password: 123
#//测试外网
# url: jdbc:mysql://18.136.207.16:3306/wecloud_im?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
# username: web
# password: axT8knPN5hAP
# Redis配置 # Redis配置
redis: redis:
database: 0 database: 0
......
...@@ -30,9 +30,20 @@ spring: ...@@ -30,9 +30,20 @@ spring:
# port: 6379 # port: 6379
# 飞蛙 # 飞蛙
# datasource:
# url: jdbc:mysql://127.0.0.1:3306/wecloud_im?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
# username: web
# password: axT8knPN5hAP
# redis:
# database: 0
# host: 127.0.0.1
# password: JH86uc53r8Ca
# port: 6379
# 国内IM集成版
datasource: datasource:
url: jdbc:mysql://127.0.0.1:3306/wecloud_im?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true url: jdbc:mysql://127.0.0.1:3306/wecloud_im?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
username: web username: root
password: axT8knPN5hAP password: axT8knPN5hAP
redis: redis:
database: 0 database: 0
......
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl;
server_name xxx.com;
ssl_certificate ssl/_.im199.com.crt;
ssl_certificate_key ssl/_.im199.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location /api {
proxy_pass http://localhost:8082/api/;
}
location /ws {
proxy_pass http://localhost:8899/ws; # ws结尾不带"/",实际请求服务器时不会去掉"/ws"
proxy_set_header Upgrade $http_upgrade; # 升级协议头
proxy_set_header Connection upgrade; # 升级长连接协议头
}
location / {
root html;
index index.html index.htm;
}
}
\ No newline at end of file
...@@ -75,4 +75,27 @@ Invoke-RestMethod http://169.254.169.254/latest/meta-data/public-ipv4 ...@@ -75,4 +75,27 @@ Invoke-RestMethod http://169.254.169.254/latest/meta-data/public-ipv4
服务器负载均衡配置 服务器负载均衡配置
load-blance: load-blance:
服务器配置 Local,AWS,AlibabaCloud,HuaweiCloud 服务器配置 Local,AWS,AlibabaCloud,HuaweiCloud
server-type: Local server-type: Local
\ No newline at end of file
2021年09月27日17:00:50部署国内IM集成版
部署1.3 版本
| weikeyun_imapi | 121.37.208.9 | 国内IM集成版
docker run -p 6379:6379 -d --restart=always --name redis6 -v $PWD/dockerData/redis6:/data redis:6 --appendonly yes --requirepass "axT8knPN5hAP"
##mysql5.7(如果本地不开,可以连上测试环境)
### docker 安装mysql
docker run -p 3306:3306 --name mysql57 -v $PWD/dockerData/mysql57/data:/var/lib/mysql --restart always -e MYSQL_ROOT_PASSWORD=JH86uc53r8Ca -d mysql:5.7
mysql
username: root
password: axT8knPN5hAP
redis:
database: 0
host: 127.0.0.1
password: JH86uc53r8Ca
port: 6379
utf8mb4_unicode_ci
建库语句
CREATE DATABASE IF NOT EXISTS wecloud_im DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment