diff --git a/LibMatrix b/LibMatrix
-Subproject 74fa4463dfb4b0508a36d83a9e77c83e379aab2
+Subproject 0640eba992f95cc45873330b76fadf123202d1c
diff --git a/MatrixUtils.RoomUpgradeCLI/Commands/ExecuteCommand.cs b/MatrixUtils.RoomUpgradeCLI/Commands/ExecuteCommand.cs
index 41c8cca..a095f2e 100644
--- a/MatrixUtils.RoomUpgradeCLI/Commands/ExecuteCommand.cs
+++ b/MatrixUtils.RoomUpgradeCLI/Commands/ExecuteCommand.cs
@@ -1,5 +1,6 @@
using System.Text.Json;
using System.Text.Json.Nodes;
+using ArcaneLibs.Extensions;
using LibMatrix.Helpers;
using LibMatrix.Homeservers;
@@ -11,6 +12,7 @@ public class ExecuteCommand(ILogger<ExecuteCommand> logger, IHost host, RuntimeC
await PrintHelp();
return;
}
+
var filename = ctx.Args[1];
if (filename.StartsWith("--")) {
Console.WriteLine("Filename cannot start with --, please provide a valid filename.");
@@ -37,14 +39,21 @@ public class ExecuteCommand(ILogger<ExecuteCommand> logger, IHost host, RuntimeC
? rbj.Deserialize<RoomUpgradeBuilder>()
: rbj.Deserialize<RoomBuilder>();
Console.WriteLine($"Executing room builder file of type {rb.GetType().Name}...");
+ if (rb is RoomUpgradeBuilder { CanUpgrade: false } rub && !(rub.UpgradeOptions.ForceUpgrade || rub.UpgradeOptions.NoopUpgrade)) {
+ Console.WriteLine("Warning: Import state has determined that you cannot upgrade this room.");
+ Console.WriteLine(rub.ToJson());
+ return;
+ }
+
await rb!.Create(hs);
}
-
+
public async Task ExecuteDirectory(string dirName) {
if (!Directory.Exists(dirName)) {
Console.WriteLine($"Directory {dirName} does not exist.");
return;
}
+
var files = Directory.GetFiles(dirName, "*.json");
foreach (var file in files) {
Console.WriteLine($"Executing file: {file}");
diff --git a/MatrixUtils.RoomUpgradeCLI/Extensions/RoomBuilderExtensions.cs b/MatrixUtils.RoomUpgradeCLI/Extensions/RoomBuilderExtensions.cs
index 75852bc..f6e5199 100644
--- a/MatrixUtils.RoomUpgradeCLI/Extensions/RoomBuilderExtensions.cs
+++ b/MatrixUtils.RoomUpgradeCLI/Extensions/RoomBuilderExtensions.cs
@@ -121,6 +121,28 @@ public static class RoomBuilderExtensions {
break;
// upgrade options
+ case "--restrict-old-room":
+ if (rb is not RoomUpgradeBuilder upgradeBuilderRestrict) {
+ throw new InvalidOperationException("Restrict old room can only be used with room upgrades");
+ }
+
+ var oldRoom = hs.GetRoom(upgradeBuilderRestrict.OldRoomId);
+ var createEvt = await oldRoom.GetCreateEventAsync();
+ if (createEvt == null) {
+ throw new InvalidOperationException("Could not get create event for old room " + upgradeBuilderRestrict.OldRoomId);
+ }
+
+ if (!int.TryParse(createEvt.RoomVersion ?? "1", out int numericVersion)) {
+ Console.WriteLine("Warning: Could not parse old room version '" + createEvt.RoomVersion + "' as a number! Setting restricted join rule may not work.");
+ }
+ else if (numericVersion < 8) {
+ throw new InvalidOperationException(
+ "Cannot set restrict old room on rooms with version lower than 8!\nhttps://spec.matrix.org/v1.17/rooms/#feature-matrix"
+ );
+ }
+
+ upgradeBuilderRestrict.UpgradeOptions.RestrictOldRoom = GetBoolArg(args, ref i, true);
+ break;
case "--invite-members":
if (rb is not RoomUpgradeBuilder upgradeBuilder) {
throw new InvalidOperationException("Invite members can only be used with room upgrades");
diff --git a/MatrixUtils.RoomUpgradeCLI/Program.cs b/MatrixUtils.RoomUpgradeCLI/Program.cs
index e169830..3a4c822 100644
--- a/MatrixUtils.RoomUpgradeCLI/Program.cs
+++ b/MatrixUtils.RoomUpgradeCLI/Program.cs
@@ -4,7 +4,7 @@ using LibMatrix.Utilities.Bot;
using MatrixUtils.RoomUpgradeCLI;
using MatrixUtils.RoomUpgradeCLI.Commands;
-foreach (var group in args.Split(";")) {
+foreach (var group in args.AsEnumerable().Split(";")) {
var argGroup = group.ToArray();
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddRoryLibMatrixServices();
diff --git a/MatrixUtils.Web/MatrixUtils.Web.csproj b/MatrixUtils.Web/MatrixUtils.Web.csproj
index e800c92..9100c87 100644
--- a/MatrixUtils.Web/MatrixUtils.Web.csproj
+++ b/MatrixUtils.Web/MatrixUtils.Web.csproj
@@ -10,6 +10,7 @@
<UseBlazorWebAssembly>true</UseBlazorWebAssembly>
<BlazorEnableCompression>false</BlazorEnableCompression>
+ <CompressionEnabled>false</CompressionEnabled>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
<BlazorCacheBootResources>false</BlazorCacheBootResources>
<BlazorEnableTimeZoneSupport>false</BlazorEnableTimeZoneSupport>
diff --git a/MatrixUtils.Web/Pages/Dev/WellKnownRes.razor b/MatrixUtils.Web/Pages/Dev/WellKnownRes.razor
index c636c56..722f9b3 100644
--- a/MatrixUtils.Web/Pages/Dev/WellKnownRes.razor
+++ b/MatrixUtils.Web/Pages/Dev/WellKnownRes.razor
@@ -72,6 +72,7 @@
public bool HasClientWellKnown => WellKnownResolutionResult?.ClientWellKnown is { Content.Homeserver.BaseUrl: { Length: > 0 } };
public bool HasServerWellKnown => WellKnownResolutionResult?.ServerWellKnown is { Content.Homeserver.Length: > 0 };
public bool HasSupportWellKnown => WellKnownResolutionResult?.SupportWellKnown?.Content is not null and not { SupportPage: null, Contacts: null or { Count: 0 } };
+ public bool HasPolicyServerWellKnown => WellKnownResolutionResult?.PolicyServerWellKnown?.Content is not null and not { PublicKey: null or "" };
}
private async Task Execute() {
diff --git a/MatrixUtils.Web/wwwroot/index.html b/MatrixUtils.Web/wwwroot/index.html
index 3334426..fa233b3 100644
--- a/MatrixUtils.Web/wwwroot/index.html
+++ b/MatrixUtils.Web/wwwroot/index.html
@@ -14,6 +14,7 @@
<link rel="manifest" href="rmu.webmanifest"/>
<link rel="apple-touch-icon" sizes="512x512" href="icon-512.png"/>
<link rel="apple-touch-icon" sizes="192x192" href="icon-192.png"/>
+ <script type="importmap"></script>
</head>
<body>
diff --git a/MatrixUtils.Web/wwwroot/service-worker.published.js b/MatrixUtils.Web/wwwroot/service-worker.published.js
index aafb48c..3e28e6c 100644
--- a/MatrixUtils.Web/wwwroot/service-worker.published.js
+++ b/MatrixUtils.Web/wwwroot/service-worker.published.js
@@ -22,7 +22,7 @@ async function onInstall(event) {
console.info('Service worker: Install');
// Activate the new service worker as soon as the old one is retired.
- self.skipWaiting();
+ await self.skipWaiting();
// Fetch and cache all matching items from the assets manifest
const assetsRequests = self.assetsManifest.assets
@@ -55,19 +55,6 @@ async function onFetch(event) {
const shouldCache = offlineAssetsInclude.some(pattern => pattern.test(request.url));
const cache = await caches.open(cacheName);
-
- if (request !== 'index.html' && request.url.endsWith("_framework/dotnet.js")) {
- // return `_framework/dotnet.<hash>.js` from cache to avoid integrity errors
- const dotnetJsUrl = manifestUrlList.find(url => /_framework\/dotnet\.[a-z0-9]+\.js$/.test(url));
- if (dotnetJsUrl) {
- cachedResponse = await cache.match(dotnetJsUrl);
- if (cachedResponse) {
- console.log("Service worker caching: serving dotnet.js from cache: ", dotnetJsUrl);
- return cachedResponse;
- }
- } else console.warn("Service worker caching: could not find dotnet.hash.js in manifest", {request, manifestUrlList});
- }
-
cachedResponse = await cache.match(request);
let exception;
let fetched;
diff --git a/scripts/deploy.sh b/scripts/deploy.sh
index 44b8a75..1f86275 100755
--- a/scripts/deploy.sh
+++ b/scripts/deploy.sh
@@ -12,5 +12,4 @@ rm -rf **/bin/Release
cd MatrixUtils.Web
dotnet publish -c Release
dotnet restore # restore debug deps
-cp bin/Release/net10.0/publish/wwwroot/_framework/dotnet.??????????.js bin/Release/net10.0/publish/wwwroot/_framework/dotnet.js
rsync --delete -raP bin/Release/net10.0/publish/wwwroot/ rory.gay:/data/nginx/html_mru/
|