Compare commits
No commits in common. "93231e541945668b5bdf4a85d82c9ebf4676940d" and "0fa985336fa7c8084168ddda6faa18ab634716cc" have entirely different histories.
93231e5419
...
0fa985336f
0
Data/.gitkeep
Normal file
0
Data/.gitkeep
Normal file
@ -1,26 +0,0 @@
|
|||||||
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; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
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,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
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; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
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; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
// 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,7 +13,6 @@
|
|||||||
<Content Include="QuestShare.json" />
|
<Content Include="QuestShare.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Lib\OtterGui\OtterGui.csproj" />
|
|
||||||
<ProjectReference Include="..\QuestShare.Common\QuestShare.Common.csproj" />
|
<ProjectReference Include="..\QuestShare.Common\QuestShare.Common.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using Dalamud.Game.ClientState.Objects;
|
|
||||||
|
|
||||||
namespace QuestShare
|
namespace QuestShare
|
||||||
{
|
{
|
||||||
@ -18,6 +17,5 @@ namespace QuestShare
|
|||||||
[PluginService] internal static IPartyList PartyList { get; private set; } = null!;
|
[PluginService] internal static IPartyList PartyList { get; private set; } = null!;
|
||||||
[PluginService] internal static IAddonLifecycle AddonLifecycle { 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 IChatGui ChatGui { get; private set; } = null!;
|
||||||
[PluginService] internal static ITargetManager Target { get; private set; } = null!;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,40 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,129 +0,0 @@
|
|||||||
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,11 +49,6 @@
|
|||||||
"System.Text.Json": "9.0.2"
|
"System.Text.Json": "9.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"JetBrains.Annotations": {
|
|
||||||
"type": "Transitive",
|
|
||||||
"resolved": "2024.3.0",
|
|
||||||
"contentHash": "ox5pkeLQXjvJdyAB4b2sBYAlqZGLh3PjSnP1bQNVx72ONuTJ9+34/+Rq91Fc0dG29XG9RgZur9+NcP4riihTug=="
|
|
||||||
},
|
|
||||||
"Microsoft.AspNetCore.Connections.Abstractions": {
|
"Microsoft.AspNetCore.Connections.Abstractions": {
|
||||||
"type": "Transitive",
|
"type": "Transitive",
|
||||||
"resolved": "8.0.13",
|
"resolved": "8.0.13",
|
||||||
@ -237,13 +232,6 @@
|
|||||||
"resolved": "8.0.0",
|
"resolved": "8.0.0",
|
||||||
"contentHash": "CMaFr7v+57RW7uZfZkPExsPB6ljwzhjACWW1gfU35Y56rk72B/Wu+sTqxVmGSk4SFUlPc3cjeKND0zktziyjBA=="
|
"contentHash": "CMaFr7v+57RW7uZfZkPExsPB6ljwzhjACWW1gfU35Y56rk72B/Wu+sTqxVmGSk4SFUlPc3cjeKND0zktziyjBA=="
|
||||||
},
|
},
|
||||||
"ottergui": {
|
|
||||||
"type": "Project",
|
|
||||||
"dependencies": {
|
|
||||||
"JetBrains.Annotations": "[2024.3.0, )",
|
|
||||||
"Microsoft.Extensions.DependencyInjection": "[9.0.2, )"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"questshare.common": {
|
"questshare.common": {
|
||||||
"type": "Project",
|
"type": "Project",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@ -1,71 +0,0 @@
|
|||||||
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
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -13,8 +13,8 @@ using QuestShare.Server.Models;
|
|||||||
namespace QuestShare.Server.Migrations
|
namespace QuestShare.Server.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(QuestShareContext))]
|
[DbContext(typeof(QuestShareContext))]
|
||||||
[Migration("20250301212836_Initial")]
|
[Migration("20250217022911_InitialCreate")]
|
||||||
partial class Initial
|
partial class InitialCreate
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -63,6 +63,13 @@ namespace QuestShare.Server.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<decimal>("CharacterId")
|
||||||
|
.HasColumnType("numeric(20,0)");
|
||||||
|
|
||||||
|
b.Property<string>("ConnectedShareCode")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("ConnectionId")
|
b.Property<string>("ConnectionId")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@ -72,161 +79,116 @@ namespace QuestShare.Server.Migrations
|
|||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasDefaultValueSql("current_timestamp");
|
.HasDefaultValueSql("current_timestamp");
|
||||||
|
|
||||||
b.Property<string>("KnownShareCodes")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTime>("LastUpdated")
|
b.Property<DateTime>("LastUpdated")
|
||||||
.ValueGeneratedOnAddOrUpdate()
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasDefaultValueSql("current_timestamp");
|
.HasDefaultValueSql("current_timestamp");
|
||||||
|
|
||||||
b.Property<Guid?>("SessionMemberClientSessionId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Token")
|
b.Property<string>("Token")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.HasKey("ClientId");
|
b.HasKey("ClientId");
|
||||||
|
|
||||||
b.HasIndex("SessionMemberClientSessionId");
|
|
||||||
|
|
||||||
b.ToTable("Clients", (string)null);
|
b.ToTable("Clients", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("QuestShare.Server.Models.Session", b =>
|
modelBuilder.Entity("QuestShare.Server.Models.Quest", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("SessionId")
|
b.Property<int>("QuestObjId")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<bool>("AllowJoins")
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("QuestObjId"));
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Created")
|
b.Property<byte>("CurrentStep")
|
||||||
.ValueGeneratedOnAddOrUpdate()
|
.HasColumnType("smallint");
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("current_timestamp");
|
|
||||||
|
|
||||||
b.Property<bool>("IsActive")
|
b.Property<bool>("IsActive")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<long>("QuestId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<Guid>("ShareId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("ShareId1")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("QuestObjId");
|
||||||
|
|
||||||
|
b.HasIndex("ShareId");
|
||||||
|
|
||||||
|
b.HasIndex("ShareId1");
|
||||||
|
|
||||||
|
b.ToTable("Quests", (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")
|
b.Property<DateTime>("LastUpdated")
|
||||||
.ValueGeneratedOnAddOrUpdate()
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasDefaultValueSql("current_timestamp");
|
.HasDefaultValueSql("current_timestamp");
|
||||||
|
|
||||||
b.Property<string>("OwnerCharacterId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<Guid>("OwnerClientId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("PartyMembers")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ReservedConnectionId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<Guid?>("SessionMemberClientSessionId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("ShareCode")
|
b.Property<string>("ShareCode")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<int>("SharedQuestId")
|
b.Property<Guid>("ShareHostClientId")
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<byte>("SharedQuestStep")
|
|
||||||
.HasColumnType("smallint");
|
|
||||||
|
|
||||||
b.Property<bool>("SkipPartyCheck")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
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");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("ClientId")
|
b.HasKey("ShareId");
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Created")
|
b.HasIndex("ShareHostClientId");
|
||||||
.ValueGeneratedOnAddOrUpdate()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("current_timestamp");
|
|
||||||
|
|
||||||
b.Property<DateTime>("LastUpdated")
|
b.ToTable("QuestShares", (string)null);
|
||||||
.ValueGeneratedOnAddOrUpdate()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("current_timestamp");
|
|
||||||
|
|
||||||
b.Property<Guid>("SessionId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("ClientSessionId");
|
|
||||||
|
|
||||||
b.HasIndex("ClientId");
|
|
||||||
|
|
||||||
b.HasIndex("SessionId");
|
|
||||||
|
|
||||||
b.ToTable("SessionMembers", (string)null);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("QuestShare.Server.Models.Client", b =>
|
modelBuilder.Entity("QuestShare.Server.Models.Quest", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("QuestShare.Server.Models.SessionMember", null)
|
b.HasOne("QuestShare.Server.Models.Share", null)
|
||||||
.WithMany()
|
.WithMany("Quests")
|
||||||
.HasForeignKey("SessionMemberClientSessionId");
|
.HasForeignKey("ShareId")
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("QuestShare.Server.Models.Session", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("QuestShare.Server.Models.Client", "Owner")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("OwnerClientId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("QuestShare.Server.Models.SessionMember", null)
|
b.HasOne("QuestShare.Server.Models.Share", "Share")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("SessionMemberClientSessionId");
|
.HasForeignKey("ShareId1")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Owner");
|
b.Navigation("Share");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("QuestShare.Server.Models.SessionMember", b =>
|
modelBuilder.Entity("QuestShare.Server.Models.Share", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("QuestShare.Server.Models.Client", "Client")
|
b.HasOne("QuestShare.Server.Models.Client", "ShareHost")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("ClientId")
|
.HasForeignKey("ShareHostClientId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("QuestShare.Server.Models.Session", "Session")
|
b.Navigation("ShareHost");
|
||||||
.WithMany()
|
});
|
||||||
.HasForeignKey("SessionId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Client");
|
modelBuilder.Entity("QuestShare.Server.Models.Share", b =>
|
||||||
|
{
|
||||||
b.Navigation("Session");
|
b.Navigation("Quests");
|
||||||
});
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
133
QuestShare.Server/Migrations/20250217022911_InitialCreate.cs
Normal file
133
QuestShare.Server/Migrations/20250217022911_InitialCreate.cs
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
148
QuestShare.Server/Migrations/20250217033300_RefactorQuests.Designer.cs
generated
Normal file
148
QuestShare.Server/Migrations/20250217033300_RefactorQuests.Designer.cs
generated
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
// <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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,84 @@
|
|||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,170 +0,0 @@
|
|||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
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,6 +64,11 @@ namespace QuestShare.Server
|
|||||||
}
|
}
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
Log.Information($"Starting QuestShare Server - API Version {Constants.Version}");
|
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();
|
app.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,8 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
plogonmaster.json = plogonmaster.json
|
plogonmaster.json = plogonmaster.json
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OtterGui", "Lib\OtterGui\OtterGui.csproj", "{55C9C0E4-CD7B-4A76-B666-E25A00EA44F7}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
@ -33,10 +31,6 @@ Global
|
|||||||
{7A4BDE00-BF8F-4A09-8363-6434609B6865}.Debug|x64.Build.0 = Debug|Any CPU
|
{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.ActiveCfg = Release|Any CPU
|
||||||
{7A4BDE00-BF8F-4A09-8363-6434609B6865}.Release|x64.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user