feat(notifications): central SMS config + nullable recipient contact (S2)
Implement the central ConfigurationDatabase side of SMS notifications: - NotificationConfiguration: EmailAddress now nullable (SMS-only recipients carry a PhoneNumber, no email); add PhoneNumber nvarchar(32); add SmsConfigurationConfiguration (AuthToken sized as the encrypted column, mirroring SmtpConfiguration.Credentials; timeout/retry mapped REQUIRED for ctor-default round-trip fidelity). - ScadaBridgeDbContext: add SmsConfigurations DbSet, encrypt AuthToken at rest via EncryptedStringConverter, and cover SmsConfiguration in the schema-only secret-write guard. - NotificationRepository: implement the four INotificationRepository SMS-config methods (resolves the 4x CS0535), mirroring the SMTP methods' stage-only / separate-SaveChangesAsync discipline. - Migration AddSmsNotifications: idempotent (guarded) ALTER EmailAddress nullable, ADD PhoneNumber, CREATE SmsConfigurations; Down reverses cleanly (backfills NULL emails before restoring NOT NULL).
This commit is contained in:
+16
@@ -88,6 +88,22 @@ public class NotificationRepository : INotificationRepository
|
||||
if (entity != null) _context.Set<SmtpConfiguration>().Remove(entity);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<SmsConfiguration?> GetSmsConfigurationAsync(CancellationToken cancellationToken = default)
|
||||
=> await _context.Set<SmsConfiguration>().FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IReadOnlyList<SmsConfiguration>> GetAllSmsConfigurationsAsync(CancellationToken cancellationToken = default)
|
||||
=> await _context.Set<SmsConfiguration>().ToListAsync(cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task AddSmsConfigurationAsync(SmsConfiguration smsConfiguration, CancellationToken cancellationToken = default)
|
||||
=> await _context.Set<SmsConfiguration>().AddAsync(smsConfiguration, cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task UpdateSmsConfigurationAsync(SmsConfiguration smsConfiguration, CancellationToken cancellationToken = default)
|
||||
{ _context.Set<SmsConfiguration>().Update(smsConfiguration); return Task.CompletedTask; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
=> await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
Reference in New Issue
Block a user