From fccd1be698ed6c39f5ec7ab2f5f0128357c8f6ba Mon Sep 17 00:00:00 2001 From: pppscn <35696959@qq.com> Date: Tue, 14 Jul 2026 22:56:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=85=8D=E6=89=93?= =?UTF-8?q?=E6=89=B0(=E7=A6=81=E7=94=A8=E8=BD=AC=E5=8F=91)=EF=BC=9A`?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=AE=B5`=E4=B8=8E`=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=AE=B5`=E4=B8=BA=E3=80=8C=E4=B8=8E=E3=80=8D=E5=85=B3?= =?UTF-8?q?=E7=B3=BB=EF=BC=8C=E4=B8=94=E8=87=B3=E5=B0=91=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=80=E9=A1=B9=E6=89=8D=E7=94=9F=E6=95=88=20#753?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ppps/forwarder/utils/SendUtils.kt | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/app/src/main/kotlin/cn/ppps/forwarder/utils/SendUtils.kt b/app/src/main/kotlin/cn/ppps/forwarder/utils/SendUtils.kt index c2098f14..228b991c 100644 --- a/app/src/main/kotlin/cn/ppps/forwarder/utils/SendUtils.kt +++ b/app/src/main/kotlin/cn/ppps/forwarder/utils/SendUtils.kt @@ -4,7 +4,6 @@ import android.annotation.SuppressLint import androidx.work.OneTimeWorkRequestBuilder import androidx.work.WorkManager import androidx.work.workDataOf -import com.google.gson.Gson import cn.ppps.forwarder.R import cn.ppps.forwarder.core.Core import cn.ppps.forwarder.database.entity.MsgAndLogs @@ -46,6 +45,7 @@ import cn.ppps.forwarder.utils.sender.WeworkRobotUtils import cn.ppps.forwarder.workers.SendLogicWorker import cn.ppps.forwarder.workers.SendWorker import cn.ppps.forwarder.workers.UpdateLogsWorker +import com.google.gson.Gson import com.jeremyliao.liveeventbus.LiveEventBus import com.xuexiang.xutil.XUtil import com.xuexiang.xutil.resource.ResUtils.getString @@ -98,32 +98,24 @@ object SendUtils { senderLogic(0, msgInfo, rule, senderIndex, msgId) return } - //免打扰(禁用转发)日期段 - Log.d(TAG, "silentDayOfWeek = ${rule.silentDayOfWeek}") - if (rule.silentDayOfWeek.isNotBlank()) { - val silentDayOfWeek = rule.silentDayOfWeek.split(",").mapNotNull { it.trim().toIntOrNull() } - if (silentDayOfWeek.isNotEmpty()) { - val dayOfWeek = Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - if (silentDayOfWeek.contains(dayOfWeek)) { - Log.d(TAG, "免打扰(禁用转发)日期段") - updateLogs(logId, 0, getString(R.string.silent_time_period)) - senderLogic(0, msgInfo, rule, senderIndex, msgId) - return - } - } - } - //免打扰(禁用转发)时间段 - Log.d(TAG, "silentPeriodStart = ${rule.silentPeriodStart}, silentPeriodEnd = ${rule.silentPeriodEnd}") - if (rule.silentPeriodStart != rule.silentPeriodEnd) { - val isSilentPeriod = DataProvider.isCurrentTimeInPeriod(rule.silentPeriodStart, rule.silentPeriodEnd) - if (isSilentPeriod) { + //免打扰(禁用转发):日期段 与 时间段 为「与」关系,且至少配置一项才生效 + //未配置星期视为「不限星期」,未配置时段视为「不限时段」,二者都命中才拦截 + Log.d(TAG, "silentDayOfWeek = ${rule.silentDayOfWeek}, silentPeriodStart = ${rule.silentPeriodStart}, silentPeriodEnd = ${rule.silentPeriodEnd}") + val silentDayOfWeek = rule.silentDayOfWeek.split(",").mapNotNull { it.trim().toIntOrNull() } + val dayConfigured = silentDayOfWeek.isNotEmpty() + val periodConfigured = rule.silentPeriodStart != rule.silentPeriodEnd + if (dayConfigured || periodConfigured) { + val dayMatched = !dayConfigured || silentDayOfWeek.contains(Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) + val periodMatched = !periodConfigured || DataProvider.isCurrentTimeInPeriod(rule.silentPeriodStart, rule.silentPeriodEnd) + if (dayMatched && periodMatched) { Log.d(TAG, "免打扰(禁用转发)时间段") updateLogs(logId, 0, getString(R.string.silent_time_period)) senderLogic(0, msgInfo, rule, senderIndex, msgId) return } } + when (sender.type) { TYPE_DINGTALK_GROUP_ROBOT -> { val settingVo = Gson().fromJson(sender.jsonSetting, DingtalkGroupRobotSetting::class.java)