about summary refs log tree commit diff
path: root/Tests/LibMatrix.HomeserverEmulator/Controllers/Users/FilterController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/LibMatrix.HomeserverEmulator/Controllers/Users/FilterController.cs')
-rw-r--r--Tests/LibMatrix.HomeserverEmulator/Controllers/Users/FilterController.cs46
1 files changed, 0 insertions, 46 deletions
diff --git a/Tests/LibMatrix.HomeserverEmulator/Controllers/Users/FilterController.cs b/Tests/LibMatrix.HomeserverEmulator/Controllers/Users/FilterController.cs
deleted file mode 100644
index bdee7bc..0000000
--- a/Tests/LibMatrix.HomeserverEmulator/Controllers/Users/FilterController.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System.Text.Json.Nodes;

-using ArcaneLibs.Extensions;

-using LibMatrix.EventTypes.Spec.State;

-using LibMatrix.Filters;

-using LibMatrix.HomeserverEmulator.Services;

-using LibMatrix.Responses;

-using Microsoft.AspNetCore.Mvc;

-

-namespace LibMatrix.HomeserverEmulator.Controllers;

-

-[ApiController]

-[Route("/_matrix/client/{version}/")]

-public class FilterController(ILogger<FilterController> logger, TokenService tokenService, UserStore userStore, RoomStore roomStore) : ControllerBase {

-    [HttpPost("user/{mxid}/filter")]

-    public async Task<object> CreateFilter(string mxid, [FromBody] SyncFilter filter) {

-        var token = tokenService.GetAccessToken(HttpContext);

-        var user = await userStore.GetUserByToken(token, false);

-        if (user is null)

-            throw new MatrixException() {

-                ErrorCode = "M_UNAUTHORIZED",

-                Error = "Invalid token."

-            };

-        var filterId = Guid.NewGuid().ToString();

-        user.Filters[filterId] = filter;

-        return new {

-            filter_id = filterId

-        };

-    }

-    

-    [HttpGet("user/{mxid}/filter/{filterId}")]

-    public async Task<SyncFilter> GetFilter(string mxid, string filterId) {

-        var token = tokenService.GetAccessToken(HttpContext);

-        var user = await userStore.GetUserByToken(token, false);

-        if (user is null)

-            throw new MatrixException() {

-                ErrorCode = "M_UNAUTHORIZED",

-                Error = "Invalid token."

-            };

-        if (!user.Filters.ContainsKey(filterId))

-            throw new MatrixException() {

-                ErrorCode = "M_NOT_FOUND",

-                Error = "Filter not found."

-            };

-        return user.Filters[filterId];

-    }

-}
\ No newline at end of file