Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
1fd92d46
Commit
1fd92d46
authored
Jun 09, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
成员不存在,不能创建会话
parent
c25d594a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
16 deletions
+32
-16
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+11
-0
common/src/main/java/com/wecloud/im/tillo/netty/handler/NettyApiRequest.java
+16
-8
config/src/main/resources/static/i18n/messages_zh_CN.properties
+1
-8
framework/src/main/java/io/geekidea/springbootplus/framework/common/api/ApiCode.java
+4
-0
No files found.
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
1fd92d46
...
@@ -76,6 +76,17 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -76,6 +76,17 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
ImClient
client
=
imClientService
.
getClient
();
ImClient
client
=
imClientService
.
getClient
();
// 成员不存在,不能创建会话
for
(
String
id
:
imConversationCreate
.
getClientIds
())
{
ImClient
client2
=
imClientService
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
eq
(
ImClient:
:
getFkAppid
,
client
.
getFkAppid
())
.
eq
(
ImClient:
:
getClientId
,
id
));
if
(
client2
==
null
)
{
log
.
info
(
" 成员不存在,不能创建会话 client2 == null"
);
return
ApiResult
.
result
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
}
// 判断是否已经存在会话
// 判断是否已经存在会话
// 两个用户如果已经创建过会话,不能重复创建会话
// 两个用户如果已经创建过会话,不能重复创建会话
if
(
imConversationCreate
.
getClientIds
().
size
()
==
1
)
{
if
(
imConversationCreate
.
getClientIds
().
size
()
==
1
)
{
...
...
common/src/main/java/com/wecloud/im/tillo/netty/handler/NettyApiRequest.java
View file @
1fd92d46
...
@@ -3,11 +3,14 @@ package com.wecloud.im.tillo.netty.handler;
...
@@ -3,11 +3,14 @@ package com.wecloud.im.tillo.netty.handler;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.auth0.jwt.interfaces.DecodedJWT
;
import
com.auth0.jwt.interfaces.DecodedJWT
;
import
com.fasterxml.jackson.databind.json.JsonMapper
;
import
com.wecloud.im.tillo.app_ws.WsHandler
;
import
com.wecloud.im.tillo.app_ws.WsHandler
;
import
com.wecloud.im.tillo.app_ws.model.WsConstants
;
import
com.wecloud.im.tillo.app_ws.model.WsConstants
;
import
com.wecloud.im.tillo.app_ws.service.MangerChannelService
;
import
com.wecloud.im.tillo.app_ws.service.MangerChannelService
;
import
com.wecloud.im.tillo.app_ws.utils.FullHttpRequestUtils
;
import
com.wecloud.im.tillo.app_ws.utils.FullHttpRequestUtils
;
import
io.geekidea.springbootplus.config.constant.CommonConstant
;
import
io.geekidea.springbootplus.config.constant.CommonConstant
;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.shiro.jwt.JwtToken
;
import
io.geekidea.springbootplus.framework.shiro.jwt.JwtToken
;
import
io.geekidea.springbootplus.framework.shiro.service.ShiroLoginService
;
import
io.geekidea.springbootplus.framework.shiro.service.ShiroLoginService
;
import
io.geekidea.springbootplus.framework.shiro.util.JwtUtil
;
import
io.geekidea.springbootplus.framework.shiro.util.JwtUtil
;
...
@@ -17,7 +20,6 @@ import io.netty.handler.codec.http.FullHttpRequest;
...
@@ -17,7 +20,6 @@ import io.netty.handler.codec.http.FullHttpRequest;
import
io.netty.handler.codec.http.HttpResponseStatus
;
import
io.netty.handler.codec.http.HttpResponseStatus
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.authc.AuthenticationException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -54,8 +56,7 @@ public class NettyApiRequest {
...
@@ -54,8 +56,7 @@ public class NettyApiRequest {
*/
*/
public
void
handle
(
ChannelHandlerContext
ctx
,
Object
msg
,
FullHttpRequest
httpRequest
)
throws
Exception
{
public
void
handle
(
ChannelHandlerContext
ctx
,
Object
msg
,
FullHttpRequest
httpRequest
)
throws
Exception
{
if
(!(
msg
instanceof
FullHttpRequest
))
{
if
(!(
msg
instanceof
FullHttpRequest
))
{
// String context = JsonUtil.obj2Json(ResultModel.error(ResultStatus.REQUEST_ERROR));
String
context
=
new
JsonMapper
().
writeValueAsString
(
ApiResult
.
fail
());
String
context
=
"JsonUtil.obj2Json(ResultModel.error(ResultStatus.REQUEST_ERROR))"
;
FullHttpRequestUtils
.
send
(
ctx
,
context
,
HttpResponseStatus
.
OK
);
FullHttpRequestUtils
.
send
(
ctx
,
context
,
HttpResponseStatus
.
OK
);
return
;
return
;
}
}
...
@@ -81,7 +82,6 @@ public class NettyApiRequest {
...
@@ -81,7 +82,6 @@ public class NettyApiRequest {
private
void
initWs
(
ChannelHandlerContext
ctx
,
FullHttpRequest
httpRequest
)
throws
Exception
{
private
void
initWs
(
ChannelHandlerContext
ctx
,
FullHttpRequest
httpRequest
)
throws
Exception
{
Map
<
String
,
String
>
paramMap
=
FullHttpRequestUtils
.
parameterParse
(
httpRequest
);
Map
<
String
,
String
>
paramMap
=
FullHttpRequestUtils
.
parameterParse
(
httpRequest
);
String
token
=
paramMap
.
get
(
WsConstants
.
TOKEN
);
String
token
=
paramMap
.
get
(
WsConstants
.
TOKEN
);
// String deviceId = paramMap.get(RequestHeaderConstants.DEVICE_ID);
DecodedJWT
jwtInfo
=
JwtUtil
.
getJwtInfo
(
token
);
DecodedJWT
jwtInfo
=
JwtUtil
.
getJwtInfo
(
token
);
String
payload
=
jwtInfo
.
getPayload
();
String
payload
=
jwtInfo
.
getPayload
();
...
@@ -92,22 +92,30 @@ public class NettyApiRequest {
...
@@ -92,22 +92,30 @@ public class NettyApiRequest {
String
clientId
=
(
String
)
jsonObject
.
get
(
CommonConstant
.
CLIENT_ID
);
String
clientId
=
(
String
)
jsonObject
.
get
(
CommonConstant
.
CLIENT_ID
);
if
(
StringUtils
.
isBlank
(
token
))
{
if
(
StringUtils
.
isBlank
(
token
))
{
throw
new
AuthenticationException
(
"token不能为空"
);
String
context
=
new
JsonMapper
().
writeValueAsString
(
ApiResult
.
result
(
ApiCode
.
FAIL
,
"token不能为空"
,
(
Object
)
null
));
FullHttpRequestUtils
.
send
(
ctx
,
context
,
HttpResponseStatus
.
OK
);
return
;
}
}
if
(
JwtUtil
.
isExpired
(
token
))
{
if
(
JwtUtil
.
isExpired
(
token
))
{
throw
new
AuthenticationException
(
"JWT Token已过期,token:"
+
token
);
String
context
=
new
JsonMapper
().
writeValueAsString
(
ApiResult
.
result
(
ApiCode
.
FAIL
,
"JWT Token已过期,token"
,
(
Object
)
null
));
FullHttpRequestUtils
.
send
(
ctx
,
context
,
HttpResponseStatus
.
OK
);
return
;
}
}
// 验签token
// 验签token
JwtToken
jwtToken
=
shiroLoginService
.
getTJwtTokenForRedis
(
token
);
JwtToken
jwtToken
=
shiroLoginService
.
getTJwtTokenForRedis
(
token
);
if
(
jwtToken
==
null
)
{
if
(
jwtToken
==
null
)
{
log
.
error
(
"jwtToken == null ,token和redis不一致, clientId:"
+
clientId
+
",token:"
+
token
);
log
.
info
(
"jwtToken == null ,token和redis不一致, clientId:"
+
clientId
+
",token:"
+
token
);
String
context
=
new
JsonMapper
().
writeValueAsString
(
ApiResult
.
result
(
ApiCode
.
FAIL
,
"jwtToken == null ,token和redis不一致"
,
(
Object
)
null
));
FullHttpRequestUtils
.
send
(
ctx
,
context
,
HttpResponseStatus
.
OK
);
return
;
return
;
}
}
if
((!
jwtToken
.
getClientId
().
equals
(
clientId
))
||
(!
jwtToken
.
getAppKey
().
equals
(
appKey
)))
{
if
((!
jwtToken
.
getClientId
().
equals
(
clientId
))
||
(!
jwtToken
.
getAppKey
().
equals
(
appKey
)))
{
log
.
error
(
"clientId appKey 不一致"
);
String
context
=
new
JsonMapper
().
writeValueAsString
(
ApiResult
.
result
(
ApiCode
.
FAIL
,
"clientId appKey 不一致"
,
(
Object
)
null
));
FullHttpRequestUtils
.
send
(
ctx
,
context
,
HttpResponseStatus
.
OK
);
log
.
info
(
"clientId appKey 不一致"
);
return
;
return
;
}
}
...
...
config/src/main/resources/static/i18n/messages_zh_CN.properties
View file @
1fd92d46
...
@@ -75,12 +75,5 @@ api.response.code.JWTDECODE_EXCEPTION=Token解析异常
...
@@ -75,12 +75,5 @@ api.response.code.JWTDECODE_EXCEPTION=Token解析异常
#* 默认的异常处理
#* 默认的异常处理
#*/
#*/
api.response.code.HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION
=
默认的异常处理
api.response.code.HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION
=
默认的异常处理
api.response.code.user.PWD_OR_USERNAME_ERROR
=
账号或密码错误
api.response.code.user.SMS_CODE_ERROR
=
旧手机号验证码错误
api.response.code.user.SMS_CODE_REGIST_ERROR
=
验证码错误
api.response.code.user.USER_NOT_FOUND
=
用户不存在
api.response.code.user.USER_WECHAT_CODE
=
微信code错误
api.response.code.user.SMS_CODE_ERROR_NEW
=
新手机号验证码错误
api.response.code.user.UPDATA_PHONE_USE
=
绑定手机已经被使用
api.response.code.user.PHONE_IS_ME
=
手机号不能为自己
api.response.code.REPETITION_CONVERSATION
=
已有会话,不能重复创建会话
api.response.code.REPETITION_CONVERSATION
=
已有会话,不能重复创建会话
api.response.code.CLIENT_NOT_FOUNT
=
成员不存在,不能创建会话
framework/src/main/java/io/geekidea/springbootplus/framework/common/api/ApiCode.java
View file @
1fd92d46
...
@@ -109,6 +109,10 @@ public enum ApiCode {
...
@@ -109,6 +109,10 @@ public enum ApiCode {
*/
*/
REPETITION_CONVERSATION
(
6010
,
"api.response.code.REPETITION_CONVERSATION"
),
REPETITION_CONVERSATION
(
6010
,
"api.response.code.REPETITION_CONVERSATION"
),
/**
* 成员不存在,不能创建会话
*/
CLIENT_NOT_FOUNT
(
6011
,
"api.response.code.CLIENT_NOT_FOUNT"
),
;
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment