using KristofferStrube.ActivityStreams;
using Microsoft.EntityFrameworkCore;
using System.Net.Mail;
using Object = KristofferStrube.ActivityStreams.Object;
namespace ActivityPub.Repositories;
///
/// Database Context for ActivityPub objects (using EF and SQLite)
///
public class ActivityPubContext : DbContext {
///
/// The table to store Activities
///
public DbSet Activities { get; set; }
///
/// The table to store Objects
///
public DbSet Objects { get; set; }
///
/// The path to the sqlite database file
///
public string DbPath { get; }
///
/// Default constructor
///
public ActivityPubContext() {
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
DbPath = System.IO.Path.Join(path, "activitypub.db");
}
///
/// The following configures EF to create a Sqlite database file in the
/// special "local" folder for your platform.
///
///
protected override void OnConfiguring(DbContextOptionsBuilder options) {
options.UseSqlite($"Data Source={DbPath}");
}
protected override void OnModelCreating(ModelBuilder modelBuilder) {
modelBuilder.Entity().HasMany(_ => _.Actor as IEnumerable);
modelBuilder.Entity().HasMany(_ => _.Object as IEnumerable);
modelBuilder.Entity().HasMany(_ => _.Target as IEnumerable);
modelBuilder.Entity().HasMany(_ => _.Result as IEnumerable);
modelBuilder.Entity().HasMany(_ => _.Origin as IEnumerable);
modelBuilder.Entity().HasMany(_ => _.Instrument as IEnumerable);
modelBuilder.Entity