Implement comprehensive notification system for LittleShop
- Add admin PWA push notifications for order management - Integrate TeleBot customer messaging service - Add push notification endpoints and VAPID key support - Implement order status notifications throughout workflow - Add notification UI components in admin panel - Create TeleBotMessagingService for customer updates - Add WebPush configuration to appsettings - Fix compilation issues (BotStatus, BotContacts DbSet) - Add comprehensive testing documentation Features: - Real-time admin notifications for new orders and status changes - Customer order progress updates via TeleBot - Graceful failure handling for notification services - Test endpoints for notification system validation 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -11,10 +11,12 @@ namespace LittleShop.Controllers;
|
||||
public class PushNotificationController : ControllerBase
|
||||
{
|
||||
private readonly IPushNotificationService _pushNotificationService;
|
||||
private readonly ITeleBotMessagingService _teleBotMessagingService;
|
||||
|
||||
public PushNotificationController(IPushNotificationService pushNotificationService)
|
||||
public PushNotificationController(IPushNotificationService pushNotificationService, ITeleBotMessagingService teleBotMessagingService)
|
||||
{
|
||||
_pushNotificationService = pushNotificationService;
|
||||
_teleBotMessagingService = teleBotMessagingService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -238,9 +240,63 @@ public class PushNotificationController : ControllerBase
|
||||
return StatusCode(500, new { error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get TeleBot service status
|
||||
/// </summary>
|
||||
[HttpGet("telebot/status")]
|
||||
[Authorize(AuthenticationSchemes = "Cookies", Roles = "Admin")]
|
||||
public async Task<IActionResult> GetTeleBotStatus()
|
||||
{
|
||||
try
|
||||
{
|
||||
var isAvailable = await _teleBotMessagingService.IsAvailableAsync();
|
||||
return Ok(new
|
||||
{
|
||||
available = isAvailable,
|
||||
message = isAvailable ? "TeleBot service is available" : "TeleBot service is not available"
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, new { error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send test message to TeleBot customer
|
||||
/// </summary>
|
||||
[HttpPost("telebot/test")]
|
||||
[Authorize(AuthenticationSchemes = "Cookies", Roles = "Admin")]
|
||||
public async Task<IActionResult> SendTeleBotTestMessage([FromBody] TeleBotTestMessageDto testDto)
|
||||
{
|
||||
try
|
||||
{
|
||||
var success = await _teleBotMessagingService.SendTestMessageAsync(testDto.CustomerId, testDto.Message);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return Ok(new { message = "TeleBot test message sent successfully" });
|
||||
}
|
||||
else
|
||||
{
|
||||
return StatusCode(500, new { error = "Failed to send TeleBot test message. Check TeleBot service status." });
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, new { error = ex.Message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class UnsubscribeDto
|
||||
{
|
||||
public string Endpoint { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class TeleBotTestMessageDto
|
||||
{
|
||||
public Guid CustomerId { get; set; }
|
||||
public string Message { get; set; } = "This is a test message from LittleShop admin!";
|
||||
}
|
||||
Reference in New Issue
Block a user