feat: publish dbussmsforward refactor
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using DbusSmsForward.Helper;
|
||||
using DbusSmsForward.ProcessSmsContent;
|
||||
using DbusSmsForward.Services;
|
||||
using DbusSmsForward.SettingModel;
|
||||
using DbusSmsForward.SMSModel;
|
||||
using System.Web;
|
||||
|
||||
namespace DbusSmsForward.Notifications;
|
||||
|
||||
public sealed class BarkNotificationSender(DbusSmsForwardOptions options) : NotificationSenderBase("bark")
|
||||
{
|
||||
private readonly BarkConfig _config = options.Notifications.Bark;
|
||||
|
||||
public override bool IsEnabled => _config.Enabled && !string.IsNullOrWhiteSpace(_config.ServerUrl) && !string.IsNullOrWhiteSpace(_config.BarkKey);
|
||||
|
||||
public override async Task SendAsync(SmsContentModel sms, string body, string deviceName, CancellationToken cancellationToken)
|
||||
{
|
||||
SmsCodeModel code = NotificationContentBuilder.ExtractCode(options, sms);
|
||||
string url = $"{_config.ServerUrl.TrimEnd('/')}/{_config.BarkKey}/{HttpUtility.UrlEncode(body)}?group={HttpUtility.UrlEncode(sms.TelNumber)}&title={HttpUtility.UrlEncode(BuildTitle(sms.TelNumber, code.CodeValue))}";
|
||||
if (!string.IsNullOrWhiteSpace(code.CodeValue))
|
||||
{
|
||||
url += $"&autoCopy=1©={HttpUtility.UrlEncode(code.CodeValue)}";
|
||||
}
|
||||
|
||||
await HttpHelper.HttpGetAsync(url, _config.SkipTlsValidation, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user