33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|