Document models
This commit is contained in:
parent
a0767fb566
commit
518191f5c6
|
|
@ -2,8 +2,18 @@
|
||||||
|
|
||||||
namespace TwilioSMSReceiver.Common.Interfaces
|
namespace TwilioSMSReceiver.Common.Interfaces
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main code where we send all SMS data and translate it accordingly
|
||||||
|
/// </summary>
|
||||||
public interface IMessageHandler
|
public interface IMessageHandler
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main relay SMS code
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">Parsed model of the SMS Message</param>
|
||||||
|
/// <returns>True if it succeeded, false if it didn't relay successfully</returns>
|
||||||
|
/// <exception cref="NotImplementedException">Returned if the code is loaded, but not actually implemented</exception>
|
||||||
|
/// <exception cref="Exception">All generic exceptions are returned here</exception>
|
||||||
public Task<bool> RelaySms(SMSModel model);
|
public Task<bool> RelaySms(SMSModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,38 @@ using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace TwilioSMSReceiver.Data.Models
|
namespace TwilioSMSReceiver.Data.Models
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The SMS Model
|
||||||
|
/// </summary>
|
||||||
public class SMSModel
|
public class SMSModel
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Where the SMS/MMS Message was directed to
|
||||||
|
/// </summary>
|
||||||
[Required]
|
[Required]
|
||||||
public string ReceivedNumber { get; set; }
|
public string ReceivedNumber { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Where the SMS/MMS Message was sent from
|
||||||
|
/// </summary>
|
||||||
[Required]
|
[Required]
|
||||||
public string SenderNumber { get; set; }
|
public string SenderNumber { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// When the message was received
|
||||||
|
/// </summary>
|
||||||
public DateTime TimeReceived { get; set; }
|
public DateTime TimeReceived { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Contents of the SMS message
|
||||||
|
/// </summary>
|
||||||
public string? MessageContents { get; set; }
|
public string? MessageContents { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// MMS Content if any
|
||||||
|
/// </summary>
|
||||||
public ICollection<MMSModel> MMSContent { get; set; }
|
public ICollection<MMSModel> MMSContent { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Has this message been processed - currently always false as we don't have background processing just yet
|
||||||
|
/// </summary>
|
||||||
public bool IsForwardedYet { get; set; }
|
public bool IsForwardedYet { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,14 +45,23 @@ namespace TwilioSMSReceiver.Data.Models
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Foreign key of the SMS Message
|
||||||
|
/// </summary>
|
||||||
public int SMSModelId { get; set; }
|
public int SMSModelId { get; set; }
|
||||||
public SMSModel ParentSMSMessage { get; set; }
|
public SMSModel ParentSMSMessage { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// URL of the MMS Data
|
||||||
|
/// </summary>
|
||||||
public string OriginalMMSData { get; set; }
|
public string OriginalMMSData { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MSTeamsWebHook
|
public class MSTeamsWebHook
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Where we sent the message to
|
||||||
|
/// </summary>
|
||||||
public string WebHookUri { get; set; }
|
public string WebHookUri { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,33 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
using TwilioSMSReceiver.Data.Models;
|
using TwilioSMSReceiver.Data.Models;
|
||||||
|
|
||||||
namespace TwilioSMSReceiver.Data
|
namespace TwilioSMSReceiver.Data
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The database context
|
||||||
|
/// </summary>
|
||||||
public class SMSDbCtx : DbContext
|
public class SMSDbCtx : DbContext
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main DB Context base constructor for this database context
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options">The usual options for EF Core Database if called outside of a DI Scope</param>
|
||||||
|
[Obsolete("Don't call this directly unless you're calling it from EF Core")]
|
||||||
public SMSDbCtx(DbContextOptions options) : base(options)
|
public SMSDbCtx(DbContextOptions options) : base(options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Received SMS Messages
|
||||||
|
/// </summary>
|
||||||
public DbSet<SMSModel> SMSMessages { get; set; }
|
public DbSet<SMSModel> SMSMessages { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Received MMS Message data
|
||||||
|
/// </summary>
|
||||||
public DbSet<MMSModel> MMSMessages { get; set; }
|
public DbSet<MMSModel> MMSMessages { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Teams WebHooks we should be spamming to
|
||||||
|
/// </summary>
|
||||||
public DbSet<MSTeamsWebHook> MSTeamsWebHooks { get; set; }
|
public DbSet<MSTeamsWebHook> MSTeamsWebHooks { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue