@@ -1,6 +1,5 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace ROLAC.API.Services.Notifications;
|
||||
|
||||
@@ -11,12 +10,12 @@ public sealed class LineMessageChannel : IMessageChannel
|
||||
private const string ReplyUrl = "https://api.line.me/v2/bot/message/reply";
|
||||
|
||||
private readonly HttpClient _http;
|
||||
private readonly LineOptions _options;
|
||||
private readonly INotificationSettingsService _settings;
|
||||
|
||||
public LineMessageChannel(HttpClient http, IOptions<LineOptions> options)
|
||||
public LineMessageChannel(HttpClient http, INotificationSettingsService settings)
|
||||
{
|
||||
_http = http;
|
||||
_options = options.Value;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public Task<MessageSendResult> PushToUserAsync(string externalId, string text, CancellationToken ct = default)
|
||||
@@ -36,7 +35,8 @@ public sealed class LineMessageChannel : IMessageChannel
|
||||
{
|
||||
Content = JsonContent.Create(payload),
|
||||
};
|
||||
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _options.ChannelAccessToken);
|
||||
request.Headers.Authorization =
|
||||
new AuthenticationHeaderValue("Bearer", _settings.GetLine().ChannelAccessToken);
|
||||
|
||||
using var response = await _http.SendAsync(request, ct);
|
||||
if (response.IsSuccessStatusCode) return new MessageSendResult(true, null);
|
||||
|
||||
Reference in New Issue
Block a user