add ottergui, update for recent changes
This commit is contained in:
parent
ded3fb3e2c
commit
08c3af0954
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "Lib/OtterGui"]
|
||||
path = Lib/OtterGui
|
||||
url = https://github.com/Ottermandias/OtterGui.git
|
||||
1
Lib/OtterGui
Submodule
1
Lib/OtterGui
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 13f1a90b88d2b8572480748a209f957b70d6a46f
|
||||
26
QuestShare.Common/API/SessionStart.cs
Normal file
26
QuestShare.Common/API/SessionStart.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QuestShare.Common.API
|
||||
{
|
||||
public sealed class SessionStart : IAPIEndpoint<SessionStart.Request, SessionStart.Response>
|
||||
{
|
||||
public class Request : IRequest
|
||||
{
|
||||
public Request() { }
|
||||
public string Version { get; set; } = null!;
|
||||
public string Token { get; set; } = null!;
|
||||
public Objects.OwnedSession Session { get; set; } = null!;
|
||||
}
|
||||
public class Response : IResponse
|
||||
{
|
||||
public Response() { }
|
||||
public Error Error { get; set; } = Error.None;
|
||||
public required bool Success { get; set; }
|
||||
public Objects.OwnedSession? Session { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
28
QuestShare.Common/Errors.cs
Normal file
28
QuestShare.Common/Errors.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QuestShare.Common
|
||||
{
|
||||
public enum Error
|
||||
{
|
||||
None,
|
||||
InvalidToken,
|
||||
InvalidSession,
|
||||
InvalidVersion,
|
||||
InvalidQuests,
|
||||
JoinRequestFailed,
|
||||
Unauthorized,
|
||||
UnknownError,
|
||||
InternalServerError,
|
||||
InvalidNotifyType,
|
||||
InvalidParty,
|
||||
InvalidMember,
|
||||
InvalidQuest,
|
||||
BannedTooManyBadRequests,
|
||||
AlreadyRegistered,
|
||||
AlreadyJoined,
|
||||
}
|
||||
}
|
||||
27
QuestShare.Common/Interfaces.cs
Normal file
27
QuestShare.Common/Interfaces.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QuestShare.Common
|
||||
{
|
||||
public interface IRequest
|
||||
{
|
||||
string Version { get; set; }
|
||||
string Token { get; set; }
|
||||
}
|
||||
|
||||
public interface IResponse
|
||||
{
|
||||
Error Error { get; set; }
|
||||
bool Success { get; set; }
|
||||
}
|
||||
|
||||
public interface IAPIEndpoint<T1, T2> where T1 : IRequest where T2 : IResponse;
|
||||
|
||||
public interface IBroadcast
|
||||
{
|
||||
string Message { get; set; }
|
||||
}
|
||||
}
|
||||
44
QuestShare.Common/Objects.cs
Normal file
44
QuestShare.Common/Objects.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QuestShare.Common
|
||||
{
|
||||
public abstract class Objects
|
||||
{
|
||||
public record ShareCode
|
||||
{
|
||||
public required string Code { get; set; }
|
||||
public required string CharacterId { get; set; }
|
||||
}
|
||||
|
||||
public record Session
|
||||
{
|
||||
public required string ShareCode { get; set; }
|
||||
public required string OwnerCharacterId { get; set; }
|
||||
public int ActiveQuestId { get; set; }
|
||||
public byte ActiveQuestStep { get; set; }
|
||||
}
|
||||
|
||||
public record OwnedSession
|
||||
{
|
||||
public required Session Session { get; set; }
|
||||
public string ShareCode => Session.ShareCode;
|
||||
|
||||
[JsonIgnore]
|
||||
public string OwnerCharacterId => Session.OwnerCharacterId;
|
||||
|
||||
[JsonIgnore]
|
||||
public int ActiveQuestId => Session.ActiveQuestId;
|
||||
|
||||
[JsonIgnore]
|
||||
public byte ActiveQuestStep => Session.ActiveQuestStep;
|
||||
public required bool AllowJoins { get; set; }
|
||||
public required bool SkipPartyCheck { get; set; }
|
||||
public required bool IsActive { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
8
QuestShare.Dalamud/GlobalSuppressions.cs
Normal file
8
QuestShare.Dalamud/GlobalSuppressions.cs
Normal file
@ -0,0 +1,8 @@
|
||||
// This file is used by Code Analysis to maintain SuppressMessage
|
||||
// attributes that are applied to this project.
|
||||
// Project-level suppressions either have no target or are given
|
||||
// a specific target and scoped to a namespace, type, member, etc.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>", Scope = "member", Target = "~E:QuestShare.Services.ApiService.GroupJoined")]
|
||||
@ -13,6 +13,7 @@
|
||||
<Content Include="QuestShare.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Lib\OtterGui\OtterGui.csproj" />
|
||||
<ProjectReference Include="..\QuestShare.Common\QuestShare.Common.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Game.ClientState.Objects;
|
||||
|
||||
namespace QuestShare
|
||||
{
|
||||
@ -17,5 +18,6 @@ namespace QuestShare
|
||||
[PluginService] internal static IPartyList PartyList { get; private set; } = null!;
|
||||
[PluginService] internal static IAddonLifecycle AddonLifecycle { get; private set; } = null!;
|
||||
[PluginService] internal static IChatGui ChatGui { get; private set; } = null!;
|
||||
[PluginService] internal static ITargetManager Target { get; private set; } = null!;
|
||||
}
|
||||
}
|
||||
|
||||
40
QuestShare.Dalamud/Services/API/SessionStart.cs
Normal file
40
QuestShare.Dalamud/Services/API/SessionStart.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QuestShare.Services.API
|
||||
{
|
||||
internal class SessionStart_Client
|
||||
{
|
||||
public static void HandleDispatch(Objects.OwnedSession session)
|
||||
{
|
||||
var api = (ApiService)Plugin.GetService<ApiService>();
|
||||
var request = new SessionStart.Request
|
||||
{
|
||||
Version = Constants.Version,
|
||||
Token = ConfigurationManager.Instance.Token,
|
||||
Session = session
|
||||
};
|
||||
_ = api.Invoke(nameof(SessionStart), request);
|
||||
}
|
||||
|
||||
public static void HandleResponse(SessionStart.Response response)
|
||||
{
|
||||
if (response.Success)
|
||||
{
|
||||
Log.Information("Session started successfully");
|
||||
ConfigurationManager.Instance.OwnedSession = response.Session;
|
||||
ConfigurationManager.Save();
|
||||
HostService.UpdateParty();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"Failed to start session: {response.Error}");
|
||||
UiService.LastErrorMessage = $"Failed to start session: {response.Error}";
|
||||
_ = ((ApiService)Plugin.GetService<ApiService>()).Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
129
QuestShare.Dalamud/Services/HostService.cs
Normal file
129
QuestShare.Dalamud/Services/HostService.cs
Normal file
@ -0,0 +1,129 @@
|
||||
using Dalamud.Plugin.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QuestShare.Services
|
||||
{
|
||||
internal class HostService : IService
|
||||
{
|
||||
internal static Objects.OwnedSession? Session => ConfigurationManager.Instance.OwnedSession;
|
||||
internal static bool HostEnabled => ConfigurationManager.Instance.EnableHosting;
|
||||
internal static Objects.Session? ActiveSession => Session?.Session;
|
||||
internal static int ActiveQuestId => ActiveSession?.ActiveQuestId ?? 0;
|
||||
internal static byte ActiveQuestStep => ActiveSession?.ActiveQuestStep ?? 0;
|
||||
internal static bool IsHost => ActiveSession != null;
|
||||
internal static bool IsActive => Session?.IsActive ?? false;
|
||||
internal static bool AllowJoins => Session?.AllowJoins ?? true;
|
||||
internal static bool SkipPartyCheck => Session?.SkipPartyCheck ?? false;
|
||||
private ulong CharacterId { get; set; }
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
ClientState.Login += OnLogin;
|
||||
ClientState.Logout += OnLogout;
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
ClientState.Login -= OnLogin;
|
||||
ClientState.Logout -= OnLogout;
|
||||
}
|
||||
|
||||
private void OnLogin()
|
||||
{
|
||||
CharacterId = ClientState.LocalContentId;
|
||||
}
|
||||
|
||||
private void OnLogout(int _, int __)
|
||||
{
|
||||
CharacterId = 0;
|
||||
}
|
||||
|
||||
public void Start(string shareCode)
|
||||
{
|
||||
var session = new Objects.Session { OwnerCharacterId = CharacterId.ToString().SaltedHash(shareCode), ShareCode = shareCode, ActiveQuestId = ActiveQuestId, ActiveQuestStep = ActiveQuestStep };
|
||||
var ownedSession = new Objects.OwnedSession {
|
||||
AllowJoins = true,
|
||||
IsActive = true,
|
||||
SkipPartyCheck = false,
|
||||
Session = session,
|
||||
};
|
||||
ApiService.DispatchSessionStart(ownedSession);
|
||||
}
|
||||
|
||||
public static void Update(int questId, byte questStep)
|
||||
{
|
||||
if (ActiveSession == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ActiveSession.ActiveQuestId = questId;
|
||||
ActiveSession.ActiveQuestStep = questStep;
|
||||
Session!.Session = ActiveSession;
|
||||
var party = (PartyService)Plugin.GetService<PartyService>();
|
||||
var members = party.GetPartyMembers(ActiveSession);
|
||||
ApiService.DispatchUpdate(Session, members);
|
||||
}
|
||||
|
||||
private void ConfigChange()
|
||||
{
|
||||
var party = (PartyService)Plugin.GetService<PartyService>();
|
||||
var members = party.GetPartyMembers(ActiveSession!);
|
||||
ApiService.DispatchConfigChange(Session!, members);
|
||||
}
|
||||
|
||||
public static void UpdateParty()
|
||||
{
|
||||
if (ActiveSession == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var party = (PartyService)Plugin.GetService<PartyService>();
|
||||
var members = party.GetPartyMembers(ActiveSession);
|
||||
ApiService.DispatchConfigChange(Session!, members);
|
||||
}
|
||||
|
||||
public void SetIsActive(bool isActive)
|
||||
{
|
||||
if (Session == null || ActiveSession == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Session.IsActive = isActive;
|
||||
ConfigChange();
|
||||
}
|
||||
|
||||
public void SetAllowJoins(bool allowJoins)
|
||||
{
|
||||
if (Session == null || ActiveSession == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Session.AllowJoins = allowJoins;
|
||||
ConfigChange();
|
||||
}
|
||||
|
||||
public void SetSkipPartyCheck(bool skipPartyCheck)
|
||||
{
|
||||
if (Session == null || ActiveSession == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Session.SkipPartyCheck = skipPartyCheck;
|
||||
ConfigChange();
|
||||
}
|
||||
|
||||
public static void Cancel()
|
||||
{
|
||||
if (ActiveSession == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var api = (ApiService)Plugin.GetService<ApiService>();
|
||||
ApiService.DispatchCancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -49,6 +49,11 @@
|
||||
"System.Text.Json": "9.0.2"
|
||||
}
|
||||
},
|
||||
"JetBrains.Annotations": {
|
||||
"type": "Transitive",
|
||||
"resolved": "2024.3.0",
|
||||
"contentHash": "ox5pkeLQXjvJdyAB4b2sBYAlqZGLh3PjSnP1bQNVx72ONuTJ9+34/+Rq91Fc0dG29XG9RgZur9+NcP4riihTug=="
|
||||
},
|
||||
"Microsoft.AspNetCore.Connections.Abstractions": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.13",
|
||||
@ -232,6 +237,13 @@
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "CMaFr7v+57RW7uZfZkPExsPB6ljwzhjACWW1gfU35Y56rk72B/Wu+sTqxVmGSk4SFUlPc3cjeKND0zktziyjBA=="
|
||||
},
|
||||
"ottergui": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"JetBrains.Annotations": "[2024.3.0, )",
|
||||
"Microsoft.Extensions.DependencyInjection": "[9.0.2, )"
|
||||
}
|
||||
},
|
||||
"questshare.common": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
|
||||
71
QuestShare.Server/Hubs/Methods/SessionStart.cs
Normal file
71
QuestShare.Server/Hubs/Methods/SessionStart.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using QuestShare.Common;
|
||||
using QuestShare.Server.Managers;
|
||||
|
||||
namespace QuestShare.Server.Hubs
|
||||
{
|
||||
public partial class ShareHub : Hub
|
||||
{
|
||||
[HubMethodName(nameof(SessionStart))]
|
||||
public async Task Server_SessionStart(SessionStart.Request request)
|
||||
{
|
||||
if (BanManager.IsBanned(Context))
|
||||
{
|
||||
Log.Error($"[AUTHORIZE] Client {Context.ConnectionId} is banned.");
|
||||
Context.Abort();
|
||||
return;
|
||||
}
|
||||
var error = Error.None;
|
||||
var client = await ClientManager.GetClient(Context.ConnectionId, request.Token);
|
||||
if (client == null) error = Error.Unauthorized;
|
||||
var session = await SessionManager.GetSession(request.Session.Session.ShareCode);
|
||||
if (session == null) error = Error.InvalidSession;
|
||||
else
|
||||
{
|
||||
if (Context.ConnectionId != session.ReservedConnectionId)
|
||||
{
|
||||
error = Error.InvalidSession;
|
||||
}
|
||||
}
|
||||
if (error != Error.None)
|
||||
{
|
||||
await Clients.Caller.SendAsync(nameof(SessionStart), new SessionStart.Response
|
||||
{
|
||||
Error = error,
|
||||
Success = false
|
||||
});
|
||||
return;
|
||||
}
|
||||
var s = await SessionManager.CreateSession(client!, Context.ConnectionId, request.Session);
|
||||
if (s == null)
|
||||
{
|
||||
Log.Error($"[SessionStart] Unable to create session for {client!.Token} and {request.Session.Session.ShareCode}");
|
||||
await Clients.Caller.SendAsync(nameof(SessionStart), new SessionStart.Response
|
||||
{
|
||||
Error = Error.InternalServerError,
|
||||
Success = false
|
||||
});
|
||||
} else {
|
||||
Log.Debug($"[SessionStart] Created session {s.ShareCode} for {client!.Token}");
|
||||
var sObject = new Objects.Session
|
||||
{
|
||||
OwnerCharacterId = s.OwnerCharacterId,
|
||||
ShareCode = s.ShareCode,
|
||||
};
|
||||
var ownedSession = new Objects.OwnedSession
|
||||
{
|
||||
IsActive = s.IsActive,
|
||||
SkipPartyCheck = s.SkipPartyCheck,
|
||||
AllowJoins = s.AllowJoins,
|
||||
Session = sObject,
|
||||
};
|
||||
await Clients.Caller.SendAsync(nameof(SessionStart), new SessionStart.Response
|
||||
{
|
||||
Error = Error.None,
|
||||
Success = true,
|
||||
Session = ownedSession
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,133 +0,0 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace QuestShare.Server.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Bans",
|
||||
columns: table => new
|
||||
{
|
||||
BanId = table.Column<string>(type: "text", nullable: false),
|
||||
BanIp = table.Column<IPAddress>(type: "inet", nullable: false),
|
||||
BanCharacterId = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
BanReason = table.Column<string>(type: "text", nullable: false),
|
||||
BanIssuer = table.Column<string>(type: "text", nullable: false),
|
||||
BanDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
BanExpiry = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Bans", x => x.BanId);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
ClientId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
CharacterId = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
ConnectionId = table.Column<string>(type: "text", nullable: false),
|
||||
Token = table.Column<string>(type: "text", nullable: false),
|
||||
ConnectedShareCode = table.Column<string>(type: "text", nullable: false),
|
||||
Created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp"),
|
||||
LastUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.ClientId);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "QuestShares",
|
||||
columns: table => new
|
||||
{
|
||||
ShareId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ShareHostClientId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ShareCode = table.Column<string>(type: "text", nullable: false),
|
||||
BroadcastParty = table.Column<bool>(type: "boolean", nullable: false),
|
||||
Created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp"),
|
||||
LastUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_QuestShares", x => x.ShareId);
|
||||
table.ForeignKey(
|
||||
name: "FK_QuestShares_Clients_ShareHostClientId",
|
||||
column: x => x.ShareHostClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "ClientId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Quests",
|
||||
columns: table => new
|
||||
{
|
||||
QuestObjId = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
QuestId = table.Column<long>(type: "bigint", nullable: false),
|
||||
CurrentStep = table.Column<byte>(type: "smallint", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
||||
ShareId1 = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ShareId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Quests", x => x.QuestObjId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Quests_QuestShares_ShareId",
|
||||
column: x => x.ShareId,
|
||||
principalTable: "QuestShares",
|
||||
principalColumn: "ShareId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Quests_QuestShares_ShareId1",
|
||||
column: x => x.ShareId1,
|
||||
principalTable: "QuestShares",
|
||||
principalColumn: "ShareId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Quests_ShareId",
|
||||
table: "Quests",
|
||||
column: "ShareId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Quests_ShareId1",
|
||||
table: "Quests",
|
||||
column: "ShareId1");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_QuestShares_ShareHostClientId",
|
||||
table: "QuestShares",
|
||||
column: "ShareHostClientId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Bans");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Quests");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "QuestShares");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,148 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using System.Net;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using QuestShare.Server.Models;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace QuestShare.Server.Migrations
|
||||
{
|
||||
[DbContext(typeof(QuestShareContext))]
|
||||
[Migration("20250217033300_RefactorQuests")]
|
||||
partial class RefactorQuests
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.2")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("QuestShare.Server.Models.Ban", b =>
|
||||
{
|
||||
b.Property<string>("BanId")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<decimal>("BanCharacterId")
|
||||
.HasColumnType("numeric(20,0)");
|
||||
|
||||
b.Property<DateTime>("BanDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("BanExpiry")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<IPAddress>("BanIp")
|
||||
.IsRequired()
|
||||
.HasColumnType("inet");
|
||||
|
||||
b.Property<string>("BanIssuer")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("BanReason")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("BanId");
|
||||
|
||||
b.ToTable("Bans", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestShare.Server.Models.Client", b =>
|
||||
{
|
||||
b.Property<Guid>("ClientId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<decimal>("CharacterId")
|
||||
.HasColumnType("numeric(20,0)");
|
||||
|
||||
b.Property<string>("ConnectedShareCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ConnectionId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("current_timestamp");
|
||||
|
||||
b.Property<DateTime>("LastUpdated")
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("current_timestamp");
|
||||
|
||||
b.Property<string>("Token")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("ClientId");
|
||||
|
||||
b.ToTable("Clients", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestShare.Server.Models.Share", b =>
|
||||
{
|
||||
b.Property<Guid>("ShareId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<bool>("BroadcastParty")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("current_timestamp");
|
||||
|
||||
b.Property<DateTime>("LastUpdated")
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("current_timestamp");
|
||||
|
||||
b.Property<string>("ShareCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("ShareHostClientId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<long>("SharedQuestId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<byte>("SharedQuestStep")
|
||||
.HasColumnType("smallint");
|
||||
|
||||
b.HasKey("ShareId");
|
||||
|
||||
b.HasIndex("ShareHostClientId");
|
||||
|
||||
b.ToTable("QuestShares", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestShare.Server.Models.Share", b =>
|
||||
{
|
||||
b.HasOne("QuestShare.Server.Models.Client", "ShareHost")
|
||||
.WithMany()
|
||||
.HasForeignKey("ShareHostClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ShareHost");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,84 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace QuestShare.Server.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class RefactorQuests : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Quests");
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "SharedQuestId",
|
||||
table: "QuestShares",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<byte>(
|
||||
name: "SharedQuestStep",
|
||||
table: "QuestShares",
|
||||
type: "smallint",
|
||||
nullable: false,
|
||||
defaultValue: (byte)0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SharedQuestId",
|
||||
table: "QuestShares");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SharedQuestStep",
|
||||
table: "QuestShares");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Quests",
|
||||
columns: table => new
|
||||
{
|
||||
QuestObjId = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ShareId1 = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
CurrentStep = table.Column<byte>(type: "smallint", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
||||
QuestId = table.Column<long>(type: "bigint", nullable: false),
|
||||
ShareId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Quests", x => x.QuestObjId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Quests_QuestShares_ShareId",
|
||||
column: x => x.ShareId,
|
||||
principalTable: "QuestShares",
|
||||
principalColumn: "ShareId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Quests_QuestShares_ShareId1",
|
||||
column: x => x.ShareId1,
|
||||
principalTable: "QuestShares",
|
||||
principalColumn: "ShareId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Quests_ShareId",
|
||||
table: "Quests",
|
||||
column: "ShareId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Quests_ShareId1",
|
||||
table: "Quests",
|
||||
column: "ShareId1");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -13,8 +13,8 @@ using QuestShare.Server.Models;
|
||||
namespace QuestShare.Server.Migrations
|
||||
{
|
||||
[DbContext(typeof(QuestShareContext))]
|
||||
[Migration("20250217022911_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
[Migration("20250301212836_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -63,13 +63,6 @@ namespace QuestShare.Server.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<decimal>("CharacterId")
|
||||
.HasColumnType("numeric(20,0)");
|
||||
|
||||
b.Property<string>("ConnectedShareCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ConnectionId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
@ -79,63 +72,102 @@ namespace QuestShare.Server.Migrations
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("current_timestamp");
|
||||
|
||||
b.Property<string>("KnownShareCodes")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("LastUpdated")
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("current_timestamp");
|
||||
|
||||
b.Property<Guid?>("SessionMemberClientSessionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Token")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("ClientId");
|
||||
|
||||
b.HasIndex("SessionMemberClientSessionId");
|
||||
|
||||
b.ToTable("Clients", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestShare.Server.Models.Quest", b =>
|
||||
modelBuilder.Entity("QuestShare.Server.Models.Session", b =>
|
||||
{
|
||||
b.Property<int>("QuestObjId")
|
||||
b.Property<Guid>("SessionId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
.HasColumnType("uuid");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("QuestObjId"));
|
||||
b.Property<bool>("AllowJoins")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<byte>("CurrentStep")
|
||||
.HasColumnType("smallint");
|
||||
b.Property<DateTime>("Created")
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("current_timestamp");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<long>("QuestId")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<DateTime>("LastUpdated")
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("current_timestamp");
|
||||
|
||||
b.Property<Guid>("ShareId")
|
||||
b.Property<string>("OwnerCharacterId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("OwnerClientId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("ShareId1")
|
||||
b.Property<string>("PartyMembers")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ReservedConnectionId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("SessionMemberClientSessionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("QuestObjId");
|
||||
b.Property<string>("ShareCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasIndex("ShareId");
|
||||
b.Property<int>("SharedQuestId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasIndex("ShareId1");
|
||||
b.Property<byte>("SharedQuestStep")
|
||||
.HasColumnType("smallint");
|
||||
|
||||
b.ToTable("Quests", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestShare.Server.Models.Share", b =>
|
||||
{
|
||||
b.Property<Guid>("ShareId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<bool>("BroadcastParty")
|
||||
b.Property<bool>("SkipPartyCheck")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
b.HasKey("SessionId");
|
||||
|
||||
b.HasIndex("OwnerClientId");
|
||||
|
||||
b.HasIndex("SessionMemberClientSessionId");
|
||||
|
||||
b.ToTable("Sessions", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestShare.Server.Models.SessionMember", b =>
|
||||
{
|
||||
b.Property<Guid>("ClientSessionId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("ClientId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("current_timestamp");
|
||||
|
||||
@ -144,51 +176,57 @@ namespace QuestShare.Server.Migrations
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("current_timestamp");
|
||||
|
||||
b.Property<string>("ShareCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("ShareHostClientId")
|
||||
b.Property<Guid>("SessionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("ShareId");
|
||||
b.HasKey("ClientSessionId");
|
||||
|
||||
b.HasIndex("ShareHostClientId");
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("QuestShares", (string)null);
|
||||
b.HasIndex("SessionId");
|
||||
|
||||
b.ToTable("SessionMembers", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestShare.Server.Models.Quest", b =>
|
||||
modelBuilder.Entity("QuestShare.Server.Models.Client", b =>
|
||||
{
|
||||
b.HasOne("QuestShare.Server.Models.Share", null)
|
||||
.WithMany("Quests")
|
||||
.HasForeignKey("ShareId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("QuestShare.Server.Models.Share", "Share")
|
||||
b.HasOne("QuestShare.Server.Models.SessionMember", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("ShareId1")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Share");
|
||||
.HasForeignKey("SessionMemberClientSessionId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestShare.Server.Models.Share", b =>
|
||||
modelBuilder.Entity("QuestShare.Server.Models.Session", b =>
|
||||
{
|
||||
b.HasOne("QuestShare.Server.Models.Client", "ShareHost")
|
||||
b.HasOne("QuestShare.Server.Models.Client", "Owner")
|
||||
.WithMany()
|
||||
.HasForeignKey("ShareHostClientId")
|
||||
.HasForeignKey("OwnerClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ShareHost");
|
||||
b.HasOne("QuestShare.Server.Models.SessionMember", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("SessionMemberClientSessionId");
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestShare.Server.Models.Share", b =>
|
||||
modelBuilder.Entity("QuestShare.Server.Models.SessionMember", b =>
|
||||
{
|
||||
b.Navigation("Quests");
|
||||
b.HasOne("QuestShare.Server.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("QuestShare.Server.Models.Session", "Session")
|
||||
.WithMany()
|
||||
.HasForeignKey("SessionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Session");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
170
QuestShare.Server/Migrations/20250301212836_Initial.cs
Normal file
170
QuestShare.Server/Migrations/20250301212836_Initial.cs
Normal file
@ -0,0 +1,170 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace QuestShare.Server.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Bans",
|
||||
columns: table => new
|
||||
{
|
||||
BanId = table.Column<string>(type: "text", nullable: false),
|
||||
BanIp = table.Column<IPAddress>(type: "inet", nullable: false),
|
||||
BanCharacterId = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
BanReason = table.Column<string>(type: "text", nullable: false),
|
||||
BanIssuer = table.Column<string>(type: "text", nullable: false),
|
||||
BanDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
BanExpiry = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Bans", x => x.BanId);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
ClientId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ConnectionId = table.Column<string>(type: "text", nullable: false),
|
||||
Token = table.Column<string>(type: "text", nullable: false),
|
||||
KnownShareCodes = table.Column<string>(type: "text", nullable: false),
|
||||
Created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp"),
|
||||
LastUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp"),
|
||||
SessionMemberClientSessionId = table.Column<Guid>(type: "uuid", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.ClientId);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SessionMembers",
|
||||
columns: table => new
|
||||
{
|
||||
ClientSessionId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ClientId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
SessionId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp"),
|
||||
LastUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SessionMembers", x => x.ClientSessionId);
|
||||
table.ForeignKey(
|
||||
name: "FK_SessionMembers_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "ClientId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Sessions",
|
||||
columns: table => new
|
||||
{
|
||||
SessionId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
OwnerCharacterId = table.Column<string>(type: "text", nullable: false),
|
||||
OwnerClientId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ShareCode = table.Column<string>(type: "text", nullable: false),
|
||||
ReservedConnectionId = table.Column<string>(type: "text", nullable: false),
|
||||
SharedQuestId = table.Column<int>(type: "integer", nullable: false),
|
||||
SharedQuestStep = table.Column<byte>(type: "smallint", nullable: false),
|
||||
PartyMembers = table.Column<string>(type: "text", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
||||
SkipPartyCheck = table.Column<bool>(type: "boolean", nullable: false),
|
||||
AllowJoins = table.Column<bool>(type: "boolean", nullable: false),
|
||||
Created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp"),
|
||||
LastUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp"),
|
||||
SessionMemberClientSessionId = table.Column<Guid>(type: "uuid", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Sessions", x => x.SessionId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Sessions_Clients_OwnerClientId",
|
||||
column: x => x.OwnerClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "ClientId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Sessions_SessionMembers_SessionMemberClientSessionId",
|
||||
column: x => x.SessionMemberClientSessionId,
|
||||
principalTable: "SessionMembers",
|
||||
principalColumn: "ClientSessionId");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Clients_SessionMemberClientSessionId",
|
||||
table: "Clients",
|
||||
column: "SessionMemberClientSessionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SessionMembers_ClientId",
|
||||
table: "SessionMembers",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SessionMembers_SessionId",
|
||||
table: "SessionMembers",
|
||||
column: "SessionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Sessions_OwnerClientId",
|
||||
table: "Sessions",
|
||||
column: "OwnerClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Sessions_SessionMemberClientSessionId",
|
||||
table: "Sessions",
|
||||
column: "SessionMemberClientSessionId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Clients_SessionMembers_SessionMemberClientSessionId",
|
||||
table: "Clients",
|
||||
column: "SessionMemberClientSessionId",
|
||||
principalTable: "SessionMembers",
|
||||
principalColumn: "ClientSessionId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_SessionMembers_Sessions_SessionId",
|
||||
table: "SessionMembers",
|
||||
column: "SessionId",
|
||||
principalTable: "Sessions",
|
||||
principalColumn: "SessionId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Clients_SessionMembers_SessionMemberClientSessionId",
|
||||
table: "Clients");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Sessions_SessionMembers_SessionMemberClientSessionId",
|
||||
table: "Sessions");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Bans");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SessionMembers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Sessions");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
}
|
||||
}
|
||||
}
|
||||
31
QuestShare.Server/Models/SessionMember.cs
Normal file
31
QuestShare.Server/Models/SessionMember.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Newtonsoft.Json;
|
||||
using QuestShare.Common;
|
||||
|
||||
namespace QuestShare.Server.Models
|
||||
{
|
||||
public class SessionMember
|
||||
{
|
||||
public Guid ClientSessionId { get; set; }
|
||||
public required Client Client { get; set; }
|
||||
public required Session Session { get; set; }
|
||||
// public required string CharacterId { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime LastUpdated { get; set; }
|
||||
}
|
||||
|
||||
internal class ClientSessionConfiguration : IEntityTypeConfiguration<SessionMember>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<SessionMember> builder)
|
||||
{
|
||||
builder.ToTable("SessionMembers");
|
||||
builder.HasKey(cs => cs.ClientSessionId);
|
||||
builder.HasMany<Client>();
|
||||
builder.HasMany<Session>();
|
||||
builder.Property(cs => cs.Created).HasDefaultValueSql("current_timestamp").ValueGeneratedOnAddOrUpdate();
|
||||
builder.Property(cs => cs.LastUpdated).HasDefaultValueSql("current_timestamp").ValueGeneratedOnAddOrUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -64,11 +64,6 @@ namespace QuestShare.Server
|
||||
}
|
||||
var app = builder.Build();
|
||||
Log.Information($"Starting QuestShare Server - API Version {Constants.Version}");
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var context = scope.ServiceProvider.GetRequiredService<QuestShareContext>();
|
||||
await context.Database.MigrateAsync();
|
||||
}
|
||||
app.Run();
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
plogonmaster.json = plogonmaster.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OtterGui", "Lib\OtterGui\OtterGui.csproj", "{55C9C0E4-CD7B-4A76-B666-E25A00EA44F7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@ -31,6 +33,10 @@ Global
|
||||
{7A4BDE00-BF8F-4A09-8363-6434609B6865}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{7A4BDE00-BF8F-4A09-8363-6434609B6865}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{7A4BDE00-BF8F-4A09-8363-6434609B6865}.Release|x64.Build.0 = Release|Any CPU
|
||||
{55C9C0E4-CD7B-4A76-B666-E25A00EA44F7}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{55C9C0E4-CD7B-4A76-B666-E25A00EA44F7}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{55C9C0E4-CD7B-4A76-B666-E25A00EA44F7}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{55C9C0E4-CD7B-4A76-B666-E25A00EA44F7}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user