@@ -2,7 +2,6 @@ using System.Text;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ROLAC.API.DTOs.Notifications;
|
||||
using ROLAC.API.Services.Notifications;
|
||||
|
||||
@@ -22,14 +21,14 @@ public sealed class LineWebhookController : ControllerBase
|
||||
|
||||
private readonly ILineNotificationService _line;
|
||||
private readonly IMessageChannel _channel;
|
||||
private readonly LineOptions _options;
|
||||
private readonly INotificationSettingsService _settings;
|
||||
|
||||
public LineWebhookController(
|
||||
ILineNotificationService line, IMessageChannel channel, IOptions<LineOptions> options)
|
||||
ILineNotificationService line, IMessageChannel channel, INotificationSettingsService settings)
|
||||
{
|
||||
_line = line;
|
||||
_channel = channel;
|
||||
_options = options.Value;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
[HttpPost("webhook")]
|
||||
@@ -40,7 +39,7 @@ public sealed class LineWebhookController : ControllerBase
|
||||
var rawBody = await reader.ReadToEndAsync(ct);
|
||||
var signature = Request.Headers["X-Line-Signature"].FirstOrDefault();
|
||||
|
||||
if (!LineSignature.IsValid(_options.ChannelSecret, Encoding.UTF8.GetBytes(rawBody), signature))
|
||||
if (!LineSignature.IsValid(_settings.GetLine().ChannelSecret, Encoding.UTF8.GetBytes(rawBody), signature))
|
||||
return BadRequest();
|
||||
|
||||
var payload = JsonSerializer.Deserialize<LineWebhookPayload>(rawBody, JsonOpts);
|
||||
|
||||
Reference in New Issue
Block a user