forked from adam/discord-bot-shtik
Compare commits
No commits in common. "b859d99c92dedba84cd42a8f8eb1778f0ec872e2" and "224a3c5a622ab50febc2758d08323800fcc72d70" have entirely different histories.
b859d99c92
...
224a3c5a62
@ -1,389 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using vassago.Models;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace vassago.Migrations
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618, 8981
|
|
||||||
[DbContext(typeof(ChattingContext))]
|
|
||||||
[Migration("20250605145513_datamemos-more-data")]
|
|
||||||
partial class datamemosmoredata
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "7.0.5")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "hstore");
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("AccountUAC", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("AccountInChannelsId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid>("UACsId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("AccountInChannelsId", "UACsId");
|
|
||||||
|
|
||||||
b.HasIndex("UACsId");
|
|
||||||
|
|
||||||
b.ToTable("AccountUAC");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("ChannelUAC", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("ChannelsId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid>("UACsId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("ChannelsId", "UACsId");
|
|
||||||
|
|
||||||
b.HasIndex("UACsId");
|
|
||||||
|
|
||||||
b.ToTable("ChannelUAC");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("UACUser", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("UACsId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid>("UsersId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("UACsId", "UsersId");
|
|
||||||
|
|
||||||
b.HasIndex("UsersId");
|
|
||||||
|
|
||||||
b.ToTable("UACUser");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.Account", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("DisplayName")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ExternalId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("IsBot")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<Guid?>("IsUserId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Protocol")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<Guid?>("SeenInChannelId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Username")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("IsUserId");
|
|
||||||
|
|
||||||
b.HasIndex("SeenInChannelId");
|
|
||||||
|
|
||||||
b.ToTable("Accounts");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.Attachment", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<byte[]>("Content")
|
|
||||||
.HasColumnType("bytea");
|
|
||||||
|
|
||||||
b.Property<string>("ContentType")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<decimal?>("ExternalId")
|
|
||||||
.HasColumnType("numeric(20,0)");
|
|
||||||
|
|
||||||
b.Property<string>("Filename")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<Guid?>("MessageId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<int>("Size")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Source")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("MessageId");
|
|
||||||
|
|
||||||
b.ToTable("Attachments");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.Channel", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<int>("ChannelType")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("DisplayName")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ExternalId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int?>("LewdnessFilterLevel")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<bool?>("LinksAllowed")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<decimal?>("MaxAttachmentBytes")
|
|
||||||
.HasColumnType("numeric(20,0)");
|
|
||||||
|
|
||||||
b.Property<long?>("MaxTextChars")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<int?>("MeannessFilterLevel")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<Guid?>("ParentChannelId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Protocol")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool?>("ReactionsPossible")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ParentChannelId");
|
|
||||||
|
|
||||||
b.ToTable("Channels");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.Message", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<bool>("ActedOn")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<Guid?>("AuthorId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid?>("ChannelId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Content")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ExternalId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("MentionsMe")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<string>("Protocol")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("Timestamp")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("AuthorId");
|
|
||||||
|
|
||||||
b.HasIndex("ChannelId");
|
|
||||||
|
|
||||||
b.ToTable("Messages");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.UAC", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Dictionary<string, string>>("CommandAliases")
|
|
||||||
.HasColumnType("hstore");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("DisplayName")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<Dictionary<string, string>>("Localization")
|
|
||||||
.HasColumnType("hstore");
|
|
||||||
|
|
||||||
b.Property<Guid>("OwnerId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("UACs");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.User", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Users");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AccountUAC", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("vassago.Models.Account", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("AccountInChannelsId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("vassago.Models.UAC", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UACsId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("ChannelUAC", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("vassago.Models.Channel", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ChannelsId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("vassago.Models.UAC", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UACsId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("UACUser", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("vassago.Models.UAC", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UACsId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("vassago.Models.User", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UsersId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.Account", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("vassago.Models.User", "IsUser")
|
|
||||||
.WithMany("Accounts")
|
|
||||||
.HasForeignKey("IsUserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
|
||||||
|
|
||||||
b.HasOne("vassago.Models.Channel", "SeenInChannel")
|
|
||||||
.WithMany("Users")
|
|
||||||
.HasForeignKey("SeenInChannelId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
|
||||||
|
|
||||||
b.Navigation("IsUser");
|
|
||||||
|
|
||||||
b.Navigation("SeenInChannel");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.Attachment", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("vassago.Models.Message", "Message")
|
|
||||||
.WithMany("Attachments")
|
|
||||||
.HasForeignKey("MessageId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
|
||||||
|
|
||||||
b.Navigation("Message");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.Channel", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("vassago.Models.Channel", "ParentChannel")
|
|
||||||
.WithMany("SubChannels")
|
|
||||||
.HasForeignKey("ParentChannelId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
|
||||||
|
|
||||||
b.Navigation("ParentChannel");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.Message", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("vassago.Models.Account", "Author")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("AuthorId");
|
|
||||||
|
|
||||||
b.HasOne("vassago.Models.Channel", "Channel")
|
|
||||||
.WithMany("Messages")
|
|
||||||
.HasForeignKey("ChannelId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
|
||||||
|
|
||||||
b.Navigation("Author");
|
|
||||||
|
|
||||||
b.Navigation("Channel");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.Channel", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Messages");
|
|
||||||
|
|
||||||
b.Navigation("SubChannels");
|
|
||||||
|
|
||||||
b.Navigation("Users");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.Message", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Attachments");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("vassago.Models.User", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Accounts");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618, 8981
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace vassago.Migrations
|
|
||||||
{
|
|
||||||
#pragma warning disable 8981
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class datamemosmoredata : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<Dictionary<string, string>>(
|
|
||||||
name: "CommandAliases",
|
|
||||||
table: "UACs",
|
|
||||||
type: "hstore",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<Dictionary<string, string>>(
|
|
||||||
name: "Localization",
|
|
||||||
table: "UACs",
|
|
||||||
type: "hstore",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
//NOTE for future me: migrationBuilder.SQL("SELECT localization INTO Aliases from Channels;");, but also make the rows for it.
|
|
||||||
//too lazy now, really leaning on the "this will work fine for my 0 users"
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Aliases",
|
|
||||||
table: "Channels");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<Dictionary<string, string>>(
|
|
||||||
name: "Aliases",
|
|
||||||
table: "Channels",
|
|
||||||
type: "hstore",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CommandAliases",
|
|
||||||
table: "UACs");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Localization",
|
|
||||||
table: "UACs");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#pragma warning restore 8981
|
|
@ -148,6 +148,9 @@ namespace vassago.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Dictionary<string, string>>("Aliases")
|
||||||
|
.HasColumnType("hstore");
|
||||||
|
|
||||||
b.Property<int>("ChannelType")
|
b.Property<int>("ChannelType")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
@ -233,18 +236,12 @@ namespace vassago.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Dictionary<string, string>>("CommandAliases")
|
|
||||||
.HasColumnType("hstore");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("DisplayName")
|
b.Property<string>("DisplayName")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<Dictionary<string, string>>("Localization")
|
|
||||||
.HasColumnType("hstore");
|
|
||||||
|
|
||||||
b.Property<Guid>("OwnerId")
|
b.Property<Guid>("OwnerId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ public class Channel
|
|||||||
public Enumerations.LewdnessFilterLevel? LewdnessFilterLevel { get; set; }
|
public Enumerations.LewdnessFilterLevel? LewdnessFilterLevel { get; set; }
|
||||||
public Enumerations.MeannessFilterLevel? MeannessFilterLevel { get; set; }
|
public Enumerations.MeannessFilterLevel? MeannessFilterLevel { get; set; }
|
||||||
public List<UAC> UACs { get; set; }
|
public List<UAC> UACs { get; set; }
|
||||||
|
//both incoming and outgoing
|
||||||
|
//public Dictionary<string, string> Aliases { get; set; }
|
||||||
|
|
||||||
public DefinitePermissionSettings EffectivePermissions
|
public DefinitePermissionSettings EffectivePermissions
|
||||||
{
|
{
|
||||||
|
@ -22,5 +22,4 @@ public class Message
|
|||||||
public List<Attachment> Attachments { get; set; }
|
public List<Attachment> Attachments { get; set; }
|
||||||
public Account Author { get; set; }
|
public Account Author { get; set; }
|
||||||
public Channel Channel { get; set; }
|
public Channel Channel { get; set; }
|
||||||
public Guid? ChannelId { get; set; }
|
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,6 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using vassago.Models;
|
using vassago.Models;
|
||||||
|
|
||||||
|
|
||||||
//TODO: rename.
|
|
||||||
//"uac" originally meant "user account control". but it might just be channel control. in fact, channel-control is much more fun,
|
|
||||||
//then the platform manages the permissions for you!
|
|
||||||
//but now I'm going to add locales to it, so it's kind of... "miscellaneous attached data". Official Sticky Notes, if you will.
|
|
||||||
public class UAC
|
public class UAC
|
||||||
{
|
{
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
@ -31,7 +26,4 @@ public class UAC
|
|||||||
///it's variably before and after compile time. shrug.emote.
|
///it's variably before and after compile time. shrug.emote.
|
||||||
///</summary>
|
///</summary>
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
public Dictionary<string, string> CommandAliases {get; set;}
|
|
||||||
public Dictionary<string, string> Localization {get; set;}
|
|
||||||
}
|
}
|
||||||
|
@ -15,23 +15,14 @@ public static class Rememberer
|
|||||||
{
|
{
|
||||||
dbAccessSemaphore.Wait();
|
dbAccessSemaphore.Wait();
|
||||||
channels = db.Channels.ToList();
|
channels = db.Channels.ToList();
|
||||||
Console.WriteLine($"caching channels. {channels.Count} channels retrieved");
|
|
||||||
foreach (Channel ch in channels)
|
foreach (Channel ch in channels)
|
||||||
{
|
{
|
||||||
if (ch.ParentChannelId != null)
|
if (ch.ParentChannelId != null)
|
||||||
{
|
{
|
||||||
ch.ParentChannel = channels.FirstOrDefault(c => c.Id == ch.ParentChannelId);
|
ch.ParentChannel = channels.FirstOrDefault(c => c.Id == ch.ParentChannelId);
|
||||||
ch.ParentChannel.SubChannels ??= [];
|
ch.ParentChannel.SubChannels ??= [];
|
||||||
if (!ch.ParentChannel.SubChannels.Contains(ch))
|
ch.ParentChannel.SubChannels.Add(ch);
|
||||||
{
|
|
||||||
ch.ParentChannel.SubChannels.Add(ch);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (ch.Messages?.Count > 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"{ch.DisplayName} got {ch.Messages.Count} messages");
|
|
||||||
}
|
|
||||||
ch.SubChannels ??= [];
|
|
||||||
}
|
}
|
||||||
channelCacheDirty = false;
|
channelCacheDirty = false;
|
||||||
dbAccessSemaphore.Release();
|
dbAccessSemaphore.Release();
|
||||||
@ -63,7 +54,7 @@ public static class Rememberer
|
|||||||
}
|
}
|
||||||
public static Channel SearchChannel(Func<Channel, bool> predicate)
|
public static Channel SearchChannel(Func<Channel, bool> predicate)
|
||||||
{
|
{
|
||||||
if (channelCacheDirty)
|
if(channelCacheDirty)
|
||||||
Task.Run(() => cacheChannels()).Wait();
|
Task.Run(() => cacheChannels()).Wait();
|
||||||
return channels.FirstOrDefault(predicate);
|
return channels.FirstOrDefault(predicate);
|
||||||
}
|
}
|
||||||
@ -75,14 +66,6 @@ public static class Rememberer
|
|||||||
dbAccessSemaphore.Release();
|
dbAccessSemaphore.Release();
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
public static List<Message> SearchMessages(Expression<Func<Message, bool>> predicate)
|
|
||||||
{
|
|
||||||
List<Message> toReturn;
|
|
||||||
dbAccessSemaphore.Wait();
|
|
||||||
toReturn = db.Messages.Where(predicate).ToList();
|
|
||||||
dbAccessSemaphore.Release();
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
public static User SearchUser(Expression<Func<User, bool>> predicate)
|
public static User SearchUser(Expression<Func<User, bool>> predicate)
|
||||||
{
|
{
|
||||||
User toReturn;
|
User toReturn;
|
||||||
@ -109,7 +92,7 @@ public static class Rememberer
|
|||||||
}
|
}
|
||||||
public static Channel RememberChannel(Channel toRemember)
|
public static Channel RememberChannel(Channel toRemember)
|
||||||
{
|
{
|
||||||
if (channelCacheDirty)
|
if(channelCacheDirty)
|
||||||
Task.Run(() => cacheChannels()).Wait(); //so we always do 2 db trips?
|
Task.Run(() => cacheChannels()).Wait(); //so we always do 2 db trips?
|
||||||
dbAccessSemaphore.Wait();
|
dbAccessSemaphore.Wait();
|
||||||
db.Update(toRemember);
|
db.Update(toRemember);
|
||||||
@ -184,8 +167,6 @@ public static class Rememberer
|
|||||||
db.Channels.Remove(toForget);
|
db.Channels.Remove(toForget);
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
dbAccessSemaphore.Release();
|
dbAccessSemaphore.Release();
|
||||||
channelCacheDirty = true;
|
|
||||||
cacheChannels();
|
|
||||||
}
|
}
|
||||||
public static void ForgetMessage(Message toForget)
|
public static void ForgetMessage(Message toForget)
|
||||||
{
|
{
|
||||||
@ -218,9 +199,11 @@ public static class Rememberer
|
|||||||
}
|
}
|
||||||
public static List<Channel> ChannelsOverview()
|
public static List<Channel> ChannelsOverview()
|
||||||
{
|
{
|
||||||
if (channelCacheDirty)
|
List<Channel> toReturn;
|
||||||
Task.Run(() => cacheChannels()).Wait();
|
dbAccessSemaphore.Wait();
|
||||||
return channels;
|
toReturn = [.. db.Channels.Include(u => u.SubChannels).Include(c => c.ParentChannel)];
|
||||||
|
dbAccessSemaphore.Release();
|
||||||
|
return toReturn;
|
||||||
}
|
}
|
||||||
public static Account AccountDetail(Guid Id)
|
public static Account AccountDetail(Guid Id)
|
||||||
{
|
{
|
||||||
@ -238,14 +221,11 @@ public static class Rememberer
|
|||||||
dbAccessSemaphore.Release();
|
dbAccessSemaphore.Release();
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
public static Channel ChannelDetail(Guid Id, bool messages = false)
|
public static Channel ChannelDetail(Guid Id)
|
||||||
{
|
{
|
||||||
if (channelCacheDirty)
|
if(channelCacheDirty)
|
||||||
Task.Run(() => cacheChannels()).Wait();
|
Task.Run(() => cacheChannels()).Wait();
|
||||||
var ch = channels.Find(c => c.Id == Id);
|
return channels.Find(c => c.Id == Id);
|
||||||
if (messages)
|
|
||||||
ch.Messages = SearchMessages(m => m.ChannelId == ch.Id);
|
|
||||||
return ch;
|
|
||||||
}
|
}
|
||||||
public static Message MessageDetail(Guid Id)
|
public static Message MessageDetail(Guid Id)
|
||||||
{
|
{
|
||||||
@ -323,7 +303,5 @@ public static class Rememberer
|
|||||||
db.Update(toRemember);
|
db.Update(toRemember);
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
dbAccessSemaphore.Release();
|
dbAccessSemaphore.Release();
|
||||||
if (toRemember.Channels?.Count() > 0)
|
|
||||||
cacheChannels();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,28 +13,32 @@ public class ChannelsController() : Controller
|
|||||||
public IActionResult Details(Guid id)
|
public IActionResult Details(Guid id)
|
||||||
{
|
{
|
||||||
var allChannels = Rememberer.ChannelsOverview();
|
var allChannels = Rememberer.ChannelsOverview();
|
||||||
if (allChannels == null)
|
if(allChannels == null)
|
||||||
return Problem("no channels.");
|
return Problem("Entity set '_db.Channels' is null.");
|
||||||
|
//"but adam", says the strawman, "why load *every* channel and walk your way up? surely there's a .Load command that works or something."
|
||||||
|
//eh. I checked. Not really. You could make an SQL view that recurses its way up, meh idk how. You could just eagerly load *every* related object...
|
||||||
|
//but that would take in all the messages.
|
||||||
|
//realistically I expect this will have less than 1MB of total "channels", and several GB of total messages per (text) channel.
|
||||||
|
|
||||||
var channel = allChannels.FirstOrDefault(u => u.Id == id);
|
var channel = allChannels.FirstOrDefault(u => u.Id == id);
|
||||||
if (channel == null)
|
if(channel == null)
|
||||||
{
|
{
|
||||||
return Problem($"couldn't find channle {id}");
|
return Problem("couldn't find that channle");
|
||||||
}
|
}
|
||||||
var walker = channel;
|
var walker = channel;
|
||||||
while (walker != null)
|
while(walker != null)
|
||||||
{
|
{
|
||||||
ViewData["breadcrumbs"] = $"<a href=\"{Url.ActionLink(action: "Details", controller: "Channels", values: new { id = walker.Id })}\">{walker.DisplayName}</a>/" +
|
ViewData["breadcrumbs"] = $"<a href=\"{Url.ActionLink(action: "Details", controller: "Channels", values: new {id = walker.Id})}\">{walker.DisplayName}</a>/" +
|
||||||
ViewData["breadcrumbs"];
|
ViewData["breadcrumbs"];
|
||||||
walker = walker.ParentChannel;
|
walker = walker.ParentChannel;
|
||||||
}
|
}
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.Append('[');
|
sb.Append('[');
|
||||||
sb.Append($"{{text: \"{channel.SubChannels?.Count}\", nodes: [");
|
sb.Append($"{{text: \"{channel.SubChannels?.Count}\", nodes: [");
|
||||||
var first = true;
|
var first=true;
|
||||||
foreach (var subChannel in channel.SubChannels)
|
foreach(var subChannel in channel.SubChannels)
|
||||||
{
|
{
|
||||||
if (!first)
|
if(!first)
|
||||||
{
|
{
|
||||||
sb.Append(',');
|
sb.Append(',');
|
||||||
}
|
}
|
||||||
@ -42,11 +46,11 @@ public class ChannelsController() : Controller
|
|||||||
{
|
{
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
sb.Append($"{{\"text\": \"<a href=\\\"{Url.ActionLink(action: "Details", controller: "Channels", values: new { id = subChannel.Id })}\\\">{subChannel.DisplayName}</a>\"}}");
|
sb.Append($"{{\"text\": \"<a href=\\\"{Url.ActionLink(action: "Details", controller: "Channels", values: new {id = subChannel.Id})}\\\">{subChannel.DisplayName}</a>\"}}");
|
||||||
}
|
}
|
||||||
sb.Append("]}]");
|
sb.Append("]}]");
|
||||||
|
|
||||||
ViewData.Add("subChannelsTree", sb.ToString());
|
ViewData.Add("channelsTree", sb.ToString());
|
||||||
return View(
|
return View(
|
||||||
new Tuple<Channel, Enumerations.LewdnessFilterLevel, Enumerations.MeannessFilterLevel>(
|
new Tuple<Channel, Enumerations.LewdnessFilterLevel, Enumerations.MeannessFilterLevel>(
|
||||||
channel, channel.EffectivePermissions.LewdnessFilterLevel, channel.EffectivePermissions.MeannessFilterLevel
|
channel, channel.EffectivePermissions.LewdnessFilterLevel, channel.EffectivePermissions.MeannessFilterLevel
|
||||||
|
@ -43,12 +43,7 @@ public class HomeController : Controller
|
|||||||
{
|
{
|
||||||
sb.Append(',');
|
sb.Append(',');
|
||||||
}
|
}
|
||||||
var displayedName = uac.DisplayName;
|
sb.Append($"{{\"text\": \"<a href=\\\"{Url.ActionLink(action: "Details", controller: "UACs", values: new {id = uac.Id})}\\\">{uac.DisplayName}</a>\"}}");
|
||||||
if(string.IsNullOrWhiteSpace(displayedName))
|
|
||||||
{
|
|
||||||
displayedName = $"[unnamed - {uac.Id}]";
|
|
||||||
}
|
|
||||||
sb.Append($"{{\"text\": \"<a href=\\\"{Url.ActionLink(action: "Details", controller: "UACs", values: new {id = uac.Id})}\\\">{displayedName}</a>\"}}");
|
|
||||||
}
|
}
|
||||||
sb.Append("]}");
|
sb.Append("]}");
|
||||||
}
|
}
|
||||||
@ -83,7 +78,7 @@ public class HomeController : Controller
|
|||||||
//type error, e is not defined
|
//type error, e is not defined
|
||||||
//channels
|
//channels
|
||||||
sb.Append(",{text: \"channels\", expanded:true, nodes: [");
|
sb.Append(",{text: \"channels\", expanded:true, nodes: [");
|
||||||
var topLevelChannels = Rememberer.ChannelsOverview().Where(x => x.ParentChannel == null).ToList();
|
var topLevelChannels = Rememberer.ChannelsOverview().Where(x => x.ParentChannel == null);
|
||||||
first = true;
|
first = true;
|
||||||
foreach (var topLevelChannel in topLevelChannels)
|
foreach (var topLevelChannel in topLevelChannels)
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ namespace vassago.Controllers.api;
|
|||||||
|
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class UACController : ControllerBase
|
public class UACController: ControllerBase
|
||||||
{
|
{
|
||||||
private readonly ILogger<UACController> _logger;
|
private readonly ILogger<UACController> _logger;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ public class UACController : ControllerBase
|
|||||||
var uacFromDb = Rememberer.SearchUAC(uac => uac.Id == uac_guid);
|
var uacFromDb = Rememberer.SearchUAC(uac => uac.Id == uac_guid);
|
||||||
if (uacFromDb == null)
|
if (uacFromDb == null)
|
||||||
{
|
{
|
||||||
var err = $"attempt to link channel for uac {uac_guid}, not found";
|
var err =$"attempt to link channel for uac {uac_guid}, not found";
|
||||||
_logger.LogError(err);
|
_logger.LogError(err);
|
||||||
return NotFound(err);
|
return NotFound(err);
|
||||||
}
|
}
|
||||||
@ -210,23 +210,4 @@ public class UACController : ControllerBase
|
|||||||
Rememberer.RememberUAC(uacFromDb);
|
Rememberer.RememberUAC(uacFromDb);
|
||||||
return Ok(uacFromDb);
|
return Ok(uacFromDb);
|
||||||
}
|
}
|
||||||
[HttpPut]
|
|
||||||
[Route("CreateForChannels/{Id}")]
|
|
||||||
[Produces("application/json")]
|
|
||||||
public IActionResult CreateForChannels(Guid Id)
|
|
||||||
{
|
|
||||||
_logger.LogDebug($"made it to controller. creating for channel {Id}");
|
|
||||||
var targetChannel = Rememberer.ChannelDetail(Id);
|
|
||||||
if (targetChannel == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
var newUAC = new UAC()
|
|
||||||
{
|
|
||||||
Channels = [targetChannel]
|
|
||||||
};
|
|
||||||
Rememberer.RememberUAC(newUAC);
|
|
||||||
Rememberer.RememberChannel(targetChannel);
|
|
||||||
return Ok(newUAC.Id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -103,12 +103,6 @@
|
|||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<th scope="row">Datamemos</th>
|
|
||||||
<td>
|
|
||||||
<div id="dataMemosTree"></div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<button onclick="forget()">forget</button>
|
<button onclick="forget()">forget</button>
|
||||||
@ -144,49 +138,15 @@
|
|||||||
deleteModel(jsonifyChannel().Id, window.history.back);
|
deleteModel(jsonifyChannel().Id, window.history.back);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function createMemo()
|
|
||||||
{
|
|
||||||
console.log("creating memo for channel..");
|
|
||||||
createMemoFor((newMemoId) => {
|
|
||||||
window.location.href = "/UACs/Details/" + newMemoId;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function channelsTree() {
|
function channelsTree() {
|
||||||
//TOOD: see how accountsTree does all our HTML-ification over here in HTML land? but this doesn't? we should pick one and stick with it.
|
var tree = @Html.Raw(ViewData["channelsTree"]);
|
||||||
var tree = @Html.Raw(ViewData["subChannelsTree"]);
|
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
function dataMemosTree(){
|
|
||||||
@{
|
|
||||||
var dmsb = new StringBuilder();
|
|
||||||
dmsb.Append("[{text: \"Data Memos\", \"expanded\":true, nodes: [");
|
|
||||||
var firstMemo = true;
|
|
||||||
if(ThisChannel.UACs != null) foreach(var memo in ThisChannel.UACs)
|
|
||||||
{
|
|
||||||
if(!firstMemo)
|
|
||||||
dmsb.Append(',');
|
|
||||||
var effectiveDisplayName = memo.DisplayName;
|
|
||||||
if(string.IsNullOrWhiteSpace(effectiveDisplayName))
|
|
||||||
{
|
|
||||||
effectiveDisplayName = $"[nameless] {memo.Id}";
|
|
||||||
}
|
|
||||||
dmsb.Append($"{{text: \"<a href=\\\"/UACs/Details/{memo.Id}\\\">{effectiveDisplayName}</a>\"}}");
|
|
||||||
firstMemo = false;
|
|
||||||
}
|
|
||||||
if(!firstMemo)
|
|
||||||
dmsb.Append(',');
|
|
||||||
dmsb.Append($"{{text: \"<button type=\\\"button\\\" class=\\\"btn btn-primary\\\" onclick=\\\"createMemo()\\\">+</button>\"}}");
|
|
||||||
dmsb.Append("]}]");
|
|
||||||
}
|
|
||||||
var tree = @Html.Raw(dmsb.ToString());
|
|
||||||
return tree;
|
|
||||||
}
|
|
||||||
|
|
||||||
function accountsTree() {
|
function accountsTree() {
|
||||||
@{
|
@{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
sb.Append("[{text: \"accounts\", \"expanded\":true, nodes: [");
|
sb.Append("[{text: \"accounts\", \"expanded\":true, nodes: [");
|
||||||
var first = true;
|
var first = true;
|
||||||
foreach (var acc in ThisChannel.Users?.OrderBy(a => a?.SeenInChannel?.LineageSummary))
|
foreach (var acc in ThisChannel.Users?.OrderBy(a => a?.SeenInChannel?.LineageSummary))
|
||||||
@ -197,7 +157,6 @@
|
|||||||
first=false;
|
first=false;
|
||||||
}
|
}
|
||||||
sb.Append("]}]");
|
sb.Append("]}]");
|
||||||
|
|
||||||
}
|
}
|
||||||
//console.log(@Html.Raw(sb.ToString()));
|
//console.log(@Html.Raw(sb.ToString()));
|
||||||
var tree = @Html.Raw(sb.ToString());
|
var tree = @Html.Raw(sb.ToString());
|
||||||
@ -205,7 +164,6 @@
|
|||||||
}
|
}
|
||||||
$('#channelsTree').bstreeview({ data: channelsTree() });
|
$('#channelsTree').bstreeview({ data: channelsTree() });
|
||||||
$('#accountsTree').bstreeview({ data: accountsTree() });
|
$('#accountsTree').bstreeview({ data: accountsTree() });
|
||||||
$('#dataMemosTree').bstreeview({ data: dataMemosTree() });
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
|
42
WebInterface/Views/Channels/Index.cshtml
Normal file
42
WebInterface/Views/Channels/Index.cshtml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
@model IEnumerable<Channel>
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Channels";
|
||||||
|
}
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
protocol
|
||||||
|
</th>
|
||||||
|
<th>type</th>
|
||||||
|
<th>
|
||||||
|
display name
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Lineage
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model) {
|
||||||
|
<tr>
|
||||||
|
<td class="@item.Protocol">
|
||||||
|
<div class="protocol-icon"> </div>
|
||||||
|
</td>
|
||||||
|
<td class="@item.ChannelType">
|
||||||
|
<div class="channel-type-icon"> </div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.DisplayName)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.LineageSummary
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a asp-action="Details" asp-route-id="@item.Id">Details</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
@ -49,7 +49,7 @@ function deleteModel(id, callback)
|
|||||||
var components = window.location.pathname.split('/');
|
var components = window.location.pathname.split('/');
|
||||||
var type=components[1];
|
var type=components[1];
|
||||||
let result = null;
|
let result = null;
|
||||||
var id=components[3]; //wait... i send it the ID then overwrite it? lmao what? TODO: fix
|
var id=components[3];
|
||||||
fetch(apiUrl + 'Rememberer/' + type + '/' + id, {
|
fetch(apiUrl + 'Rememberer/' + type + '/' + id, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
@ -71,37 +71,9 @@ function deleteModel(id, callback)
|
|||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function createMemoFor(callback)
|
|
||||||
{
|
|
||||||
let components = window.location.pathname.split('/');
|
|
||||||
let type=components[1];
|
|
||||||
type = type.charAt(0).toUpperCase() + type.slice(1).toLowerCase();
|
|
||||||
let result = null;
|
|
||||||
let id=components[3];
|
|
||||||
console.log("createMemoFor" + type + "(" + id + ")");
|
|
||||||
fetch(apiUrl + "UAC/CreateFor" + type + "/" + id, {
|
|
||||||
method: 'PUT',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('Network response was not "ok". which is not ok.');
|
|
||||||
}
|
|
||||||
return response.json();
|
|
||||||
})
|
|
||||||
.then(returnedSuccessdata => {
|
|
||||||
console.log("success");
|
|
||||||
console.log('returnedSuccessdata:', returnedSuccessdata);
|
|
||||||
if(callback !== null) { callback(returnedSuccessdata); }
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Error:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function linkUAC_Channel(channel_guid, callback)
|
function linkUAC_Channel(channel_guid, callback)
|
||||||
{
|
{
|
||||||
|
|
||||||
var components = window.location.pathname.split('/');
|
var components = window.location.pathname.split('/');
|
||||||
var id=components[3];
|
var id=components[3];
|
||||||
let model={"uac_guid": id,
|
let model={"uac_guid": id,
|
||||||
|
Loading…
Reference in New Issue
Block a user