From 7665e02f2cf038443af3a3b85a0a0b71002161aa Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Sat, 8 Oct 2022 14:01:37 +0100
Subject: [PATCH 01/18] Service installer will now ask to remove old ones
---
src/Tgstation.Server.Host.Service/Program.cs | 26 ++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/Tgstation.Server.Host.Service/Program.cs b/src/Tgstation.Server.Host.Service/Program.cs
index 9056e67f70..f313cba287 100644
--- a/src/Tgstation.Server.Host.Service/Program.cs
+++ b/src/Tgstation.Server.Host.Service/Program.cs
@@ -118,6 +118,32 @@ namespace Tgstation.Server.Host.Service
{
if (Uninstall)
return; // oh no, it's retarded...
+
+ // First check if the service already exists
+ foreach (ServiceController sc in ServiceController.GetServices())
+ {
+ if (sc.ServiceName == "tgstation-server" || sc.ServiceName == "tgstation-server-4")
+ {
+ DialogResult result = MessageBox.Show($"You already have another TGS service installed ({sc.ServiceName}). Would you like to uninstall it now? Pressing \"No\" will cancel this install.", "TGS Service", MessageBoxButtons.YesNo);
+ if (result != DialogResult.Yes)
+ {
+ Environment.Exit(1);
+ return; // is this needed after exit?
+ }
+
+ // Stop it first to give it some cleanup time
+ if (sc.Status == ServiceControllerStatus.Running)
+ sc.Stop();
+
+ // And remove it
+ using (ServiceInstaller si = new ServiceInstaller()) {
+ si.Context = new InstallContext($"old-{sc.ServiceName}-uninstall.log", null);
+ si.ServiceName = ServerService.Name;
+ si.Uninstall(null);
+ }
+ }
+ }
+
using (var processInstaller = new ServiceProcessInstaller())
using (var installer = new ServiceInstaller())
{
From 48a6e5e8e7a4b3f7145628748fd0c7dcf964b3dd Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Sat, 8 Oct 2022 14:04:07 +0100
Subject: [PATCH 02/18] Style
---
src/Tgstation.Server.Host.Service/Program.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Tgstation.Server.Host.Service/Program.cs b/src/Tgstation.Server.Host.Service/Program.cs
index f313cba287..62e4678903 100644
--- a/src/Tgstation.Server.Host.Service/Program.cs
+++ b/src/Tgstation.Server.Host.Service/Program.cs
@@ -136,7 +136,8 @@ namespace Tgstation.Server.Host.Service
sc.Stop();
// And remove it
- using (ServiceInstaller si = new ServiceInstaller()) {
+ using (ServiceInstaller si = new ServiceInstaller())
+ {
si.Context = new InstallContext($"old-{sc.ServiceName}-uninstall.log", null);
si.ServiceName = ServerService.Name;
si.Uninstall(null);
From 6fc13cff70980a4dae1046efaddf7d2f1680a17a Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Sat, 8 Oct 2022 14:36:16 +0100
Subject: [PATCH 03/18] Try this
---
src/Tgstation.Server.Host.Service/Program.cs | 34 +++++++++++---------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/src/Tgstation.Server.Host.Service/Program.cs b/src/Tgstation.Server.Host.Service/Program.cs
index 62e4678903..40baaadd9d 100644
--- a/src/Tgstation.Server.Host.Service/Program.cs
+++ b/src/Tgstation.Server.Host.Service/Program.cs
@@ -120,27 +120,29 @@ namespace Tgstation.Server.Host.Service
return; // oh no, it's retarded...
// First check if the service already exists
- foreach (ServiceController sc in ServiceController.GetServices())
+ if (Environment.UserInteractive)
{
- if (sc.ServiceName == "tgstation-server" || sc.ServiceName == "tgstation-server-4")
+ foreach (ServiceController sc in ServiceController.GetServices())
{
- DialogResult result = MessageBox.Show($"You already have another TGS service installed ({sc.ServiceName}). Would you like to uninstall it now? Pressing \"No\" will cancel this install.", "TGS Service", MessageBoxButtons.YesNo);
- if (result != DialogResult.Yes)
+ if (sc.ServiceName == "tgstation-server" || sc.ServiceName == "tgstation-server-4")
{
- Environment.Exit(1);
- return; // is this needed after exit?
- }
+ DialogResult result = MessageBox.Show($"You already have another TGS service installed ({sc.ServiceName}). Would you like to uninstall it now? Pressing \"No\" will cancel this install.", "TGS Service", MessageBoxButtons.YesNo);
+ if (result != DialogResult.Yes)
+ {
+ return; // is this needed after exit?
+ }
- // Stop it first to give it some cleanup time
- if (sc.Status == ServiceControllerStatus.Running)
- sc.Stop();
+ // Stop it first to give it some cleanup time
+ if (sc.Status == ServiceControllerStatus.Running)
+ sc.Stop();
- // And remove it
- using (ServiceInstaller si = new ServiceInstaller())
- {
- si.Context = new InstallContext($"old-{sc.ServiceName}-uninstall.log", null);
- si.ServiceName = ServerService.Name;
- si.Uninstall(null);
+ // And remove it
+ using (ServiceInstaller si = new ServiceInstaller())
+ {
+ si.Context = new InstallContext($"old-{sc.ServiceName}-uninstall.log", null);
+ si.ServiceName = ServerService.Name;
+ si.Uninstall(null);
+ }
}
}
}
From a68073769bbfa8fffe8f1c8db2b5e00f83cdf2ba Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Sat, 8 Oct 2022 15:07:20 +0100
Subject: [PATCH 04/18] Nits
---
src/Tgstation.Server.Host.Service/Program.cs | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/Tgstation.Server.Host.Service/Program.cs b/src/Tgstation.Server.Host.Service/Program.cs
index 40baaadd9d..33f40c9ba2 100644
--- a/src/Tgstation.Server.Host.Service/Program.cs
+++ b/src/Tgstation.Server.Host.Service/Program.cs
@@ -121,20 +121,19 @@ namespace Tgstation.Server.Host.Service
// First check if the service already exists
if (Environment.UserInteractive)
- {
foreach (ServiceController sc in ServiceController.GetServices())
- {
if (sc.ServiceName == "tgstation-server" || sc.ServiceName == "tgstation-server-4")
{
DialogResult result = MessageBox.Show($"You already have another TGS service installed ({sc.ServiceName}). Would you like to uninstall it now? Pressing \"No\" will cancel this install.", "TGS Service", MessageBoxButtons.YesNo);
if (result != DialogResult.Yes)
- {
return; // is this needed after exit?
- }
// Stop it first to give it some cleanup time
if (sc.Status == ServiceControllerStatus.Running)
+ {
sc.Stop();
+ sc.WaitForStatus(ServiceControllerStatus.Stopped);
+ }
// And remove it
using (ServiceInstaller si = new ServiceInstaller())
@@ -144,8 +143,6 @@ namespace Tgstation.Server.Host.Service
si.Uninstall(null);
}
}
- }
- }
using (var processInstaller = new ServiceProcessInstaller())
using (var installer = new ServiceInstaller())
From f94d04488c594c395b9bf9d67d76317b1b15d826 Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Sat, 8 Oct 2022 15:17:25 +0100
Subject: [PATCH 05/18] I am not smart
---
src/Tgstation.Server.Host.Service/Program.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Tgstation.Server.Host.Service/Program.cs b/src/Tgstation.Server.Host.Service/Program.cs
index 33f40c9ba2..673accd9a0 100644
--- a/src/Tgstation.Server.Host.Service/Program.cs
+++ b/src/Tgstation.Server.Host.Service/Program.cs
@@ -139,7 +139,7 @@ namespace Tgstation.Server.Host.Service
using (ServiceInstaller si = new ServiceInstaller())
{
si.Context = new InstallContext($"old-{sc.ServiceName}-uninstall.log", null);
- si.ServiceName = ServerService.Name;
+ si.ServiceName = sc.ServiceName;
si.Uninstall(null);
}
}
From e346238472aa16a1f39d70f82bb6c3bd805812ec Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Thu, 27 Oct 2022 18:13:11 +0100
Subject: [PATCH 06/18] DMAPI 515 compat for TGS3
---
build/Version.props | 2 +-
src/DMAPI/tgs.dm | 2 +-
src/DMAPI/tgs/v3210/api.dm | 4 ++++
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/build/Version.props b/build/Version.props
index 2cab724f17..e8cb350332 100644
--- a/build/Version.props
+++ b/build/Version.props
@@ -8,7 +8,7 @@
9.7.0
10.1.0
11.1.0
- 6.0.5
+ 6.0.6
5.3.0
1.2.0
1.2.0
diff --git a/src/DMAPI/tgs.dm b/src/DMAPI/tgs.dm
index 51bf6e66f7..83e06658c5 100644
--- a/src/DMAPI/tgs.dm
+++ b/src/DMAPI/tgs.dm
@@ -1,6 +1,6 @@
// tgstation-server DMAPI
-#define TGS_DMAPI_VERSION "6.0.5"
+#define TGS_DMAPI_VERSION "6.0.6"
// All functions and datums outside this document are subject to change with any version and should not be relied on.
diff --git a/src/DMAPI/tgs/v3210/api.dm b/src/DMAPI/tgs/v3210/api.dm
index 9bcc801897..3c218d5b10 100644
--- a/src/DMAPI/tgs/v3210/api.dm
+++ b/src/DMAPI/tgs/v3210/api.dm
@@ -99,7 +99,11 @@
if(skip_compat_check && !fexists(SERVICE_INTERFACE_DLL))
TGS_ERROR_LOG("Service parameter present but no interface DLL detected. This is symptomatic of running a service less than version 3.1! Please upgrade.")
return
+ #if DM_VERSION >= 515
+ call_ext(SERVICE_INTERFACE_DLL, SERVICE_INTERFACE_FUNCTION)(instance_name, command) //trust no retval
+ #else
call(SERVICE_INTERFACE_DLL, SERVICE_INTERFACE_FUNCTION)(instance_name, command) //trust no retval
+ #endif
return TRUE
/datum/tgs_api/v3210/OnTopic(T)
From 9a7c8d44ba29aebcffc7c0cc7768185a7297e9a3 Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Thu, 27 Oct 2022 18:20:44 +0100
Subject: [PATCH 07/18] Bump bump
---
.github/workflows/ci-suite.yml | 4 ++--
tests/Tgstation.Server.Tests/Instance/ByondTest.cs | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/ci-suite.yml b/.github/workflows/ci-suite.yml
index c00b2cb4e4..43714e3cf8 100644
--- a/.github/workflows/ci-suite.yml
+++ b/.github/workflows/ci-suite.yml
@@ -51,8 +51,8 @@ jobs:
dmapi-build:
name: Build DMAPI
env:
- BYOND_MAJOR: 513
- BYOND_MINOR: 1536
+ BYOND_MAJOR: 515
+ BYOND_MINOR: 1592
runs-on: ubuntu-latest
steps:
- name: Install x86 libc Dependencies
diff --git a/tests/Tgstation.Server.Tests/Instance/ByondTest.cs b/tests/Tgstation.Server.Tests/Instance/ByondTest.cs
index db83ca4ad3..92dca4144d 100644
--- a/tests/Tgstation.Server.Tests/Instance/ByondTest.cs
+++ b/tests/Tgstation.Server.Tests/Instance/ByondTest.cs
@@ -22,7 +22,7 @@ namespace Tgstation.Server.Tests.Instance
{
sealed class ByondTest : JobsRequiredTest
{
- public static readonly Version TestVersion = new (513, 1536);
+ public static readonly Version TestVersion = new (515, 1592);
readonly IByondClient byondClient;
From b3e296ac46b71edd6424399e8956e01f6862da05 Mon Sep 17 00:00:00 2001
From: TiviPlus <57223640+TiviPlus@users.noreply.github.com>
Date: Sat, 5 Nov 2022 22:41:27 +0100
Subject: [PATCH 08/18] Make github testmerge comments collapsible
---
.../Deployment/Remote/GitHubRemoteDeploymentManager.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs
index 4bbdb835d4..a76434e9a1 100644
--- a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs
+++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs
@@ -283,7 +283,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote
string remoteRepositoryName,
bool updated) => String.Format(
CultureInfo.InvariantCulture,
- "#### Test Merge {4}{0}{0}##### Server Instance{0}{5}{1}{0}{0}##### Revision{0}Origin: {6}{0}Pull Request: {2}{0}Server: {7}{3}{8}",
+ "#### Test Merge {4}{0}{0}Details
{0}{0}##### Server Instance{0}{5}{1}{0}{0}##### Revision{0}Origin: {6}{0}Pull Request: {2}{0}Server: {7}{3}{8}{0} ",
Environment.NewLine,
repositorySettings.ShowTestMergeCommitters.Value
? String.Format(
From bc9181dc5d711a8ef482d58a8ac18327ac63c39c Mon Sep 17 00:00:00 2001
From: MaltVinegar <69946338+MaltVinegar@users.noreply.github.com>
Date: Wed, 7 Dec 2022 15:00:16 -0500
Subject: [PATCH 09/18] Adds trailing newline to readme file
Whenever the dmapi auto-updater action tries to update the dmapi, this file is copied over without the trailing newline causing the linters to lose their mind.
---
src/DMAPI/tgs/core/README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/DMAPI/tgs/core/README.md b/src/DMAPI/tgs/core/README.md
index aa3c7a9c9d..b82d8f49e2 100644
--- a/src/DMAPI/tgs/core/README.md
+++ b/src/DMAPI/tgs/core/README.md
@@ -5,4 +5,5 @@ This folder contains all DMAPI code not directly involved in an API.
- [_definitions.dm](./definitions.dm) contains defines needed across DMAPI internals.
- [core.dm](./core.dm) contains the implementations of the `/world/proc/TgsXXX()` procs. Many map directly to the `/datum/tgs_api` functions. It also contains the /datum selection and setup code.
- [datum.dm](./datum.dm) contains the `/datum/tgs_api` declarations that all APIs must implement.
-- [tgs_version.dm](./tgs_version.dm) contains the `/datum/tgs_version` definition
\ No newline at end of file
+- [tgs_version.dm](./tgs_version.dm) contains the `/datum/tgs_version` definition
+-
From bd7f6524987f225f812d92323cfc62751bfa4626 Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Fri, 30 Dec 2022 14:57:36 +0000
Subject: [PATCH 10/18] EventScript for when a deployment dir is cleared
---
.../Components/Deployment/DmbFactory.cs | 10 ++++++++++
.../Components/Events/EventType.cs | 6 ++++++
.../Components/InstanceFactory.cs | 1 +
3 files changed, 17 insertions(+)
diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
index cb6497e3a4..d8d584a803 100644
--- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
+++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
@@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Tgstation.Server.Host.Components.Deployment.Remote;
+using Tgstation.Server.Host.Components.Events;
using Tgstation.Server.Host.Database;
using Tgstation.Server.Host.IO;
using Tgstation.Server.Host.Models;
@@ -53,6 +54,11 @@ namespace Tgstation.Server.Host.Components.Deployment
///
readonly ILogger logger;
+ ///
+ /// The for .
+ ///
+ readonly IEventConsumer eventConsumer;
+
///
/// The for the .
///
@@ -95,18 +101,21 @@ namespace Tgstation.Server.Host.Components.Deployment
/// The value of .
/// The value of .
/// The value of .
+ /// The value of .
/// The value of .
public DmbFactory(
IDatabaseContextFactory databaseContextFactory,
IIOManager ioManager,
IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory,
ILogger logger,
+ IEventConsumer eventConsumer,
Api.Models.Instance metadata)
{
this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
this.remoteDeploymentManagerFactory = remoteDeploymentManagerFactory ?? throw new ArgumentNullException(nameof(remoteDeploymentManagerFactory));
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
+ this.eventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer));
this.metadata = metadata ?? throw new ArgumentNullException(nameof(metadata));
cleanupTask = Task.CompletedTask;
@@ -358,6 +367,7 @@ namespace Tgstation.Server.Host.Components.Deployment
try
{
++deleting;
+ await eventConsumer.HandleEvent(EventType.DeploymentCleanedUp, new List { x }, cancellationToken);
await ioManager.DeleteDirectory(x, cancellationToken);
}
catch (OperationCanceledException)
diff --git a/src/Tgstation.Server.Host/Components/Events/EventType.cs b/src/Tgstation.Server.Host/Components/Events/EventType.cs
index ba91a25f4f..dc5fea1cec 100644
--- a/src/Tgstation.Server.Host/Components/Events/EventType.cs
+++ b/src/Tgstation.Server.Host/Components/Events/EventType.cs
@@ -155,5 +155,11 @@
///
[EventScript("PreDreamMaker")]
PreDreamMaker,
+
+ ///
+ /// Whenever a deployment folder is deleted from disk. Parameters: Game directory path
+ ///
+ [EventScript("DeploymentCleanedUp")]
+ DeploymentCleanedUp,
}
}
diff --git a/src/Tgstation.Server.Host/Components/InstanceFactory.cs b/src/Tgstation.Server.Host/Components/InstanceFactory.cs
index ff4fc85c11..75fb2f0695 100644
--- a/src/Tgstation.Server.Host/Components/InstanceFactory.cs
+++ b/src/Tgstation.Server.Host/Components/InstanceFactory.cs
@@ -287,6 +287,7 @@ namespace Tgstation.Server.Host.Components
gameIoManager,
remoteDeploymentManagerFactory,
loggerFactory.CreateLogger(),
+ eventConsumer,
metadata);
try
{
From 5693363d2ce4289baae92891b248ce08bc5528fb Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Thu, 5 Jan 2023 19:42:10 +0000
Subject: [PATCH 11/18] Cybbtweaks
---
.../Components/Deployment/DmbFactory.cs | 10 ++++++----
.../Components/Deployment/DreamMaker.cs | 1 +
.../Components/Events/EventType.cs | 4 ++--
.../Components/InstanceFactory.cs | 2 +-
4 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
index d8d584a803..775c8ce270 100644
--- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
+++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
@@ -100,22 +100,22 @@ namespace Tgstation.Server.Host.Components.Deployment
/// The value of .
/// The value of .
/// The value of .
- /// The value of .
/// The value of .
+ /// The value of .
/// The value of .
public DmbFactory(
IDatabaseContextFactory databaseContextFactory,
IIOManager ioManager,
IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory,
- ILogger logger,
IEventConsumer eventConsumer,
+ ILogger logger,
Api.Models.Instance metadata)
{
this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
this.remoteDeploymentManagerFactory = remoteDeploymentManagerFactory ?? throw new ArgumentNullException(nameof(remoteDeploymentManagerFactory));
- this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
this.eventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer));
+ this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
this.metadata = metadata ?? throw new ArgumentNullException(nameof(metadata));
cleanupTask = Task.CompletedTask;
@@ -367,7 +367,7 @@ namespace Tgstation.Server.Host.Components.Deployment
try
{
++deleting;
- await eventConsumer.HandleEvent(EventType.DeploymentCleanedUp, new List { x }, cancellationToken);
+ await eventConsumer.HandleEvent(EventType.DeploymentCleanup, new List { x }, cancellationToken);
await ioManager.DeleteDirectory(x, cancellationToken);
}
catch (OperationCanceledException)
@@ -400,6 +400,8 @@ namespace Tgstation.Server.Host.Components.Deployment
{
async Task HandleCleanup()
{
+ // This needs to happen first
+ await eventConsumer.HandleEvent(EventType.DeploymentCleanup, new List { job.DirectoryName.ToString() }, cleanupCts.Token);
var deleteJob = ioManager.DeleteDirectory(job.DirectoryName.ToString(), cleanupCts.Token);
var remoteDeploymentManager = remoteDeploymentManagerFactory.CreateRemoteDeploymentManager(
metadata,
diff --git a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs
index ffb2935ac9..e8464b0d89 100644
--- a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs
+++ b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs
@@ -929,6 +929,7 @@ namespace Tgstation.Server.Host.Components.Deployment
try
{
// DCT: None available
+ await eventConsumer.HandleEvent(EventType.DeploymentCleanup, new List { jobPath }, default);
await ioManager.DeleteDirectory(jobPath, default);
}
catch (Exception e)
diff --git a/src/Tgstation.Server.Host/Components/Events/EventType.cs b/src/Tgstation.Server.Host/Components/Events/EventType.cs
index dc5fea1cec..f67a4bea87 100644
--- a/src/Tgstation.Server.Host/Components/Events/EventType.cs
+++ b/src/Tgstation.Server.Host/Components/Events/EventType.cs
@@ -159,7 +159,7 @@
///
/// Whenever a deployment folder is deleted from disk. Parameters: Game directory path
///
- [EventScript("DeploymentCleanedUp")]
- DeploymentCleanedUp,
+ [EventScript("DeploymentCleanup")]
+ DeploymentCleanup,
}
}
diff --git a/src/Tgstation.Server.Host/Components/InstanceFactory.cs b/src/Tgstation.Server.Host/Components/InstanceFactory.cs
index 75fb2f0695..1bb8121c9d 100644
--- a/src/Tgstation.Server.Host/Components/InstanceFactory.cs
+++ b/src/Tgstation.Server.Host/Components/InstanceFactory.cs
@@ -286,8 +286,8 @@ namespace Tgstation.Server.Host.Components
databaseContextFactory,
gameIoManager,
remoteDeploymentManagerFactory,
- loggerFactory.CreateLogger(),
eventConsumer,
+ loggerFactory.CreateLogger(),
metadata);
try
{
From c4f05dcb07db9d9510f9b071ffa464af4e12a1c5 Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Fri, 20 Jan 2023 20:17:23 +0000
Subject: [PATCH 12/18] I think I did it
---
.../Components/Deployment/DmbFactory.cs | 34 ++++++++++++-------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
index 775c8ce270..ebec279d77 100644
--- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
+++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
@@ -75,7 +75,7 @@ namespace Tgstation.Server.Host.Components.Deployment
readonly IDictionary jobLockCounts;
///
- /// representing calls to .
+ /// representing calls to .
///
Task cleanupTask;
@@ -254,7 +254,7 @@ namespace Tgstation.Server.Host.Components.Deployment
void CleanupAction()
{
if (providerSubmitted)
- CleanJob(compileJob);
+ CleanRegisteredCompileJob(compileJob);
}
var newProvider = new DmbProvider(compileJob, ioManager, CleanupAction);
@@ -367,8 +367,7 @@ namespace Tgstation.Server.Host.Components.Deployment
try
{
++deleting;
- await eventConsumer.HandleEvent(EventType.DeploymentCleanup, new List { x }, cancellationToken);
- await ioManager.DeleteDirectory(x, cancellationToken);
+ await DeleteCompileJobContent(x, cancellationToken);
}
catch (OperationCanceledException)
{
@@ -396,21 +395,19 @@ namespace Tgstation.Server.Host.Components.Deployment
/// Delete the of .
///
/// The to clean.
- void CleanJob(CompileJob job)
+ void CleanRegisteredCompileJob(CompileJob job)
{
async Task HandleCleanup()
{
- // This needs to happen first
- await eventConsumer.HandleEvent(EventType.DeploymentCleanup, new List { job.DirectoryName.ToString() }, cleanupCts.Token);
- var deleteJob = ioManager.DeleteDirectory(job.DirectoryName.ToString(), cleanupCts.Token);
- var remoteDeploymentManager = remoteDeploymentManagerFactory.CreateRemoteDeploymentManager(
- metadata,
- job);
+ // First kill the GitHub deployment
+ var remoteDeploymentManager = remoteDeploymentManagerFactory.CreateRemoteDeploymentManager(metadata, job);
// DCT: None available
var deploymentJob = remoteDeploymentManager.MarkInactive(job, default);
+
+ var deleteTask = DeleteCompileJobContent(job.DirectoryName.ToString(), cleanupCts.Token);
var otherTask = cleanupTask;
- await Task.WhenAll(otherTask, deleteJob, deploymentJob);
+ await Task.WhenAll(otherTask, deleteTask, deploymentJob);
}
lock (jobLockCounts)
@@ -426,5 +423,18 @@ namespace Tgstation.Server.Host.Components.Deployment
logger.LogTrace("Compile job {0} lock count now: {1}", job.Id, decremented);
}
}
+
+ ///
+ /// Handles cleaning the resources of a .
+ ///
+ /// The directory to cleanup.
+ /// The for this .
+ /// The deletion task
+ async Task DeleteCompileJobContent(string directory, CancellationToken cancellationToken)
+ {
+ // Then call the cleanup event, waiting here first
+ await eventConsumer.HandleEvent(EventType.DeploymentCleanup, new List { directory }, cancellationToken);
+ await ioManager.DeleteDirectory(directory, cancellationToken);
+ }
}
}
From fce2288afd00a59026ab1bd326fba7cf226be3c5 Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Fri, 20 Jan 2023 20:43:40 +0000
Subject: [PATCH 13/18] AAAAAAAAA
---
src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
index ebec279d77..c3d56bfd60 100644
--- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
+++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
@@ -429,7 +429,7 @@ namespace Tgstation.Server.Host.Components.Deployment
///
/// The directory to cleanup.
/// The for this .
- /// The deletion task
+ /// The deletion task.
async Task DeleteCompileJobContent(string directory, CancellationToken cancellationToken)
{
// Then call the cleanup event, waiting here first
From 706de066089e680d3ac3271c18b010ad09ad5b86 Mon Sep 17 00:00:00 2001
From: Dominion
Date: Fri, 20 Jan 2023 15:52:36 -0500
Subject: [PATCH 14/18] Version bump to 5.3.0
---
build/Version.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build/Version.props b/build/Version.props
index ba7d174e52..2c69817efd 100644
--- a/build/Version.props
+++ b/build/Version.props
@@ -3,7 +3,7 @@
- 5.2.4
+ 5.3.0
4.4.0
9.7.0
10.1.0
From 719aa44b463dc2070d6939bd0e0125b47b995f93 Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Fri, 20 Jan 2023 21:34:26 +0000
Subject: [PATCH 15/18] lol
---
src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
index c3d56bfd60..981698834a 100644
--- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
+++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
@@ -429,7 +429,7 @@ namespace Tgstation.Server.Host.Components.Deployment
///
/// The directory to cleanup.
/// The for this .
- /// The deletion task.
+ /// The deletion .
async Task DeleteCompileJobContent(string directory, CancellationToken cancellationToken)
{
// Then call the cleanup event, waiting here first
From 914d25d4dbecf107d8883180c38464f046013720 Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Sat, 21 Jan 2023 14:35:04 +0000
Subject: [PATCH 16/18] Update
src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
Co-authored-by: Jordan Dominion
---
src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
index 981698834a..e2f9fd442a 100644
--- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
+++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
@@ -433,7 +433,7 @@ namespace Tgstation.Server.Host.Components.Deployment
async Task DeleteCompileJobContent(string directory, CancellationToken cancellationToken)
{
// Then call the cleanup event, waiting here first
- await eventConsumer.HandleEvent(EventType.DeploymentCleanup, new List { directory }, cancellationToken);
+ await eventConsumer.HandleEvent(EventType.DeploymentCleanup, new List { ioManager.ResolvePath(directory) }, cancellationToken);
await ioManager.DeleteDirectory(directory, cancellationToken);
}
}
From 8f5755310f80249bd55d25537ff2784ed1f4c462 Mon Sep 17 00:00:00 2001
From: Dominion
Date: Sat, 21 Jan 2023 13:53:33 -0500
Subject: [PATCH 17/18] Stringify chat channel Id in API.
This is to deal with JSON and u64 being shitty
---
build/Version.props | 6 +--
.../Models/ChatChannel.cs | 43 +++++++------------
.../Models/Internal/ChatBotApiBase.cs | 4 +-
.../Models/Internal/ChatChannelBase.cs | 35 +++++++++++++++
.../Tgstation.Server.Api.csproj | 2 +-
.../Tgstation.Server.Client.csproj | 2 +-
.../Components/Chat/ChatManager.cs | 6 +--
.../Components/Chat/IChatManager.cs | 4 +-
.../Chat/Providers/DiscordProvider.cs | 4 +-
.../Components/Chat/Providers/IProvider.cs | 8 ++--
.../Components/Chat/Providers/IrcProvider.cs | 16 +++----
.../Components/Chat/Providers/Provider.cs | 12 +++---
.../Controllers/ChatController.cs | 42 +++++++++++++-----
.../Extensions/ChatChannelExtensions.cs | 2 +-
src/Tgstation.Server.Host/Models/ChatBot.cs | 2 +-
.../Models/ChatChannel.cs | 31 ++++++++++---
.../Instance/ChatTest.cs | 21 +++------
17 files changed, 150 insertions(+), 90 deletions(-)
create mode 100644 src/Tgstation.Server.Api/Models/Internal/ChatChannelBase.cs
diff --git a/build/Version.props b/build/Version.props
index 2c69817efd..a5f8a360ad 100644
--- a/build/Version.props
+++ b/build/Version.props
@@ -5,9 +5,9 @@
5.3.0
4.4.0
- 9.7.0
- 10.1.0
- 11.1.0
+ 9.8.0
+ 10.2.0
+ 11.2.0
6.0.6
5.3.0
1.2.0
diff --git a/src/Tgstation.Server.Api/Models/ChatChannel.cs b/src/Tgstation.Server.Api/Models/ChatChannel.cs
index 49dc7c0898..07b643fcab 100644
--- a/src/Tgstation.Server.Api/Models/ChatChannel.cs
+++ b/src/Tgstation.Server.Api/Models/ChatChannel.cs
@@ -1,49 +1,38 @@
-using System.ComponentModel.DataAnnotations;
+using System;
+using System.ComponentModel.DataAnnotations;
+
+using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models
{
///
/// Indicates a chat channel.
///
- public class ChatChannel
+ public class ChatChannel : ChatChannelBase
{
+ ///
+ /// The channel identifier. Supercedes and .
+ /// For , it's the IRC channel name and optional password colon separated.
+ /// For , it's the stringified Discord channel snowflake.
+ ///
+ [Required]
+ [StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
+ public string? ChannelData { get; set; }
+
///
/// The IRC channel name. Also potentially contains the channel passsword (if separated by a colon).
/// If multiple copies of the same channel with different keys are added to the server, the one that will be used is undefined.
///
[ResponseOptions]
[StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
+ [Obsolete($"Use {nameof(ChannelData)}")]
public string? IrcChannel { get; set; }
///
/// The Discord channel ID.
///
+ [Obsolete($"Use {nameof(ChannelData)}")]
[ResponseOptions]
public ulong? DiscordChannelId { get; set; }
-
- ///
- /// If the is an admin channel.
- ///
- [Required]
- public bool? IsAdminChannel { get; set; }
-
- ///
- /// If the is a watchdog channel.
- ///
- [Required]
- public bool? IsWatchdogChannel { get; set; }
-
- ///
- /// If the is an updates channel.
- ///
- [Required]
- public bool? IsUpdatesChannel { get; set; }
-
- ///
- /// A custom tag users can define to group channels together.
- ///
- [ResponseOptions]
- [StringLength(Limits.MaximumStringLength)]
- public string? Tag { get; set; }
}
}
diff --git a/src/Tgstation.Server.Api/Models/Internal/ChatBotApiBase.cs b/src/Tgstation.Server.Api/Models/Internal/ChatBotApiBase.cs
index ef82e1e5cb..2c4dcd8875 100644
--- a/src/Tgstation.Server.Api/Models/Internal/ChatBotApiBase.cs
+++ b/src/Tgstation.Server.Api/Models/Internal/ChatBotApiBase.cs
@@ -22,8 +22,8 @@ namespace Tgstation.Server.Api.Models.Internal
return true;
return Provider.Value switch
{
- ChatProvider.Discord => Channels?.Select(x => x.DiscordChannelId.HasValue && x.IrcChannel == null).All(x => x) ?? true,
- ChatProvider.Irc => Channels?.Select(x => !x.DiscordChannelId.HasValue && x.IrcChannel != null).All(x => x) ?? true,
+ ChatProvider.Discord => Channels?.Select(x => (x.DiscordChannelId.HasValue || ulong.TryParse(x.ChannelData, out _)) && x.IrcChannel == null).All(x => x) ?? true,
+ ChatProvider.Irc => Channels?.Select(x => !x.DiscordChannelId.HasValue && (x.IrcChannel != null || x.ChannelData != null)).All(x => x) ?? true,
_ => throw new InvalidOperationException("Invalid provider type!"),
};
}
diff --git a/src/Tgstation.Server.Api/Models/Internal/ChatChannelBase.cs b/src/Tgstation.Server.Api/Models/Internal/ChatChannelBase.cs
new file mode 100644
index 0000000000..87da5746ae
--- /dev/null
+++ b/src/Tgstation.Server.Api/Models/Internal/ChatChannelBase.cs
@@ -0,0 +1,35 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace Tgstation.Server.Api.Models.Internal
+{
+ ///
+ /// Base chat channel class.
+ ///
+ public abstract class ChatChannelBase
+ {
+ ///
+ /// If the is an admin channel.
+ ///
+ [Required]
+ public bool? IsAdminChannel { get; set; }
+
+ ///
+ /// If the is a watchdog channel.
+ ///
+ [Required]
+ public bool? IsWatchdogChannel { get; set; }
+
+ ///
+ /// If the is an updates channel.
+ ///
+ [Required]
+ public bool? IsUpdatesChannel { get; set; }
+
+ ///
+ /// A custom tag users can define to group channels together.
+ ///
+ [ResponseOptions]
+ [StringLength(Limits.MaximumStringLength)]
+ public string? Tag { get; set; }
+ }
+}
diff --git a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj
index 0840359482..d6179cd730 100644
--- a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj
+++ b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj
@@ -16,7 +16,7 @@
https://github.com/tgstation/tgstation-server
2018-2022
json web api tgstation-server tgstation ss13 byond
- Retargeted to netstandard2.0 to support migrator.
+ Added ChannelData field to ChatChannels model.
true
snupkg
../../build/analyzers.ruleset
diff --git a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj
index 65f7edce9f..5f9daa6809 100644
--- a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj
+++ b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj
@@ -16,7 +16,7 @@
https://github.com/tgstation/tgstation-server
2018-2022
json web api tgstation-server tgstation ss13 byond client
- Retargeted to netstandard2.0 to support migrator. Fixed nullablity of IByondClient.SetActiveVersion's Stream parameter.
+ Updated to API library 10.2.0.
true
snupkg
../../build/analyzers.ruleset
diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs
index 0d2cf0fd64..97460ba2fd 100644
--- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs
@@ -88,7 +88,7 @@ namespace Tgstation.Server.Host.Components.Chat
readonly object synchronizationLock;
///
- /// The for the .
+ /// The for the .
///
ICustomCommandHandler customCommandHandler;
@@ -175,7 +175,7 @@ namespace Tgstation.Server.Host.Components.Chat
}
///
- public async Task ChangeChannels(long connectionId, IEnumerable newChannels, CancellationToken cancellationToken)
+ public async Task ChangeChannels(long connectionId, IEnumerable newChannels, CancellationToken cancellationToken)
{
if (newChannels == null)
throw new ArgumentNullException(nameof(newChannels));
@@ -554,7 +554,7 @@ namespace Tgstation.Server.Host.Components.Chat
async Task RemapProvider(IProvider provider, CancellationToken cancellationToken)
{
logger.LogTrace("Remapping channels for provider reconnection...");
- IEnumerable channelsToMap;
+ IEnumerable channelsToMap;
long providerId;
lock (providers)
providerId = providers.Where(x => x.Value == provider).Select(x => x.Key).First();
diff --git a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs
index 2cad279068..41e9acfa40 100644
--- a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs
@@ -40,10 +40,10 @@ namespace Tgstation.Server.Host.Components.Chat
/// Change chat channels.
///
/// The of the connection.
- /// An of the new list of s.
+ /// An of the new list of s.
/// The for the operation.
/// A representing the running operation.
- Task ChangeChannels(long connectionId, IEnumerable newChannels, CancellationToken cancellationToken);
+ Task ChangeChannels(long connectionId, IEnumerable newChannels, CancellationToken cancellationToken);
///
/// Queue a chat to a given set of .
diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs
index dbb4d6e4c5..aba57ae759 100644
--- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs
@@ -608,14 +608,14 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
}
///
- protected override async Task>> MapChannelsImpl(IEnumerable channels, CancellationToken cancellationToken)
+ protected override async Task>> MapChannelsImpl(IEnumerable channels, CancellationToken cancellationToken)
{
if (channels == null)
throw new ArgumentNullException(nameof(channels));
var remapRequired = false;
- async Task> GetModelChannelFromDBChannel(Api.Models.ChatChannel channelFromDB)
+ async Task> GetModelChannelFromDBChannel(Models.ChatChannel channelFromDB)
{
if (!channelFromDB.DiscordChannelId.HasValue)
throw new InvalidOperationException("ChatChannel missing DiscordChannelId!");
diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs
index 5ec71c169e..702a51e984 100644
--- a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs
@@ -33,7 +33,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
Task InitialConnectionJob { get; }
///
- /// Indicate to the provider that at least one call has successfully completed.
+ /// Indicate to the provider that at least one call has successfully completed.
///
void InitialMappingComplete();
@@ -42,7 +42,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
///
/// The for the operation.
/// A resulting in the next available or if the needed to reconnect.
- /// Note that private messages will come in the form of s not returned in . Do not the on continuations run from the returned .
+ /// Note that private messages will come in the form of s not returned in . Do not the on continuations run from the returned .
Task NextMessage(CancellationToken cancellationToken);
///
@@ -57,8 +57,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
///
/// The s to map.
/// The for the operation.
- /// A resulting in a of the 's s representing .
- Task>> MapChannels(IEnumerable channels, CancellationToken cancellationToken);
+ /// A resulting in a of the 's s representing .
+ Task>> MapChannels(IEnumerable channels, CancellationToken cancellationToken);
///
/// Send a message to the .
diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs
index 1a3d22f682..42c26c813f 100644
--- a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs
@@ -252,8 +252,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
}
///
- protected override Task>> MapChannelsImpl(
- IEnumerable channels,
+ protected override Task>> MapChannelsImpl(
+ IEnumerable channels,
CancellationToken cancellationToken)
=> Task.Factory.StartNew(
() =>
@@ -285,10 +285,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
else
client.RfcJoin(channelToJoin);
- return (IReadOnlyCollection>)channels
- .Select(apiChannel =>
+ return (IReadOnlyCollection>)channels
+ .Select(dbChannel =>
{
- var channelName = apiChannel.GetIrcChannelName();
+ var channelName = dbChannel.GetIrcChannelName();
ulong? id = null;
if (!channelIdMap.Any(y =>
{
@@ -303,15 +303,15 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
}
return Tuple.Create(
- apiChannel,
+ dbChannel,
new ChannelRepresentation
{
RealId = id.Value,
- IsAdminChannel = apiChannel.IsAdminChannel == true,
+ IsAdminChannel = dbChannel.IsAdminChannel == true,
ConnectionName = address,
FriendlyName = channelIdMap[id.Value],
IsPrivateChannel = false,
- Tag = apiChannel.Tag,
+ Tag = dbChannel.Tag,
});
})
.ToList();
diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs
index 17f2b35fb2..3c339a6666 100644
--- a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs
@@ -117,7 +117,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
public void InitialMappingComplete() => initialConnectionTcs.TrySetResult(null);
///
- public async Task>> MapChannels(IEnumerable channels, CancellationToken cancellationToken)
+ public async Task>> MapChannels(IEnumerable channels, CancellationToken cancellationToken)
{
try
{
@@ -193,13 +193,13 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
protected abstract Task DisconnectImpl(CancellationToken cancellationToken);
///
- /// Implementation of .
+ /// Implementation of .
///
- /// The s to map.
+ /// The s to map.
/// The for the operation.
- /// A resulting in a of the 's s representing .
- protected abstract Task>> MapChannelsImpl(
- IEnumerable channels,
+ /// A resulting in a of the 's s representing .
+ protected abstract Task>> MapChannelsImpl(
+ IEnumerable channels,
CancellationToken cancellationToken);
///
diff --git a/src/Tgstation.Server.Host/Controllers/ChatController.cs b/src/Tgstation.Server.Host/Controllers/ChatController.cs
index 0ce4d56bf3..0ee4155882 100644
--- a/src/Tgstation.Server.Host/Controllers/ChatController.cs
+++ b/src/Tgstation.Server.Host/Controllers/ChatController.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
@@ -57,16 +58,37 @@ namespace Tgstation.Server.Host.Controllers
/// Converts to a .
///
/// The .
+ /// The channel's .
/// A based on .
- static Models.ChatChannel ConvertApiChatChannel(Api.Models.ChatChannel api) => new ()
+ static Models.ChatChannel ConvertApiChatChannel(Api.Models.ChatChannel api, ChatProvider chatProvider)
{
- DiscordChannelId = api.DiscordChannelId,
- IrcChannel = api.IrcChannel,
- IsAdminChannel = api.IsAdminChannel ?? false,
- IsWatchdogChannel = api.IsWatchdogChannel ?? false,
- IsUpdatesChannel = api.IsUpdatesChannel ?? false,
- Tag = api.Tag,
- };
+ var result = new Models.ChatChannel
+ {
+ DiscordChannelId = api.DiscordChannelId,
+ IrcChannel = api.IrcChannel,
+ IsAdminChannel = api.IsAdminChannel ?? false,
+ IsWatchdogChannel = api.IsWatchdogChannel ?? false,
+ IsUpdatesChannel = api.IsUpdatesChannel ?? false,
+ Tag = api.Tag,
+ };
+
+ if (api.ChannelData != null)
+ {
+ switch (chatProvider)
+ {
+ case ChatProvider.Discord:
+ result.DiscordChannelId = ulong.Parse(api.ChannelData, CultureInfo.InvariantCulture);
+ break;
+ case ChatProvider.Irc:
+ result.IrcChannel = api.ChannelData;
+ break;
+ default:
+ throw new InvalidOperationException($"Invalid chat provider: {chatProvider}");
+ }
+ }
+
+ return result;
+ }
///
/// Create a new chat bot .
@@ -106,7 +128,7 @@ namespace Tgstation.Server.Host.Controllers
Name = model.Name,
ConnectionString = model.ConnectionString,
Enabled = model.Enabled,
- Channels = model.Channels?.Select(x => ConvertApiChatChannel(x)).ToList() ?? new List(), // important that this isn't null
+ Channels = model.Channels?.Select(x => ConvertApiChatChannel(x, model.Provider.Value)).ToList() ?? new List(), // important that this isn't null
InstanceId = Instance.Id.Value,
Provider = model.Provider,
ReconnectionInterval = model.ReconnectionInterval,
@@ -319,7 +341,7 @@ namespace Tgstation.Server.Host.Controllers
DatabaseContext.ChatChannels.RemoveRange(current.Channels);
if (hasChannels)
{
- var dbChannels = model.Channels.Select(x => ConvertApiChatChannel(x)).ToList();
+ var dbChannels = model.Channels.Select(x => ConvertApiChatChannel(x, model.Provider ?? current.Provider.Value)).ToList();
DatabaseContext.ChatChannels.AddRange(dbChannels);
current.Channels = dbChannels;
}
diff --git a/src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs b/src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs
index e2ef1bd72b..5a3fd8ac26 100644
--- a/src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs
+++ b/src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
-using Tgstation.Server.Api.Models;
+using Tgstation.Server.Host.Models;
namespace Tgstation.Server.Host.Extensions
{
diff --git a/src/Tgstation.Server.Host/Models/ChatBot.cs b/src/Tgstation.Server.Host/Models/ChatBot.cs
index f19b724cd0..8bef6104a8 100644
--- a/src/Tgstation.Server.Host/Models/ChatBot.cs
+++ b/src/Tgstation.Server.Host/Models/ChatBot.cs
@@ -33,7 +33,7 @@ namespace Tgstation.Server.Host.Models
///
public ChatBotResponse ToApi() => new ChatBotResponse
{
- Channels = Channels.Select(x => x.ToApi()).ToList(),
+ Channels = Channels.Select(x => x.ToApi(Provider.Value)).ToList(),
ConnectionString = ConnectionString,
Enabled = Enabled,
Provider = Provider,
diff --git a/src/Tgstation.Server.Host/Models/ChatChannel.cs b/src/Tgstation.Server.Host/Models/ChatChannel.cs
index 59a903f5a4..1277b0f5ff 100644
--- a/src/Tgstation.Server.Host/Models/ChatChannel.cs
+++ b/src/Tgstation.Server.Host/Models/ChatChannel.cs
@@ -1,7 +1,12 @@
-namespace Tgstation.Server.Host.Models
+using System.ComponentModel.DataAnnotations;
+
+using Tgstation.Server.Api.Models;
+using Tgstation.Server.Api.Models.Internal;
+
+namespace Tgstation.Server.Host.Models
{
///
- public sealed class ChatChannel : Api.Models.ChatChannel, IApiTransformable
+ public sealed class ChatChannel : ChatChannelBase
{
///
/// The row Id.
@@ -9,18 +14,34 @@
public long Id { get; set; }
///
- /// The .
+ /// The .
///
public long ChatSettingsId { get; set; }
+ ///
+ /// See .
+ ///
+ [StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
+ public string IrcChannel { get; set; }
+
+ ///
+ /// See .
+ ///
+ public ulong? DiscordChannelId { get; set; }
+
///
/// The .
///
public ChatBot ChatSettings { get; set; }
- ///
- public Api.Models.ChatChannel ToApi() => new Api.Models.ChatChannel
+ ///
+ /// Convert to a .
+ ///
+ /// The channel's .
+ /// The converted .
+ public Api.Models.ChatChannel ToApi(ChatProvider chatProvider) => new Api.Models.ChatChannel
{
+ ChannelData = chatProvider == ChatProvider.Discord ? DiscordChannelId.ToString() : IrcChannel,
DiscordChannelId = DiscordChannelId,
IsAdminChannel = IsAdminChannel,
IsWatchdogChannel = IsWatchdogChannel,
diff --git a/tests/Tgstation.Server.Tests/Instance/ChatTest.cs b/tests/Tgstation.Server.Tests/Instance/ChatTest.cs
index 71a0f2ff03..805cd934a1 100644
--- a/tests/Tgstation.Server.Tests/Instance/ChatTest.cs
+++ b/tests/Tgstation.Server.Tests/Instance/ChatTest.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -81,7 +81,8 @@ namespace Tgstation.Server.Tests.Instance
IsUpdatesChannel = true,
IsWatchdogChannel = true,
Tag = "butt2",
- IrcChannel = channelId
+ ChannelData = channelId,
+ IrcChannel = "should_not_be_this!!!JHF*WW(#*(*$&(#*@))("
}
}
}, cancellationToken);
@@ -94,6 +95,7 @@ namespace Tgstation.Server.Tests.Instance
Assert.AreEqual(true, updatedBot.Channels.First().IsWatchdogChannel);
Assert.AreEqual("butt2", updatedBot.Channels.First().Tag);
Assert.AreEqual(channelId, updatedBot.Channels.First().IrcChannel);
+ Assert.AreEqual(channelId, updatedBot.Channels.First().ChannelData);
Assert.IsNull(updatedBot.Channels.First().DiscordChannelId);
}
@@ -138,17 +140,6 @@ namespace Tgstation.Server.Tests.Instance
Assert.AreEqual(true, updatedBot.Enabled);
var channelId = UInt64.Parse(Environment.GetEnvironmentVariable("TGS_TEST_DISCORD_CHANNEL"));
- firstBot.Channels = new List
- {
- new ChatChannel
- {
- IsAdminChannel = true,
- IsUpdatesChannel = true,
- IsWatchdogChannel = true,
- Tag = "butt",
- DiscordChannelId = channelId
- }
- };
updatedBot = await chatClient.Update(new ChatBotUpdateRequest
{
@@ -161,7 +152,8 @@ namespace Tgstation.Server.Tests.Instance
IsUpdatesChannel = true,
IsWatchdogChannel = true,
Tag = "butt",
- DiscordChannelId = channelId
+ ChannelData = channelId.ToString(),
+ DiscordChannelId = 1234,
}
}
}, cancellationToken);
@@ -174,6 +166,7 @@ namespace Tgstation.Server.Tests.Instance
Assert.AreEqual(true, updatedBot.Channels.First().IsWatchdogChannel);
Assert.AreEqual("butt", updatedBot.Channels.First().Tag);
Assert.AreEqual(channelId, updatedBot.Channels.First().DiscordChannelId);
+ Assert.AreEqual(channelId.ToString(), updatedBot.Channels.First().ChannelData);
Assert.IsNull(updatedBot.Channels.First().IrcChannel);
}
From 80f88ddc0b39d27cc7969eff12a61914950fd4b3 Mon Sep 17 00:00:00 2001
From: Dominion
Date: Sat, 21 Jan 2023 14:10:22 -0500
Subject: [PATCH 18/18] Suppress deprecated field warnings
---
.../Controllers/ChatController.cs | 2 ++
src/Tgstation.Server.Host/Models/ChatChannel.cs | 4 +++-
tests/Tgstation.Server.Tests/Instance/ChatTest.cs | 14 +++++++++++---
tools/Tgstation.Server.Migrator.Comms/Program.cs | 6 +-----
4 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/Tgstation.Server.Host/Controllers/ChatController.cs b/src/Tgstation.Server.Host/Controllers/ChatController.cs
index 0ee4155882..27227b1f81 100644
--- a/src/Tgstation.Server.Host/Controllers/ChatController.cs
+++ b/src/Tgstation.Server.Host/Controllers/ChatController.cs
@@ -64,8 +64,10 @@ namespace Tgstation.Server.Host.Controllers
{
var result = new Models.ChatChannel
{
+#pragma warning disable CS0618
DiscordChannelId = api.DiscordChannelId,
IrcChannel = api.IrcChannel,
+#pragma warning restore CS0618
IsAdminChannel = api.IsAdminChannel ?? false,
IsWatchdogChannel = api.IsWatchdogChannel ?? false,
IsUpdatesChannel = api.IsUpdatesChannel ?? false,
diff --git a/src/Tgstation.Server.Host/Models/ChatChannel.cs b/src/Tgstation.Server.Host/Models/ChatChannel.cs
index 1277b0f5ff..7e88f80306 100644
--- a/src/Tgstation.Server.Host/Models/ChatChannel.cs
+++ b/src/Tgstation.Server.Host/Models/ChatChannel.cs
@@ -42,11 +42,13 @@ namespace Tgstation.Server.Host.Models
public Api.Models.ChatChannel ToApi(ChatProvider chatProvider) => new Api.Models.ChatChannel
{
ChannelData = chatProvider == ChatProvider.Discord ? DiscordChannelId.ToString() : IrcChannel,
+#pragma warning disable CS0618
+ IrcChannel = IrcChannel,
DiscordChannelId = DiscordChannelId,
+#pragma warning restore CS0618
IsAdminChannel = IsAdminChannel,
IsWatchdogChannel = IsWatchdogChannel,
IsUpdatesChannel = IsUpdatesChannel,
- IrcChannel = IrcChannel,
Tag = Tag,
};
}
diff --git a/tests/Tgstation.Server.Tests/Instance/ChatTest.cs b/tests/Tgstation.Server.Tests/Instance/ChatTest.cs
index 805cd934a1..f354110e89 100644
--- a/tests/Tgstation.Server.Tests/Instance/ChatTest.cs
+++ b/tests/Tgstation.Server.Tests/Instance/ChatTest.cs
@@ -82,7 +82,9 @@ namespace Tgstation.Server.Tests.Instance
IsWatchdogChannel = true,
Tag = "butt2",
ChannelData = channelId,
+#pragma warning disable CS0618
IrcChannel = "should_not_be_this!!!JHF*WW(#*(*$&(#*@))("
+#pragma warning restore CS0618
}
}
}, cancellationToken);
@@ -94,9 +96,11 @@ namespace Tgstation.Server.Tests.Instance
Assert.AreEqual(true, updatedBot.Channels.First().IsUpdatesChannel);
Assert.AreEqual(true, updatedBot.Channels.First().IsWatchdogChannel);
Assert.AreEqual("butt2", updatedBot.Channels.First().Tag);
+#pragma warning disable CS0618
Assert.AreEqual(channelId, updatedBot.Channels.First().IrcChannel);
- Assert.AreEqual(channelId, updatedBot.Channels.First().ChannelData);
Assert.IsNull(updatedBot.Channels.First().DiscordChannelId);
+#pragma warning restore CS0618
+ Assert.AreEqual(channelId, updatedBot.Channels.First().ChannelData);
}
async Task RunDiscord(CancellationToken cancellationToken)
@@ -153,7 +157,9 @@ namespace Tgstation.Server.Tests.Instance
IsWatchdogChannel = true,
Tag = "butt",
ChannelData = channelId.ToString(),
+#pragma warning disable CS0618
DiscordChannelId = 1234,
+#pragma warning restore CS0618
}
}
}, cancellationToken);
@@ -165,9 +171,11 @@ namespace Tgstation.Server.Tests.Instance
Assert.AreEqual(true, updatedBot.Channels.First().IsUpdatesChannel);
Assert.AreEqual(true, updatedBot.Channels.First().IsWatchdogChannel);
Assert.AreEqual("butt", updatedBot.Channels.First().Tag);
+#pragma warning disable CS0618
Assert.AreEqual(channelId, updatedBot.Channels.First().DiscordChannelId);
- Assert.AreEqual(channelId.ToString(), updatedBot.Channels.First().ChannelData);
Assert.IsNull(updatedBot.Channels.First().IrcChannel);
+#pragma warning restore CS0618
+ Assert.AreEqual(channelId.ToString(), updatedBot.Channels.First().ChannelData);
}
public async Task RunPostTest(CancellationToken cancellationToken)
@@ -208,7 +216,7 @@ namespace Tgstation.Server.Tests.Instance
IsUpdatesChannel = false,
IsWatchdogChannel = true,
Tag = "butt",
- DiscordChannelId = discordBotReq.Channels.First().DiscordChannelId
+ ChannelData = discordBotReq.Channels.First().ChannelData
});
await ApiAssert.ThrowsException(() => chatClient.Update(discordBotReq, cancellationToken), ErrorCode.ChatBotMaxChannels);
diff --git a/tools/Tgstation.Server.Migrator.Comms/Program.cs b/tools/Tgstation.Server.Migrator.Comms/Program.cs
index 826e07a80c..2aee2a3001 100644
--- a/tools/Tgstation.Server.Migrator.Comms/Program.cs
+++ b/tools/Tgstation.Server.Migrator.Comms/Program.cs
@@ -204,13 +204,9 @@ static class Program
IsWatchdogChannel = providerInfo.WatchdogChannels.Any(x => NormalizeChannelId(x) == channelIdentifier),
IsAdminChannel = providerInfo.AdminChannels.Any(x => NormalizeChannelId(x) == channelIdentifier),
IsUpdatesChannel = providerInfo.DevChannels.Any(x => NormalizeChannelId(x) == channelIdentifier),
+ ChannelData = channelIdentifier,
};
- if (isDiscordProvider)
- newChatChannel.DiscordChannelId = ulong.Parse(channelIdentifier);
- else
- newChatChannel.IrcChannel = channelIdentifier;
-
createRequest.Channels.Add(newChatChannel);
}