update 群信息更新时保存到通讯录

This commit is contained in:
gallonyin
2023-06-23 23:01:36 +08:00
parent 3692579ff3
commit 7b11e863a0
4 changed files with 30 additions and 10 deletions

View File

@@ -23,7 +23,7 @@ public class WeworkMessageBean {
* 在房间内指定回复消息 REPLY_MESSAGE
* 在房间内转发消息 RELAY_MESSAGE
* 创建群 INIT_GROUP
* 进入群聊并修改群配置 INTO_GROUP_AND_CONFIG
* 进入群聊并修改群配置 UPDATE_GROUP
* 推送微盘图片 PUSH_MICRO_DISK_IMAGE
* 推送微盘文件 PUSH_MICRO_DISK_FILE
* 推送小程序 PUSH_MICROPROGRAM
@@ -70,7 +70,7 @@ public class WeworkMessageBean {
public static final int REPLY_MESSAGE = 204;
public static final int RELAY_MESSAGE = 205;
public static final int INIT_GROUP = 206;
public static final int INTO_GROUP_AND_CONFIG = 207;
public static final int UPDATE_GROUP = 207;
public static final int PUSH_MICRO_DISK_IMAGE = 208;
public static final int PUSH_MICRO_DISK_FILE = 209;
public static final int PUSH_MICROPROGRAM = 210;

View File

@@ -148,8 +148,8 @@ object MyLooper {
WeworkMessageBean.INIT_GROUP -> {
WeworkController.initGroup(message)
}
WeworkMessageBean.INTO_GROUP_AND_CONFIG -> {
WeworkController.intoGroupAndConfig(message)
WeworkMessageBean.UPDATE_GROUP -> {
WeworkController.updateGroup(message)
}
WeworkMessageBean.PUSH_MICRO_DISK_IMAGE -> {
WeworkController.pushMicroDiskImage(message)

View File

@@ -148,7 +148,7 @@ object WeworkController {
/**
* 进入群聊并修改群配置
* 群名称、群公告、拉人、踢人、群备注、群模板
* @see WeworkMessageBean.INTO_GROUP_AND_CONFIG
* @see WeworkMessageBean.UPDATE_GROUP
* @param message#groupName 待修改的群
* @param message#newGroupName 修改群名 选填
* @param message#newGroupAnnouncement 修改群公告 选填
@@ -159,9 +159,9 @@ object WeworkController {
* @param message#removeList 移除群成员名称列表/踢人 选填
*/
@RequestMapping
fun intoGroupAndConfig(message: WeworkMessageBean): Boolean {
LogUtils.d("intoGroupAndConfig(): ${message.groupName} ${message.newGroupName} ${message.newGroupAnnouncement} ${message.selectList} ${message.showMessageHistory} ${message.removeList} ${message.groupRemark} ${message.groupTemplate}")
return WeworkOperationImpl.intoGroupAndConfig(
fun updateGroup(message: WeworkMessageBean): Boolean {
LogUtils.d("updateGroup(): ${message.groupName} ${message.newGroupName} ${message.newGroupAnnouncement} ${message.selectList} ${message.showMessageHistory} ${message.removeList} ${message.groupRemark} ${message.groupTemplate}")
return WeworkOperationImpl.updateGroup(
message,
message.groupName,
message.newGroupName,

View File

@@ -284,6 +284,7 @@ object WeworkOperationImpl {
uploadCommandResult(message, ExecCallbackBean.ERROR_GROUP_TEMPLATE, "创建群成功 群改名成功 群拉人成功 群公告成功 群备注成功 群模板失败", startTime, listOf(), listOf(groupName))
return false
}
saveToContract()
getGroupQrcode(groupName, groupRemark)
uploadCommandResult(message, ExecCallbackBean.SUCCESS, "", startTime, listOf(groupName), listOf())
return true
@@ -292,7 +293,7 @@ object WeworkOperationImpl {
/**
* 进入群聊并修改群配置
* 群名称、群公告、拉人、踢人、群备注、群模板
* @see WeworkMessageBean.INTO_GROUP_AND_CONFIG
* @see WeworkMessageBean.UPDATE_GROUP
* @param groupName 待修改的群
* @param newGroupName 修改群名 选填
* @param newGroupAnnouncement 修改群公告 选填
@@ -302,7 +303,7 @@ object WeworkOperationImpl {
* @param showMessageHistory 拉人是否附带历史记录 选填
* @param removeList 移除群成员名称列表/踢人 选填
*/
fun intoGroupAndConfig(
fun updateGroup(
message: WeworkMessageBean,
groupName: String,
newGroupName: String?,
@@ -342,6 +343,7 @@ object WeworkOperationImpl {
uploadCommandResult(message, ExecCallbackBean.ERROR_GROUP_TEMPLATE, "进入房间成功 群改名成功 群拉人成功 群公告成功 群备注成功 群模板失败", startTime, listOf(), listOf(groupName))
return false
}
saveToContract()
getGroupQrcode(groupName, groupRemark)
uploadCommandResult(message, ExecCallbackBean.SUCCESS, "", startTime, listOf(groupName), listOf())
return true
@@ -2687,4 +2689,22 @@ object WeworkOperationImpl {
return false
}
/**
* 保存到通讯录
*/
private fun saveToContract(): Boolean {
if (WeworkRoomUtil.intoGroupManager()) {
AccessibilityUtil.findOneByText(getRoot(), "全部群成员", "微信用户创建") ?: return false
LogUtils.d("保存到通讯录")
val tvAddressFlag = AccessibilityUtil.scrollAndFindByText(WeworkController.weworkService, getRoot(), "保存到通讯录", exact = true)
val tvAddress = AccessibilityUtil.findBackNode(tvAddressFlag, minChildCount = 1)
val addressDesc = AccessibilityUtil.findOnceByDesc(tvAddress, "false", "true", exact = true)
if (addressDesc?.contentDescription == "false") {
LogUtils.d("未保存到通讯录 进行保存...")
AccessibilityUtil.performClick(addressDesc)
}
}
return true
}
}