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
ae35ab17
Commit
ae35ab17
authored
May 11, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
群拓展属性
parent
ceea5097
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
21 deletions
+44
-21
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+44
-21
No files found.
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
ae35ab17
...
...
@@ -766,10 +766,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
imMessage
.
setSystemFlag
(
false
);
imMessage
.
setSendStatus
(
2
);
imMessage
.
setFkConversationId
(
conversationId
);
Long
appId
=
currentClient
.
getFkAppid
();
String
sender
=
currentClient
.
getClientId
();
// 遍历发送给已在群内的成员
for
(
String
key
:
chatRoomMembers
.
keySet
())
{
Long
fkClientId
=
Long
.
valueOf
(
key
.
split
(
RedisUtils
.
SPLIT
)[
0
]);
...
...
@@ -1051,30 +1047,24 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
public
void
saveOrUpdateAttr
(
ImConversationAttrUpdate
imConversationAttrUpdate
)
{
// 获取当前client
ImClient
currentClient
=
contextService
.
getImClientIfNotNullOrThrow
();
// 根据appId查询application
ImApplication
imApplication
=
contextService
.
getImApplicationIfNotNullOrThrow
(
currentClient
.
getFkAppid
());
ImConversation
imConversationById
=
imConversationService
.
getById
(
imConversationAttrUpdate
.
getConversationId
());
// 判断是否为群主
// if (imConversationById == null || !imConversationById.getCreator().equals(imClientSender.getId())) {
// return ApiResult.result(false);
// }
imConversationById
.
setAttributes
(
imConversationAttrUpdate
.
getAttributes
());
boolean
b
=
imConversationService
.
updateById
(
imConversationById
);
// 删除redis中该会话的缓存
deleteCacheImConversationById
(
imConversationAttrUpdate
.
getConversationId
());
if
(
b
)
{
if
(
ChatTypeEnum
.
CHAT_ROOM
.
getCode
().
equals
(
imConversationById
.
getChatType
()))
{
// 聊天室事件发送逻辑
chatRoomAttrChanged
(
imConversationById
,
currentClient
);
return
;
}
// 查询该会话所有成员
List
<
ImConversationMembers
>
membersList
=
imConversationMembersService
.
list
(
new
QueryWrapper
<
ImConversationMembers
>().
lambda
()
.
eq
(
ImConversationMembers:
:
getFkAppid
,
imApplication
.
getI
d
())
.
eq
(
ImConversationMembers:
:
getFkAppid
,
currentClient
.
getFkAppi
d
())
.
eq
(
ImConversationMembers:
:
getFkConversationId
,
imConversationAttrUpdate
.
getConversationId
())
.
ne
(
ImConversationMembers:
:
getFkClientId
,
currentClient
.
getId
())
);
imConversationById
.
setAttributes
(
imConversationAttrUpdate
.
getAttributes
());
boolean
b
=
imConversationService
.
updateById
(
imConversationById
);
// 删除redis中该会话的缓存
deleteCacheImConversationById
(
imConversationAttrUpdate
.
getConversationId
());
if
(
b
)
{
// ws下发拓展字段变动事件
HashMap
<
String
,
String
>
content
=
Maps
.
newHashMap
();
content
.
put
(
"attributes"
,
imConversationById
.
getAttributes
());
...
...
@@ -1090,7 +1080,40 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
}
else
{
throw
new
BusinessException
(
"修改错误"
);
}
}
/**
* 解散聊天室
* @param imConversation
* @param currentClient
*/
private
void
chatRoomAttrChanged
(
ImConversation
imConversation
,
ImClient
currentClient
)
{
Map
<
String
,
String
>
chatRoomMembers
=
chatRoomCacheManager
.
findOnlineClientsByChatRoomId
(
imConversation
.
getId
());
if
(
chatRoomMembers
.
isEmpty
())
{
throw
new
BusinessException
(
"聊天室成员列为空"
);
}
// 保存事件消息
ImMessage
imMessage
=
new
ImMessage
();
HashMap
<
String
,
String
>
content
=
Maps
.
newHashMap
();
content
.
put
(
"attributes"
,
imConversation
.
getAttributes
());
imMessage
.
setContent
(
JsonUtils
.
encodeJson
(
content
));
imMessage
.
setId
(
SnowflakeUtil
.
getId
());
imMessage
.
setMsgType
(
MsgTypeEnum
.
CONVERSATION_EXPAND_FIELD_CHANGE
.
getUriCode
());
imMessage
.
setCreateTime
(
new
Date
());
imMessage
.
setFkAppid
(
currentClient
.
getFkAppid
());
imMessage
.
setSender
(
currentClient
.
getId
());
imMessage
.
setWithdraw
(
false
);
imMessage
.
setEvent
(
true
);
imMessage
.
setSystemFlag
(
false
);
imMessage
.
setSendStatus
(
2
);
imMessage
.
setFkConversationId
(
imConversation
.
getId
());
// 遍历发送给已在群内的成员
for
(
String
key
:
chatRoomMembers
.
keySet
())
{
Long
fkClientId
=
Long
.
valueOf
(
key
.
split
(
RedisUtils
.
SPLIT
)[
0
]);
sendEventMsgToMember
(
imConversation
.
getId
(),
currentClient
.
getFkAppid
(),
currentClient
.
getClientId
(),
fkClientId
,
null
,
imMessage
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
...
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