mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-05 16:02:17 +00:00
- 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
41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
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)
|
||
}
|