update 发送文件优化
This commit is contained in:
@@ -174,6 +174,8 @@ public class WeworkMessageBean {
|
|||||||
public String extraText;
|
public String extraText;
|
||||||
//接收消息类型
|
//接收消息类型
|
||||||
public Integer textType;
|
public Integer textType;
|
||||||
|
//最大尝试次数
|
||||||
|
public Integer maxRetryCount;
|
||||||
|
|
||||||
//群名
|
//群名
|
||||||
public String groupName;
|
public String groupName;
|
||||||
|
|||||||
@@ -334,7 +334,8 @@ object WeworkController {
|
|||||||
message.fileUrl,
|
message.fileUrl,
|
||||||
message.fileBase64,
|
message.fileBase64,
|
||||||
message.fileType,
|
message.fileType,
|
||||||
message.extraText
|
message.extraText,
|
||||||
|
message.maxRetryCount
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -549,8 +549,10 @@ object WeworkOperationImpl {
|
|||||||
fileUrl: String?,
|
fileUrl: String?,
|
||||||
fileBase64: String?,
|
fileBase64: String?,
|
||||||
fileType: String,
|
fileType: String,
|
||||||
extraText: String? = null
|
extraText: String? = null,
|
||||||
|
maxRetryCount: Int? = null
|
||||||
): Boolean {
|
): Boolean {
|
||||||
|
val retryCount = maxRetryCount ?: 1
|
||||||
val startTime = System.currentTimeMillis()
|
val startTime = System.currentTimeMillis()
|
||||||
if (!PermissionUtils.isGrantedDrawOverlays()) {
|
if (!PermissionUtils.isGrantedDrawOverlays()) {
|
||||||
LogUtils.e("未打开悬浮窗权限")
|
LogUtils.e("未打开悬浮窗权限")
|
||||||
@@ -594,13 +596,16 @@ object WeworkOperationImpl {
|
|||||||
}
|
}
|
||||||
currentTime = System.currentTimeMillis()
|
currentTime = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
if (relaySelectTarget(titleList, extraText, timeout = 10000)) {
|
if (Random().nextBoolean() && relaySelectTarget(titleList, extraText, timeout = 10000)) {
|
||||||
val stayButton = AccessibilityUtil.findOneByText(getRoot(), "留在企业微信")
|
val stayButton = AccessibilityUtil.findOneByText(getRoot(), "留在企业微信")
|
||||||
AccessibilityUtil.performClick(stayButton)
|
AccessibilityUtil.performClick(stayButton)
|
||||||
uploadCommandResult(message, ExecCallbackBean.SUCCESS, "", startTime)
|
uploadCommandResult(message, ExecCallbackBean.SUCCESS, "", startTime)
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("文件转发失败: $objectName")
|
LogUtils.e("文件转发失败: $objectName")
|
||||||
|
if (retryCount > 0) {
|
||||||
|
return pushFile(message, titleList, objectName, fileUrl, fileBase64, fileType, extraText, retryCount - 1)
|
||||||
|
}
|
||||||
uploadCommandResult(
|
uploadCommandResult(
|
||||||
message,
|
message,
|
||||||
ExecCallbackBean.ERROR_RELAY,
|
ExecCallbackBean.ERROR_RELAY,
|
||||||
@@ -611,6 +616,9 @@ object WeworkOperationImpl {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("文件存储本地失败 $filePath")
|
LogUtils.e("文件存储本地失败 $filePath")
|
||||||
|
if (retryCount > 0) {
|
||||||
|
return pushFile(message, titleList, objectName, fileUrl, fileBase64, fileType, extraText, retryCount - 1)
|
||||||
|
}
|
||||||
uploadCommandResult(
|
uploadCommandResult(
|
||||||
message,
|
message,
|
||||||
ExecCallbackBean.ERROR_FILE_STORAGE,
|
ExecCallbackBean.ERROR_FILE_STORAGE,
|
||||||
@@ -621,6 +629,9 @@ object WeworkOperationImpl {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("文件下载失败")
|
LogUtils.e("文件下载失败")
|
||||||
|
if (retryCount > 0) {
|
||||||
|
return pushFile(message, titleList, objectName, fileUrl, fileBase64, fileType, extraText, retryCount - 1)
|
||||||
|
}
|
||||||
uploadCommandResult(
|
uploadCommandResult(
|
||||||
message,
|
message,
|
||||||
ExecCallbackBean.ERROR_FILE_DOWNLOAD,
|
ExecCallbackBean.ERROR_FILE_DOWNLOAD,
|
||||||
@@ -668,6 +679,9 @@ object WeworkOperationImpl {
|
|||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("文件转发失败: $objectName")
|
LogUtils.e("文件转发失败: $objectName")
|
||||||
|
if (retryCount > 0) {
|
||||||
|
return pushFile(message, titleList, objectName, fileUrl, fileBase64, fileType, extraText, retryCount - 1)
|
||||||
|
}
|
||||||
uploadCommandResult(
|
uploadCommandResult(
|
||||||
message,
|
message,
|
||||||
ExecCallbackBean.ERROR_RELAY,
|
ExecCallbackBean.ERROR_RELAY,
|
||||||
@@ -678,6 +692,9 @@ object WeworkOperationImpl {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("文件存储本地失败 $filePath")
|
LogUtils.e("文件存储本地失败 $filePath")
|
||||||
|
if (retryCount > 0) {
|
||||||
|
return pushFile(message, titleList, objectName, fileUrl, fileBase64, fileType, extraText, retryCount - 1)
|
||||||
|
}
|
||||||
uploadCommandResult(
|
uploadCommandResult(
|
||||||
message,
|
message,
|
||||||
ExecCallbackBean.ERROR_FILE_STORAGE,
|
ExecCallbackBean.ERROR_FILE_STORAGE,
|
||||||
@@ -687,6 +704,10 @@ object WeworkOperationImpl {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
LogUtils.e("未找到文件资源参数")
|
||||||
|
if (retryCount > 0) {
|
||||||
|
return pushFile(message, titleList, objectName, fileUrl, fileBase64, fileType, extraText, retryCount - 1)
|
||||||
|
}
|
||||||
uploadCommandResult(
|
uploadCommandResult(
|
||||||
message,
|
message,
|
||||||
ExecCallbackBean.ERROR_ILLEGAL_DATA,
|
ExecCallbackBean.ERROR_ILLEGAL_DATA,
|
||||||
|
|||||||
Reference in New Issue
Block a user