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
3c32cadc
Commit
3c32cadc
authored
May 17, 2022
by
罗长华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复群设置后没有下发事件的问题
parent
e89daacc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
42 deletions
+49
-42
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+49
-42
No files found.
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
3c32cadc
...
@@ -1082,12 +1082,13 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -1082,12 +1082,13 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
throw
new
BusinessException
(
"群不存在"
);
throw
new
BusinessException
(
"群不存在"
);
}
}
return
this
.
groupChatSetting
(
imApplication
,
currentClient
,
group
,
param
);
this
.
groupChatSetting
(
imApplication
,
currentClient
,
group
,
param
);
afterGroupSetting
(
imApplication
,
currentClient
,
group
,
param
);
return
true
;
}
}
@Override
@Override
public
Boolean
groupChatSettingForSdk
(
GroupChatSettingParam
param
)
{
public
Boolean
groupChatSettingForSdk
(
GroupChatSettingParam
param
)
{
ImClient
operatorClient
=
imClientService
.
getCacheImClient
(
SecurityUtils
.
getCurrentAppId
(),
param
.
getOperatorClientId
());
ImClient
operatorClient
=
imClientService
.
getCacheImClient
(
SecurityUtils
.
getCurrentAppId
(),
param
.
getOperatorClientId
());
ImApplication
imApplication
=
contextService
.
getImApplicationIfNotNullOrThrow
(
operatorClient
.
getFkAppid
());
ImApplication
imApplication
=
contextService
.
getImApplicationIfNotNullOrThrow
(
operatorClient
.
getFkAppid
());
ImConversation
group
=
getOne
(
Wrappers
.<
ImConversation
>
lambdaQuery
().
eq
(
ImConversation:
:
getFkAppid
,
SecurityUtils
.
getCurrentAppId
()).
eq
(
ImConversation:
:
getId
,
param
.
getGroupId
()));
ImConversation
group
=
getOne
(
Wrappers
.<
ImConversation
>
lambdaQuery
().
eq
(
ImConversation:
:
getFkAppid
,
SecurityUtils
.
getCurrentAppId
()).
eq
(
ImConversation:
:
getId
,
param
.
getGroupId
()));
...
@@ -1096,8 +1097,52 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -1096,8 +1097,52 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
throw
new
BusinessException
(
"群不存在"
);
throw
new
BusinessException
(
"群不存在"
);
}
}
return
this
.
groupChatSetting
(
imApplication
,
operatorClient
,
group
,
param
);
this
.
groupChatSetting
(
imApplication
,
operatorClient
,
group
,
param
);
afterGroupSetting
(
imApplication
,
operatorClient
,
group
,
param
);
return
true
;
}
/**
* 群消息设置后的事件
* @Author luozh
* @Date 2022年05月17日 12:01:48
* @param application
* @param operatorClient
* @param group
* @param param
* @Return
*/
private
void
afterGroupSetting
(
ImApplication
application
,
ImClient
operatorClient
,
ImConversation
group
,
GroupChatSettingParam
param
)
{
// 删除redis中该会话的缓存
deleteCacheImConversationById
(
group
.
getId
());
// 下发事件
GroupChatSettingTypeEnum
type
=
param
.
getType
();
// 消息内容
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
content
.
put
(
"operator"
,
operatorClient
.
getClientId
());
switch
(
type
)
{
case
NAME:
content
.
put
(
"name"
,
param
.
getName
());
break
;
case
HEAD_PORTRAIT:
content
.
put
(
"headPortrait"
,
param
.
getHeadPortrait
());
break
;
default
:
break
;
}
// 查询该会话所有成员
List
<
ImConversationMembers
>
membersList
=
imConversationMembersService
.
list
(
new
QueryWrapper
<
ImConversationMembers
>().
lambda
().
eq
(
ImConversationMembers:
:
getFkAppid
,
application
.
getId
())
.
eq
(
ImConversationMembers:
:
getFkConversationId
,
group
.
getId
()).
ne
(
ImConversationMembers:
:
getFkClientId
,
operatorClient
.
getId
()));
// 发送群聊配置变化消息
MsgTypeEnum
msgType
=
getMsgType
(
type
,
param
.
getOn
());
if
(!
membersList
.
isEmpty
())
{
// 保存事件消息
ImMessage
imMessage
=
MessageBuilder
.
buildEventMessage
(
msgType
,
application
,
operatorClient
,
group
,
JsonUtils
.
encodeJson
(
content
));
imMessageService
.
save
(
imMessage
);
// 发送消息至群成员
sendMsgToMembers
(
group
,
membersList
,
operatorClient
,
imMessage
,
content
);
}
}
}
private
Boolean
groupChatSetting
(
ImApplication
application
,
ImClient
operatorClient
,
ImConversation
conversation
,
GroupChatSettingParam
param
)
{
private
Boolean
groupChatSetting
(
ImApplication
application
,
ImClient
operatorClient
,
ImConversation
conversation
,
GroupChatSettingParam
param
)
{
...
@@ -1118,7 +1163,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -1118,7 +1163,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
conversation
.
setHeadPortrait
(
param
.
getHeadPortrait
());
conversation
.
setHeadPortrait
(
param
.
getHeadPortrait
());
break
;
break
;
case
NAME:
case
NAME:
conversation
.
setName
(
param
.
get
HeadPortrait
());
conversation
.
setName
(
param
.
get
Name
());
break
;
break
;
case
MUTED:
case
MUTED:
int
muted
=
1
;
int
muted
=
1
;
...
@@ -1132,18 +1177,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -1132,18 +1177,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
}
}
// 更新会话
// 更新会话
boolean
success
=
updateById
(
conversation
);
boolean
success
=
updateById
(
conversation
);
if
(
success
)
{
// 删除redis中该会话的缓存
deleteCacheImConversationById
(
conversation
.
getId
());
// 查询该会话所有成员
List
<
ImConversationMembers
>
membersList
=
imConversationMembersService
.
list
(
new
QueryWrapper
<
ImConversationMembers
>().
lambda
().
eq
(
ImConversationMembers:
:
getFkAppid
,
application
.
getId
())
.
eq
(
ImConversationMembers:
:
getFkConversationId
,
conversation
.
getId
()).
ne
(
ImConversationMembers:
:
getFkClientId
,
operatorClient
.
getId
()));
// 发送群聊配置变化消息
MsgTypeEnum
msgType
=
getMsgType
(
typeEnum
,
param
.
getOn
());
sendConversationSettingChangeMsg
(
application
,
operatorClient
,
conversation
,
msgType
);
}
return
success
;
return
success
;
}
}
...
@@ -1397,32 +1430,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -1397,32 +1430,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
}
}
/**
/**
* 发送会话配置变更事件
*
* @param application 应用
* @param currentClient 当前client信息
* @param conversation 会话
* @param msgType 消息类型
* @Author luozh
* @Date 2022年04月27日 01:52:54
* @Return
*/
private
void
sendConversationSettingChangeMsg
(
ImApplication
application
,
ImClient
currentClient
,
ImConversation
conversation
,
MsgTypeEnum
msgType
)
{
// 查询该会话所有成员
List
<
ImConversationMembers
>
membersList
=
imConversationMembersService
.
list
(
new
QueryWrapper
<
ImConversationMembers
>().
lambda
().
eq
(
ImConversationMembers:
:
getFkAppid
,
currentClient
.
getFkAppid
()).
eq
(
ImConversationMembers:
:
getFkConversationId
,
conversation
.
getId
()).
ne
(
ImConversationMembers:
:
getFkClientId
,
currentClient
.
getId
()));
if
(!
membersList
.
isEmpty
())
{
// 消息内容
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
content
.
put
(
"operator"
,
currentClient
.
getClientId
());
// 保存事件消息
ImMessage
imMessage
=
MessageBuilder
.
buildEventMessage
(
msgType
,
application
,
currentClient
,
conversation
,
JsonUtils
.
encodeJson
(
content
));
imMessageService
.
save
(
imMessage
);
// 发送消息至群成员
sendMsgToMembers
(
conversation
,
membersList
,
currentClient
,
imMessage
,
content
);
}
}
/**
* 发送会话事件消息至群成员列表
* 发送会话事件消息至群成员列表
*
*
* @param conversation 会话
* @param conversation 会话
...
...
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