diff options
Diffstat (limited to 'Tests/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomsController.cs')
-rw-r--r-- | Tests/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomsController.cs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/Tests/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomsController.cs b/Tests/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomsController.cs index e9f52dc..b0f5014 100644 --- a/Tests/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomsController.cs +++ b/Tests/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomsController.cs @@ -112,7 +112,7 @@ public class RoomsController(ILogger<RoomsController> logger, TokenService token ["creator"] = user.UserId } }); - + oldRoom.State.Where(x => eventTypesToTransfer.Contains(x.Type)).ToList().ForEach(x => room.SetStateInternal(x)); room.AddUser(user.UserId); @@ -122,6 +122,38 @@ public class RoomsController(ILogger<RoomsController> logger, TokenService token replacement_room = room.RoomId }; } + + [HttpPost("rooms/{roomId}/leave")] // TODO: implement + public async Task<object> LeaveRoom(string roomId) { + var token = tokenService.GetAccessToken(HttpContext); + if (token == null) + throw new MatrixException() { + ErrorCode = "M_MISSING_TOKEN", + Error = "Missing token" + }; + + var user = await userStore.GetUserByToken(token); + if (user == null) + throw new MatrixException() { + ErrorCode = "M_UNKNOWN_TOKEN", + Error = "No such user" + }; + + var room = roomStore.GetRoomById(roomId); + if (room == null) + throw new MatrixException() { + ErrorCode = "M_NOT_FOUND", + Error = "Room not found" + }; + + // room.RemoveUser(user.UserId); + + // room.SetStateInternal(new StateEventResponse() { }); + + return new { + room_id = room.RoomId + }; + } } public class UpgradeRoomRequest { |