diff --git a/.gitignore b/.gitignore
index a4b1174..5892125 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,7 +24,9 @@ DiscordBot/token.txt
DiscordBot/debugtoken.txt
Lieb/discordAppSecret.txt
publish.sh
+publishStaging.sh
getDatabase.sh
+copyDatabaseToStaging.sh
TODO.txt
# Build results
diff --git a/DiscordBot/appsettings.Staging.json b/DiscordBot/appsettings.Staging.json
new file mode 100644
index 0000000..9d70732
--- /dev/null
+++ b/DiscordBot/appsettings.Staging.json
@@ -0,0 +1,12 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*",
+ "HttpClients": {
+ "LiebWebsite": "https://lieb.games:4430"
+ }
+}
diff --git a/Lieb/Data/PollService.cs b/Lieb/Data/PollService.cs
index d8864be..1f5d0ed 100644
--- a/Lieb/Data/PollService.cs
+++ b/Lieb/Data/PollService.cs
@@ -109,5 +109,37 @@ namespace Lieb.Data
PollAnswer answer = poll.Answers.First(a => a.UserId == userId);
answer.PollOptionId = pollOptionId;
}
+
+ public async Task AddUser(int pollId, ulong userId)
+ {
+ using var context = _contextFactory.CreateDbContext();
+ Poll? poll = context.Polls
+ .Include(p => p.Answers)
+ .FirstOrDefault(p => p.PollId == pollId && p.Answers.Where(a => a.UserId == userId).Any());
+
+ if (poll == null) return;
+
+ poll.Answers.Add(new PollAnswer()
+ {
+ UserId = userId
+ });
+ await context.SaveChangesAsync();
+ }
+
+ public async Task RemoveUser(int pollId, ulong userId)
+ {
+ using var context = _contextFactory.CreateDbContext();
+ Poll? poll = context.Polls
+ .Include(p => p.Answers)
+ .FirstOrDefault(p => p.PollId == pollId && p.Answers.Where(a => a.UserId == userId).Any());
+
+ if (poll == null) return;
+
+ PollAnswer answer = poll.Answers.First(a => a.UserId == userId);
+ context.Remove(answer);
+ await context.SaveChangesAsync();
+ poll.Answers.Remove(answer);
+ await context.SaveChangesAsync();
+ }
}
}
diff --git a/Lieb/Data/RaidService.cs b/Lieb/Data/RaidService.cs
index eff9c8b..c6e63b0 100644
--- a/Lieb/Data/RaidService.cs
+++ b/Lieb/Data/RaidService.cs
@@ -166,6 +166,10 @@ namespace Lieb.Data
{
return false;
}
+ foreach(Poll poll in context.Polls.Where(p => p.RaidId == raidId && !p.Answers.Where(a => a.UserId == liebUserId).Any()))
+ {
+ await _pollService.AddUser(poll.PollId, liebUserId);
+ }
return true;
}
@@ -202,6 +206,10 @@ namespace Lieb.Data
context.RaidSignUps.Add(signUp);
}
await context.SaveChangesAsync();
+ foreach(Poll poll in context.Polls.Where(p => p.RaidId == raidId && !p.Answers.Where(a => a.UserId == liebUserId).Any()))
+ {
+ await _pollService.AddUser(poll.PollId, liebUserId);
+ }
await LogSignUp(signUp, userName, signedUpByUserId);
return true;
}
@@ -240,6 +248,10 @@ namespace Lieb.Data
await LogSignUp(signUp, signUp.LiebUser.Name, signedOffByUserId);
}
await context.SaveChangesAsync();
+ foreach(Poll poll in context.Polls.Where(p => p.RaidId == raidId && !p.Answers.Where(a => a.UserId == liebUserId).Any()))
+ {
+ await _pollService.RemoveUser(poll.PollId, liebUserId);
+ }
await _discordService.PostRaidMessage(raidId);
}
diff --git a/Lieb/Migrations/20230103181756_PollsAndMinUsers.Designer.cs b/Lieb/Migrations/20230103181756_PollsAndMinUsers.Designer.cs
new file mode 100644
index 0000000..91bf1ee
--- /dev/null
+++ b/Lieb/Migrations/20230103181756_PollsAndMinUsers.Designer.cs
@@ -0,0 +1,755 @@
+//
+using System;
+using Lieb.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace Lieb.Migrations
+{
+ [DbContext(typeof(LiebContext))]
+ [Migration("20230103181756_PollsAndMinUsers")]
+ partial class PollsAndMinUsers
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "6.0.10");
+
+ modelBuilder.Entity("Lieb.Models.DiscordSettings", b =>
+ {
+ b.Property("DiscordSettingsId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ChangeUserNames")
+ .HasColumnType("INTEGER");
+
+ b.Property("DiscordLogChannel")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("DiscordSettingsId");
+
+ b.ToTable("DiscordSettings", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Equipped", b =>
+ {
+ b.Property("EquippedId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CanTank")
+ .HasColumnType("INTEGER");
+
+ b.Property("GuildWars2AccountId")
+ .HasColumnType("INTEGER");
+
+ b.Property("GuildWars2BuildId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("EquippedId");
+
+ b.HasIndex("GuildWars2AccountId");
+
+ b.HasIndex("GuildWars2BuildId");
+
+ b.ToTable("Equipped", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Account", b =>
+ {
+ b.Property("GuildWars2AccountId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AccountName")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("ApiKey")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("LiebUserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("GuildWars2AccountId");
+
+ b.HasIndex("LiebUserId");
+
+ b.ToTable("GuildWars2Account", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Build", b =>
+ {
+ b.Property("GuildWars2BuildId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Alacrity")
+ .HasColumnType("INTEGER");
+
+ b.Property("BuildName")
+ .IsRequired()
+ .HasMaxLength(60)
+ .HasColumnType("TEXT");
+
+ b.Property("Class")
+ .HasColumnType("INTEGER");
+
+ b.Property("DamageType")
+ .HasColumnType("INTEGER");
+
+ b.Property("EliteSpecialization")
+ .HasColumnType("INTEGER");
+
+ b.Property("Might")
+ .HasColumnType("INTEGER");
+
+ b.Property("Quickness")
+ .HasColumnType("INTEGER");
+
+ b.Property("Source")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("SourceLink")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UseInRandomRaid")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("GuildWars2BuildId");
+
+ b.ToTable("GuildWars2Build", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.DiscordRaidMessage", b =>
+ {
+ b.Property("DiscordRaidMessageId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("DiscordChannelId")
+ .HasColumnType("INTEGER");
+
+ b.Property("DiscordGuildId")
+ .HasColumnType("INTEGER");
+
+ b.Property("DiscordMessageId")
+ .HasColumnType("INTEGER");
+
+ b.Property("RaidId")
+ .HasColumnType("INTEGER");
+
+ b.Property("RaidTemplateId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("DiscordRaidMessageId");
+
+ b.HasIndex("RaidId");
+
+ b.HasIndex("RaidTemplateId");
+
+ b.ToTable("DiscordRaidMessage", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.Raid", b =>
+ {
+ b.Property("RaidId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("TEXT");
+
+ b.Property("EndTimeUTC")
+ .HasColumnType("TEXT");
+
+ b.Property("EventType")
+ .HasColumnType("INTEGER");
+
+ b.Property("FreeForAllTimeUTC")
+ .HasColumnType("TEXT");
+
+ b.Property("Guild")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("MinUserDeadLineUTC")
+ .HasColumnType("TEXT");
+
+ b.Property("MinUserPollId")
+ .HasColumnType("INTEGER");
+
+ b.Property("MinUsers")
+ .HasColumnType("INTEGER");
+
+ b.Property("MoveFlexUsers")
+ .HasColumnType("INTEGER");
+
+ b.Property("Organizer")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("RaidOwnerId")
+ .HasColumnType("INTEGER");
+
+ b.Property("RaidType")
+ .HasColumnType("INTEGER");
+
+ b.Property("RequiredRole")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("StartTimeUTC")
+ .HasColumnType("TEXT");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT");
+
+ b.Property("VoiceChat")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.HasKey("RaidId");
+
+ b.ToTable("Raid", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidReminder", b =>
+ {
+ b.Property("RaidReminderId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("DiscordChannelId")
+ .HasColumnType("INTEGER");
+
+ b.Property("DiscordServerId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Message")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("TEXT");
+
+ b.Property("RaidId")
+ .HasColumnType("INTEGER");
+
+ b.Property("RaidTemplateId")
+ .HasColumnType("INTEGER");
+
+ b.Property("ReminderTimeUTC")
+ .HasColumnType("TEXT");
+
+ b.Property("RoleId")
+ .HasColumnType("INTEGER");
+
+ b.Property("RoleType")
+ .HasColumnType("INTEGER");
+
+ b.Property("Sent")
+ .HasColumnType("INTEGER");
+
+ b.Property("TimeType")
+ .HasColumnType("INTEGER");
+
+ b.Property("Type")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("RaidReminderId");
+
+ b.HasIndex("RaidId");
+
+ b.HasIndex("RaidTemplateId");
+
+ b.ToTable("RaidReminder", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidRole", b =>
+ {
+ b.Property("RaidRoleId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("TEXT");
+
+ b.Property("IsRandomSignUpRole")
+ .HasColumnType("INTEGER");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("TEXT");
+
+ b.Property("RaidId")
+ .HasColumnType("INTEGER");
+
+ b.Property("RaidTemplateId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Spots")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("RaidRoleId");
+
+ b.HasIndex("RaidId");
+
+ b.HasIndex("RaidTemplateId");
+
+ b.ToTable("RaidRole", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidSignUp", b =>
+ {
+ b.Property("RaidSignUpId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ExternalUserName")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("GuildWars2AccountId")
+ .HasColumnType("INTEGER");
+
+ b.Property("LiebUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("RaidId")
+ .HasColumnType("INTEGER");
+
+ b.Property("RaidRoleId")
+ .HasColumnType("INTEGER");
+
+ b.Property("SignUpType")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("RaidSignUpId");
+
+ b.HasIndex("GuildWars2AccountId");
+
+ b.HasIndex("LiebUserId");
+
+ b.HasIndex("RaidId");
+
+ b.HasIndex("RaidRoleId");
+
+ b.ToTable("RaidSignUp", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidTemplate", b =>
+ {
+ b.Property("RaidTemplateId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CreateDaysBefore")
+ .HasColumnType("INTEGER");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("TEXT");
+
+ b.Property("EndTime")
+ .HasColumnType("TEXT");
+
+ b.Property("EventType")
+ .HasColumnType("INTEGER");
+
+ b.Property("FreeForAllTime")
+ .HasColumnType("TEXT");
+
+ b.Property("Guild")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("Interval")
+ .HasColumnType("INTEGER");
+
+ b.Property("MinUserDeadLine")
+ .HasColumnType("TEXT");
+
+ b.Property("MinUsers")
+ .HasColumnType("INTEGER");
+
+ b.Property("MoveFlexUsers")
+ .HasColumnType("INTEGER");
+
+ b.Property("Organizer")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("RaidOwnerId")
+ .HasColumnType("INTEGER");
+
+ b.Property("RaidType")
+ .HasColumnType("INTEGER");
+
+ b.Property("RequiredRole")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("StartTime")
+ .HasColumnType("TEXT");
+
+ b.Property("TimeZone")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT");
+
+ b.Property("VoiceChat")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.HasKey("RaidTemplateId");
+
+ b.ToTable("RaidTemplate", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.LiebRole", b =>
+ {
+ b.Property("LiebRoleId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Level")
+ .HasColumnType("INTEGER");
+
+ b.Property("LevelToAssign")
+ .HasColumnType("INTEGER");
+
+ b.Property("RoleName")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("TEXT");
+
+ b.Property("Type")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("LiebRoleId");
+
+ b.ToTable("LiebRole", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.LiebUser", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("INTEGER");
+
+ b.Property("AlwaysSignUpWithMainAccount")
+ .HasColumnType("INTEGER");
+
+ b.Property("BannedUntil")
+ .HasColumnType("TEXT");
+
+ b.Property("Birthday")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("LastSignUpAt")
+ .HasColumnType("TEXT");
+
+ b.Property("MainGW2Account")
+ .HasColumnType("INTEGER");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("TEXT");
+
+ b.Property("Pronouns")
+ .IsRequired()
+ .HasMaxLength(60)
+ .HasColumnType("TEXT");
+
+ b.Property("ReminderSubscription")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("LiebUser", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.Poll.Poll", b =>
+ {
+ b.Property("PollId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Question")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("RaidId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("PollId");
+
+ b.ToTable("Poll", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.Poll.PollAnswer", b =>
+ {
+ b.Property("PollAnswerId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("PollId")
+ .HasColumnType("INTEGER");
+
+ b.Property("PollOptionId")
+ .HasColumnType("INTEGER");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("PollAnswerId");
+
+ b.HasIndex("PollId");
+
+ b.ToTable("PollAnswer", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.Poll.PollOption", b =>
+ {
+ b.Property("PollOptionId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("PollId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("PollOptionId");
+
+ b.HasIndex("PollId");
+
+ b.ToTable("PollOption", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.RoleAssignment", b =>
+ {
+ b.Property("RoleAssignmentId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("LiebRoleId")
+ .HasColumnType("INTEGER");
+
+ b.Property("LiebUserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("RoleAssignmentId");
+
+ b.HasIndex("LiebRoleId");
+
+ b.HasIndex("LiebUserId");
+
+ b.ToTable("RoleAssignment", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Equipped", b =>
+ {
+ b.HasOne("Lieb.Models.GuildWars2.GuildWars2Account", "GuildWars2Account")
+ .WithMany("EquippedBuilds")
+ .HasForeignKey("GuildWars2AccountId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lieb.Models.GuildWars2.GuildWars2Build", "GuildWars2Build")
+ .WithMany("EquippedRoles")
+ .HasForeignKey("GuildWars2BuildId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("GuildWars2Account");
+
+ b.Navigation("GuildWars2Build");
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Account", b =>
+ {
+ b.HasOne("Lieb.Models.LiebUser", null)
+ .WithMany("GuildWars2Accounts")
+ .HasForeignKey("LiebUserId");
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.DiscordRaidMessage", b =>
+ {
+ b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", null)
+ .WithMany("DiscordRaidMessages")
+ .HasForeignKey("RaidId");
+
+ b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", null)
+ .WithMany("DiscordRaidMessages")
+ .HasForeignKey("RaidTemplateId");
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidReminder", b =>
+ {
+ b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", null)
+ .WithMany("Reminders")
+ .HasForeignKey("RaidId");
+
+ b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", null)
+ .WithMany("Reminders")
+ .HasForeignKey("RaidTemplateId");
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidRole", b =>
+ {
+ b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", null)
+ .WithMany("Roles")
+ .HasForeignKey("RaidId");
+
+ b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", null)
+ .WithMany("Roles")
+ .HasForeignKey("RaidTemplateId");
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidSignUp", b =>
+ {
+ b.HasOne("Lieb.Models.GuildWars2.GuildWars2Account", "GuildWars2Account")
+ .WithMany()
+ .HasForeignKey("GuildWars2AccountId");
+
+ b.HasOne("Lieb.Models.LiebUser", "LiebUser")
+ .WithMany()
+ .HasForeignKey("LiebUserId");
+
+ b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", "Raid")
+ .WithMany("SignUps")
+ .HasForeignKey("RaidId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lieb.Models.GuildWars2.Raid.RaidRole", "RaidRole")
+ .WithMany()
+ .HasForeignKey("RaidRoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("GuildWars2Account");
+
+ b.Navigation("LiebUser");
+
+ b.Navigation("Raid");
+
+ b.Navigation("RaidRole");
+ });
+
+ modelBuilder.Entity("Lieb.Models.Poll.PollAnswer", b =>
+ {
+ b.HasOne("Lieb.Models.Poll.Poll", null)
+ .WithMany("Answers")
+ .HasForeignKey("PollId");
+ });
+
+ modelBuilder.Entity("Lieb.Models.Poll.PollOption", b =>
+ {
+ b.HasOne("Lieb.Models.Poll.Poll", null)
+ .WithMany("Options")
+ .HasForeignKey("PollId");
+ });
+
+ modelBuilder.Entity("Lieb.Models.RoleAssignment", b =>
+ {
+ b.HasOne("Lieb.Models.LiebRole", "LiebRole")
+ .WithMany("RoleAssignments")
+ .HasForeignKey("LiebRoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lieb.Models.LiebUser", "LiebUser")
+ .WithMany("RoleAssignments")
+ .HasForeignKey("LiebUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("LiebRole");
+
+ b.Navigation("LiebUser");
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Account", b =>
+ {
+ b.Navigation("EquippedBuilds");
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Build", b =>
+ {
+ b.Navigation("EquippedRoles");
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.Raid", b =>
+ {
+ b.Navigation("DiscordRaidMessages");
+
+ b.Navigation("Reminders");
+
+ b.Navigation("Roles");
+
+ b.Navigation("SignUps");
+ });
+
+ modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidTemplate", b =>
+ {
+ b.Navigation("DiscordRaidMessages");
+
+ b.Navigation("Reminders");
+
+ b.Navigation("Roles");
+ });
+
+ modelBuilder.Entity("Lieb.Models.LiebRole", b =>
+ {
+ b.Navigation("RoleAssignments");
+ });
+
+ modelBuilder.Entity("Lieb.Models.LiebUser", b =>
+ {
+ b.Navigation("GuildWars2Accounts");
+
+ b.Navigation("RoleAssignments");
+ });
+
+ modelBuilder.Entity("Lieb.Models.Poll.Poll", b =>
+ {
+ b.Navigation("Answers");
+
+ b.Navigation("Options");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Lieb/Migrations/20230103181756_PollsAndMinUsers.cs b/Lieb/Migrations/20230103181756_PollsAndMinUsers.cs
new file mode 100644
index 0000000..1ebbc16
--- /dev/null
+++ b/Lieb/Migrations/20230103181756_PollsAndMinUsers.cs
@@ -0,0 +1,142 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace Lieb.Migrations
+{
+ public partial class PollsAndMinUsers : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "MinUserDeadLine",
+ table: "RaidTemplate",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AddColumn(
+ name: "MinUsers",
+ table: "RaidTemplate",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: 0);
+
+ migrationBuilder.AddColumn(
+ name: "MinUserDeadLineUTC",
+ table: "Raid",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)));
+
+ migrationBuilder.AddColumn(
+ name: "MinUserPollId",
+ table: "Raid",
+ type: "INTEGER",
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "MinUsers",
+ table: "Raid",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: 0);
+
+ migrationBuilder.CreateTable(
+ name: "Poll",
+ columns: table => new
+ {
+ PollId = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Question = table.Column(type: "TEXT", nullable: false),
+ RaidId = table.Column(type: "INTEGER", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Poll", x => x.PollId);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "PollAnswer",
+ columns: table => new
+ {
+ PollAnswerId = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ PollOptionId = table.Column(type: "INTEGER", nullable: true),
+ UserId = table.Column(type: "INTEGER", nullable: false),
+ PollId = table.Column(type: "INTEGER", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_PollAnswer", x => x.PollAnswerId);
+ table.ForeignKey(
+ name: "FK_PollAnswer_Poll_PollId",
+ column: x => x.PollId,
+ principalTable: "Poll",
+ principalColumn: "PollId");
+ });
+
+ migrationBuilder.CreateTable(
+ name: "PollOption",
+ columns: table => new
+ {
+ PollOptionId = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Name = table.Column(type: "TEXT", nullable: false),
+ PollId = table.Column(type: "INTEGER", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_PollOption", x => x.PollOptionId);
+ table.ForeignKey(
+ name: "FK_PollOption_Poll_PollId",
+ column: x => x.PollId,
+ principalTable: "Poll",
+ principalColumn: "PollId");
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_PollAnswer_PollId",
+ table: "PollAnswer",
+ column: "PollId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_PollOption_PollId",
+ table: "PollOption",
+ column: "PollId");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "PollAnswer");
+
+ migrationBuilder.DropTable(
+ name: "PollOption");
+
+ migrationBuilder.DropTable(
+ name: "Poll");
+
+ migrationBuilder.DropColumn(
+ name: "MinUserDeadLine",
+ table: "RaidTemplate");
+
+ migrationBuilder.DropColumn(
+ name: "MinUsers",
+ table: "RaidTemplate");
+
+ migrationBuilder.DropColumn(
+ name: "MinUserDeadLineUTC",
+ table: "Raid");
+
+ migrationBuilder.DropColumn(
+ name: "MinUserPollId",
+ table: "Raid");
+
+ migrationBuilder.DropColumn(
+ name: "MinUsers",
+ table: "Raid");
+ }
+ }
+}
diff --git a/Lieb/Migrations/LiebContextModelSnapshot.cs b/Lieb/Migrations/LiebContextModelSnapshot.cs
index 0e7efc7..0304baa 100644
--- a/Lieb/Migrations/LiebContextModelSnapshot.cs
+++ b/Lieb/Migrations/LiebContextModelSnapshot.cs
@@ -182,6 +182,15 @@ namespace Lieb.Migrations
.HasMaxLength(50)
.HasColumnType("TEXT");
+ b.Property("MinUserDeadLineUTC")
+ .HasColumnType("TEXT");
+
+ b.Property("MinUserPollId")
+ .HasColumnType("INTEGER");
+
+ b.Property("MinUsers")
+ .HasColumnType("INTEGER");
+
b.Property("MoveFlexUsers")
.HasColumnType("INTEGER");
@@ -374,6 +383,12 @@ namespace Lieb.Migrations
b.Property("Interval")
.HasColumnType("INTEGER");
+ b.Property("MinUserDeadLine")
+ .HasColumnType("TEXT");
+
+ b.Property("MinUsers")
+ .HasColumnType("INTEGER");
+
b.Property("MoveFlexUsers")
.HasColumnType("INTEGER");
@@ -480,6 +495,66 @@ namespace Lieb.Migrations
b.ToTable("LiebUser", (string)null);
});
+ modelBuilder.Entity("Lieb.Models.Poll.Poll", b =>
+ {
+ b.Property("PollId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Question")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("RaidId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("PollId");
+
+ b.ToTable("Poll", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.Poll.PollAnswer", b =>
+ {
+ b.Property("PollAnswerId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("PollId")
+ .HasColumnType("INTEGER");
+
+ b.Property("PollOptionId")
+ .HasColumnType("INTEGER");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("PollAnswerId");
+
+ b.HasIndex("PollId");
+
+ b.ToTable("PollAnswer", (string)null);
+ });
+
+ modelBuilder.Entity("Lieb.Models.Poll.PollOption", b =>
+ {
+ b.Property("PollOptionId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("PollId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("PollOptionId");
+
+ b.HasIndex("PollId");
+
+ b.ToTable("PollOption", (string)null);
+ });
+
modelBuilder.Entity("Lieb.Models.RoleAssignment", b =>
{
b.Property("RoleAssignmentId")
@@ -591,6 +666,20 @@ namespace Lieb.Migrations
b.Navigation("RaidRole");
});
+ modelBuilder.Entity("Lieb.Models.Poll.PollAnswer", b =>
+ {
+ b.HasOne("Lieb.Models.Poll.Poll", null)
+ .WithMany("Answers")
+ .HasForeignKey("PollId");
+ });
+
+ modelBuilder.Entity("Lieb.Models.Poll.PollOption", b =>
+ {
+ b.HasOne("Lieb.Models.Poll.Poll", null)
+ .WithMany("Options")
+ .HasForeignKey("PollId");
+ });
+
modelBuilder.Entity("Lieb.Models.RoleAssignment", b =>
{
b.HasOne("Lieb.Models.LiebRole", "LiebRole")
@@ -651,6 +740,13 @@ namespace Lieb.Migrations
b.Navigation("RoleAssignments");
});
+
+ modelBuilder.Entity("Lieb.Models.Poll.Poll", b =>
+ {
+ b.Navigation("Answers");
+
+ b.Navigation("Options");
+ });
#pragma warning restore 612, 618
}
}
diff --git a/Lieb/Program.cs b/Lieb/Program.cs
index e973b03..5b42b47 100644
--- a/Lieb/Program.cs
+++ b/Lieb/Program.cs
@@ -24,6 +24,7 @@ builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
+builder.Services.AddScoped();
builder.Services.AddHostedService();
builder.Services.AddAuthentication(opt =>
diff --git a/Lieb/appsettings.Staging.json b/Lieb/appsettings.Staging.json
new file mode 100644
index 0000000..d36fe25
--- /dev/null
+++ b/Lieb/appsettings.Staging.json
@@ -0,0 +1,18 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "Discord": {
+ "AppId": "942448872335220806"
+ },
+ "AllowedHosts": "*",
+ "ConnectionStrings": {
+ "LiebContext": "Data Source=/database/mydb.sqlite;"
+ },
+ "HttpClients": {
+ "DiscordBot": "http://lieb-bot-test"
+ }
+}