Skip to content

Commit

Permalink
update 群信息更新时保存到通讯录
Browse files Browse the repository at this point in the history
  • Loading branch information
gallonyin committed Jun 23, 2023
1 parent 3692579 commit 7b11e86
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/yameida/worktool/service/MyLooper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 修改群公告 选填
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -292,7 +293,7 @@ object WeworkOperationImpl {
/**
* 进入群聊并修改群配置
* 群名称、群公告、拉人、踢人、群备注、群模板
* @see WeworkMessageBean.INTO_GROUP_AND_CONFIG
* @see WeworkMessageBean.UPDATE_GROUP
* @param groupName 待修改的群
* @param newGroupName 修改群名 选填
* @param newGroupAnnouncement 修改群公告 选填
Expand All @@ -302,7 +303,7 @@ object WeworkOperationImpl {
* @param showMessageHistory 拉人是否附带历史记录 选填
* @param removeList 移除群成员名称列表/踢人 选填
*/
fun intoGroupAndConfig(
fun updateGroup(
message: WeworkMessageBean,
groupName: String,
newGroupName: String?,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

}

0 comments on commit 7b11e86

Please sign in to comment.