feat: publish dbussmsforward refactor
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using DbusSmsForward.Helper;
|
||||
using DbusSmsForward.Services;
|
||||
using DbusSmsForward.SettingModel;
|
||||
using DbusSmsForward.SMSModel;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace DbusSmsForward.Notifications;
|
||||
|
||||
public sealed class AutmanPushNotificationSender(DbusSmsForwardOptions options) : NotificationSenderBase("autmanpush")
|
||||
{
|
||||
private readonly AutmanPushConfig _config = options.Notifications.AutmanPush;
|
||||
|
||||
public override bool IsEnabled => _config.Enabled && !string.IsNullOrWhiteSpace(_config.ApiUrl);
|
||||
|
||||
public override async Task SendAsync(SmsContentModel sms, string body, string deviceName, CancellationToken cancellationToken)
|
||||
{
|
||||
JsonObject payload = new()
|
||||
{
|
||||
["title"] = BuildTitle(sms.TelNumber, string.Empty),
|
||||
["content"] = body,
|
||||
["deviceName"] = deviceName,
|
||||
["phoneNumber"] = sms.TelNumber
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_config.AccessToken))
|
||||
{
|
||||
payload["accessToken"] = _config.AccessToken;
|
||||
}
|
||||
|
||||
await HttpHelper.PostAsync(_config.ApiUrl, payload, _config.SkipTlsValidation, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user