Files
BFNOC e25e0c8074 feat(notify): name the receiving SIM and device in SMS notifications
- Pass the receiving SIM's ICCID and IMSI from cellular and VoWiFi SMS to the notifier
- Add a local line with the stored number of that SIM, or its last four ICCID digits
- Show the device name next to its ID in SMS, call and IP change notifications
- Expose the local number as local_number in webhook meta and webhook and WeCom templates
- List the new placeholder in the notification settings
- Test the number, the ICCID fallback, device names and the webhook template
2026-10-14 13:25:48 +08:00

41 lines
1.4 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package device
import "time"
// Notifier 定义了设备池需要的事件通知接口,
// 用于解耦具体的通知实现(如 Telegram 或 Webhook)
type Notifier interface {
NotifySMS(deviceID, sender, content string, timestamp time.Time)
NotifyIPRotated(deviceID, oldIP, newIP string, duration time.Duration)
NotifyRaw(msg string)
}
type SMSSourceNotifier interface {
NotifySMSWithSource(deviceID, sender, content, source string, timestamp time.Time)
}
// SMSReceiptNotifier also receives the SIM that got the message, so a
// notification can name the local number when one device switches profiles.
type SMSReceiptNotifier interface {
NotifySMSReceipt(sms InboundSMS, source string)
}
// notifySMS uses the richest interface the notifier implements. An empty
// source means cellular.
func notifySMS(notifier Notifier, sms InboundSMS, source string) {
if receipt, ok := notifier.(SMSReceiptNotifier); ok {
receipt.NotifySMSReceipt(sms, source)
return
}
if withSource, ok := notifier.(SMSSourceNotifier); ok && source != "" {
withSource.NotifySMSWithSource(sms.DeviceID, sms.Sender, sms.Content, source, sms.Time)
return
}
notifier.NotifySMS(sms.DeviceID, sms.Sender, sms.Content, sms.Time)
}
// IncomingCallNotifier is implemented by host notifiers that can surface a ring.
type IncomingCallNotifier interface {
NotifyIncomingCall(deviceID, caller, callee string)
}