feat: publish dbussmsforward refactor
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
using Tmds.DBus.Protocol;
|
||||
|
||||
namespace DbusSmsForward.SettingModel;
|
||||
|
||||
public sealed class appsettingsModel
|
||||
{
|
||||
public LegacyAppSettings appSettings { get; set; } = new();
|
||||
}
|
||||
|
||||
public sealed class LegacyAppsettingsModel
|
||||
{
|
||||
public LegacyAppSettings appSettings { get; set; } = new();
|
||||
}
|
||||
|
||||
public sealed class LegacyAppSettings
|
||||
{
|
||||
public EmailConfig EmailConfig { get; set; } = new();
|
||||
public PushPlusConfig PushPlusConfig { get; set; } = new();
|
||||
public DingTalkConfig DingTalkConfig { get; set; } = new();
|
||||
public BarkConfig BarkConfig { get; set; } = new();
|
||||
public WeComApplicationConfig WeComApplicationConfig { get; set; } = new();
|
||||
public TelegramBotConfig TGBotConfig { get; set; } = new();
|
||||
public ShellConfig ShellConfig { get; set; } = new();
|
||||
public string SmsCodeKey { get; set; } = "验证码±verification±code±认证±代码±随机码";
|
||||
public string ForwardIgnoreStorageType { get; set; } = "sm";
|
||||
public string DeviceName { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class DbusSmsForwardOptions
|
||||
{
|
||||
public DaemonConfig Daemon { get; set; } = new();
|
||||
public ModemConfig Modem { get; set; } = new();
|
||||
public ForwardingConfig Forwarding { get; set; } = new();
|
||||
public NotificationChannels Notifications { get; set; } = new();
|
||||
public LegacyCompatibilityConfig LegacyCompatibility { get; set; } = new();
|
||||
}
|
||||
|
||||
public sealed class DaemonConfig
|
||||
{
|
||||
public string Mode { get; set; } = "forward";
|
||||
public bool ValidateOnStartup { get; set; } = true;
|
||||
public bool UseSystemd { get; set; } = true;
|
||||
public string LogLevel { get; set; } = "Information";
|
||||
}
|
||||
|
||||
public sealed class ModemConfig
|
||||
{
|
||||
public string SystemBusAddress { get; set; } = Address.System ?? string.Empty;
|
||||
public string ServiceName { get; set; } = "org.freedesktop.ModemManager1";
|
||||
public string ManagerObjectPath { get; set; } = "/org/freedesktop/ModemManager1";
|
||||
public bool ScanDevicesOnStartup { get; set; } = true;
|
||||
}
|
||||
|
||||
public sealed class ForwardingConfig
|
||||
{
|
||||
public string DeviceName { get; set; } = string.Empty;
|
||||
public string SmsCodeKey { get; set; } = "验证码±verification±code±认证±代码±随机码";
|
||||
public string IgnoreStorageType { get; set; } = "sm";
|
||||
public bool EnableSmsCodeExtraction { get; set; } = true;
|
||||
public string[] EnabledChannels { get; set; } = [];
|
||||
}
|
||||
|
||||
public sealed class NotificationChannels
|
||||
{
|
||||
public EmailConfig Email { get; set; } = new();
|
||||
public PushPlusConfig PushPlus { get; set; } = new();
|
||||
public DingTalkConfig DingTalk { get; set; } = new();
|
||||
public BarkConfig Bark { get; set; } = new();
|
||||
public WeComApplicationConfig WeComApplication { get; set; } = new();
|
||||
public TelegramBotConfig TelegramBot { get; set; } = new();
|
||||
public ShellConfig Shell { get; set; } = new();
|
||||
public AutmanPushConfig AutmanPush { get; set; } = new();
|
||||
}
|
||||
|
||||
public sealed class LegacyCompatibilityConfig
|
||||
{
|
||||
public bool EnableLegacyCliFlags { get; set; } = true;
|
||||
public bool WriteLegacyAppSettings { get; set; } = false;
|
||||
}
|
||||
|
||||
public class ChannelConfigBase
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
public int TimeoutSeconds { get; set; } = 15;
|
||||
public bool SkipTlsValidation { get; set; }
|
||||
}
|
||||
|
||||
public sealed class EmailConfig : ChannelConfigBase
|
||||
{
|
||||
public string SmtpHost { get; set; } = string.Empty;
|
||||
public int SmtpPort { get; set; } = 465;
|
||||
public bool EnableSsl { get; set; } = true;
|
||||
public string EmailKey { get; set; } = string.Empty;
|
||||
public string SendEmail { get; set; } = string.Empty;
|
||||
public string ReceiveEmail { get; set; } = string.Empty;
|
||||
|
||||
public string smtpHost { get => SmtpHost; set => SmtpHost = value; }
|
||||
public string smtpPort { get => SmtpPort.ToString(); set => SmtpPort = int.TryParse(value, out int parsed) ? parsed : 465; }
|
||||
public string enableSSL { get => EnableSsl.ToString().ToLowerInvariant(); set => EnableSsl = bool.TryParse(value, out bool parsed) && parsed; }
|
||||
public string emailKey { get => EmailKey; set => EmailKey = value; }
|
||||
public string sendEmail { get => SendEmail; set => SendEmail = value; }
|
||||
public string reciveEmail { get => ReceiveEmail; set => ReceiveEmail = value; }
|
||||
}
|
||||
|
||||
public sealed class PushPlusConfig : ChannelConfigBase
|
||||
{
|
||||
public string Token { get; set; } = string.Empty;
|
||||
public string Endpoint { get; set; } = "https://www.pushplus.plus/send";
|
||||
|
||||
public string pushPlusToken { get => Token; set => Token = value; }
|
||||
}
|
||||
|
||||
public sealed class DingTalkConfig : ChannelConfigBase
|
||||
{
|
||||
public string AccessToken { get; set; } = string.Empty;
|
||||
public string Secret { get; set; } = string.Empty;
|
||||
public string Endpoint { get; set; } = "https://oapi.dingtalk.com/robot/send";
|
||||
|
||||
public string DingTalkAccessToken { get => AccessToken; set => AccessToken = value; }
|
||||
public string DingTalkSecret { get => Secret; set => Secret = value; }
|
||||
}
|
||||
|
||||
public sealed class BarkConfig : ChannelConfigBase
|
||||
{
|
||||
public string ServerUrl { get; set; } = string.Empty;
|
||||
public string BarkKey { get; set; } = string.Empty;
|
||||
|
||||
public string BarkUrl { get => ServerUrl; set => ServerUrl = value; }
|
||||
}
|
||||
|
||||
public sealed class WeComApplicationConfig : ChannelConfigBase
|
||||
{
|
||||
public string CorpId { get; set; } = string.Empty;
|
||||
public string AgentId { get; set; } = string.Empty;
|
||||
public string ApplicationSecret { get; set; } = string.Empty;
|
||||
|
||||
public string WeChatQYID { get => CorpId; set => CorpId = value; }
|
||||
public string WeChatQYApplicationID { get => AgentId; set => AgentId = value; }
|
||||
public string WeChatQYApplicationSecret { get => ApplicationSecret; set => ApplicationSecret = value; }
|
||||
}
|
||||
|
||||
public sealed class TelegramBotConfig : ChannelConfigBase
|
||||
{
|
||||
public bool EnableCustomApi { get; set; }
|
||||
public string CustomApi { get; set; } = string.Empty;
|
||||
public string BotToken { get; set; } = string.Empty;
|
||||
public string ChatId { get; set; } = string.Empty;
|
||||
|
||||
public string IsEnableCustomTGBotApi { get => EnableCustomApi.ToString().ToLowerInvariant(); set => EnableCustomApi = bool.TryParse(value, out bool parsed) && parsed; }
|
||||
public string CustomTGBotApi { get => CustomApi; set => CustomApi = value; }
|
||||
public string TGBotToken { get => BotToken; set => BotToken = value; }
|
||||
public string TGBotChatID { get => ChatId; set => ChatId = value; }
|
||||
}
|
||||
|
||||
public sealed class ShellConfig : ChannelConfigBase
|
||||
{
|
||||
public string ShellPath { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class AutmanPushConfig : ChannelConfigBase
|
||||
{
|
||||
public string ApiUrl { get; set; } = string.Empty;
|
||||
public string AccessToken { get; set; } = string.Empty;
|
||||
public string Method { get; set; } = "POST";
|
||||
}
|
||||
Reference in New Issue
Block a user