about summary refs log tree commit diff
path: root/MatrixUtils.Web/Classes/RMUStorageWrapper.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-01-29 10:15:27 +0100
committerRory& <root@rory.gay>2024-01-29 10:15:27 +0100
commit3e6a73599bb58161c08d8675ea23ee6c82c6675c (patch)
treef3c0d1e797a77ed5993478d742751d386e004fb7 /MatrixUtils.Web/Classes/RMUStorageWrapper.cs
parentRoom member migrations (diff)
downloadMatrixUtils-3e6a73599bb58161c08d8675ea23ee6c82c6675c.tar.xz
Room list fixes, migration fix, update available handler
Diffstat (limited to 'MatrixUtils.Web/Classes/RMUStorageWrapper.cs')
-rw-r--r--MatrixUtils.Web/Classes/RMUStorageWrapper.cs31
1 files changed, 29 insertions, 2 deletions
diff --git a/MatrixUtils.Web/Classes/RMUStorageWrapper.cs b/MatrixUtils.Web/Classes/RMUStorageWrapper.cs
index 31e7734..fa79268 100644
--- a/MatrixUtils.Web/Classes/RMUStorageWrapper.cs
+++ b/MatrixUtils.Web/Classes/RMUStorageWrapper.cs
@@ -12,7 +12,7 @@ public class RMUStorageWrapper(TieredStorageService storageService, HomeserverPr
     }
 
     public async Task<UserAuth?> GetCurrentToken() {
-        var currentToken = await storageService.DataStorageProvider.LoadObjectAsync<UserAuth>("token");
+        var currentToken = await storageService.DataStorageProvider.LoadObjectAsync<UserAuth>("rmu.token");
         var allTokens = await GetAllTokens();
         if (allTokens is null or { Count: 0 }) {
             await SetCurrentToken(null);
@@ -94,5 +94,32 @@ public class RMUStorageWrapper(TieredStorageService storageService, HomeserverPr
         await storageService.DataStorageProvider.SaveObjectAsync("rmu.tokens", tokens);
     }
 
-    public async Task SetCurrentToken(UserAuth? auth) => await storageService.DataStorageProvider.SaveObjectAsync("token", auth);
+    public async Task SetCurrentToken(UserAuth? auth) => await storageService.DataStorageProvider.SaveObjectAsync("rmu.token", auth);
+
+    public async Task MigrateFromMRU() {
+        var dsp = storageService.DataStorageProvider!;
+        if(await dsp.ObjectExistsAsync("token")) {
+            var oldToken = await dsp.LoadObjectAsync<UserAuth>("token");
+            if (oldToken != null) {
+                await dsp.SaveObjectAsync("rmu.token", oldToken);
+                await dsp.DeleteObjectAsync("tokens");
+            }
+        }
+        
+        if(await dsp.ObjectExistsAsync("tokens")) {
+            var oldTokens = await dsp.LoadObjectAsync<List<UserAuth>>("tokens");
+            if (oldTokens != null) {
+                await dsp.SaveObjectAsync("rmu.tokens", oldTokens);
+                await dsp.DeleteObjectAsync("tokens");
+            }
+        }
+        
+        if(await dsp.ObjectExistsAsync("mru.tokens")) {
+            var oldTokens = await dsp.LoadObjectAsync<List<UserAuth>>("mru.tokens");
+            if (oldTokens != null) {
+                await dsp.SaveObjectAsync("rmu.tokens", oldTokens);
+                await dsp.DeleteObjectAsync("mru.tokens");
+            }
+        }
+    }
 }