feat: publish dbussmsforward refactor
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using DbusSmsForward.Helper;
|
||||
using DbusSmsForward.Notifications;
|
||||
using DbusSmsForward.ProcessSmsContent;
|
||||
using DbusSmsForward.Services;
|
||||
using DbusSmsForward.SettingModel;
|
||||
using DbusSmsForward.SMSModel;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace DbusSmsForward.Notifications;
|
||||
|
||||
public sealed class PushPlusNotificationSender(DbusSmsForwardOptions options) : NotificationSenderBase("pushplus")
|
||||
{
|
||||
private readonly PushPlusConfig _config = options.Notifications.PushPlus;
|
||||
|
||||
public override bool IsEnabled => _config.Enabled && !string.IsNullOrWhiteSpace(_config.Token);
|
||||
|
||||
public override async Task SendAsync(SmsContentModel sms, string body, string deviceName, CancellationToken cancellationToken)
|
||||
{
|
||||
SmsCodeModel code = NotificationContentBuilder.ExtractCode(options, sms);
|
||||
JsonObject payload = new()
|
||||
{
|
||||
["token"] = _config.Token,
|
||||
["title"] = BuildTitle(sms.TelNumber, code.CodeValue),
|
||||
["content"] = body,
|
||||
["topic"] = string.Empty
|
||||
};
|
||||
|
||||
await HttpHelper.PostAsync(_config.Endpoint, payload, _config.SkipTlsValidation, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user