Duansg opened a new pull request, #4192:
URL: https://github.com/apache/hertzbeat/pull/4192

   ## What's changed?
   
   - Closes #1347 (notice side)
   - Complements #4081 / #4069 by adding the timezone-offset that those did not 
cover
   
   
   When a notification rule (or a cyclic silence rule) is configured with an 
active time window, the window is stored as `ZonedDateTime` (`periodStart` / 
`periodEnd`).
   
   Two defects made the window match incorrectly:
     
   1. **Notice side was never fixed.** 
`NoticeConfigServiceImpl#getReceiverFilterRule` detected a cross-midnight 
window by comparing the **full timestamps** (`periodStart.isAfter(periodEnd)`), 
including the date part. Because the UI may persist `periodStart` and 
`periodEnd` on different dates, a normal window such as `08:30–22:30` could be 
misdetected as cross-midnight, so notifications were sent **outside** the 
configured window (e.g. at 03:00). This is exactly what #1347 reports.
   
   
   2. **Timezone offset was ignored on both sides.** Both notice and 
cyclic-silence matching converted the stored value via `.toLocalTime()` 
directly, discarding the offset. When the stored offset differs from the server 
zone, the comparison runs against the wrong wall-clock time. PR #4081 fixed the 
cyclic-silence *time-of-day* logic but did not touch the timezone offset (and 
#4069 explicitly excluded it), and never touched the notice path at all.
   
   ## What this PR does
   - Rewrite the notice period filter in 
`NoticeConfigServiceImpl#getReceiverFilterRule`
   - Normalize the stored `ZonedDateTime` to the server zone 
   - Boundaries are now inclusive (`!isBefore` / `!isAfter`) so a time exactly 
on the edge of the window is treated as inside it.
   
   ## Checklist
   
   - [x]  I have read the [Contributing 
Guide](https://hertzbeat.apache.org/docs/community/code_style_and_quality_guide)
   - [ ]  I have written the necessary doc or comment.
   - [x]  I have added the necessary unit tests and all cases have passed.
   
   ## Add or update API
   
   - [ ] I have added the necessary [e2e 
tests](https://github.com/apache/hertzbeat/tree/master/e2e) and all cases have 
passed.
   
   > Server Time
   <img width="1187" height="104" alt="capcap-260711-153930" 
src="https://github.com/user-attachments/assets/92decf92-b4c2-43a2-8f75-a3429df6cc90";
 />
   
   > Notification Policy
   <img width="799" height="389" alt="capcap-260711-154526" 
src="https://github.com/user-attachments/assets/4bdc1199-9977-41fc-8ea5-0fdd85abefe2";
 />
   
   > Alarms
   <img width="1363" height="422" alt="capcap-260711-154640" 
src="https://github.com/user-attachments/assets/9044990e-4c8b-4818-87b6-e875a96b40d0";
 />
   
   > DingTalk Notification
   <img width="815" height="724" alt="capcap-260711-154648" 
src="https://github.com/user-attachments/assets/e525acdd-339e-473f-9798-892c900ee05d";
 />


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to