From 170e824e96999e463c3095129e8fcf05efcfabc1 Mon Sep 17 00:00:00 2001 From: Michael Youngling <89745384+m88youngling@users.noreply.github.com> Date: Sun, 11 Jun 2023 16:27:38 -0400 Subject: [PATCH] Revert "Add online users endpoint to user API" (#790) Revert "Add online users endpoint to user API (#789)" This reverts commit d1e21b4e1862f1e32f307e77fe62651e7d3a0591. --- .../Controllers/UserEndpoints.cs | 28 ++----------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/ProjectLighthouse.Servers.API/Controllers/UserEndpoints.cs b/ProjectLighthouse.Servers.API/Controllers/UserEndpoints.cs index d5e074b7..cb095a60 100644 --- a/ProjectLighthouse.Servers.API/Controllers/UserEndpoints.cs +++ b/ProjectLighthouse.Servers.API/Controllers/UserEndpoints.cs @@ -96,7 +96,8 @@ public class UserEndpoints : ApiEndpointController [HttpPost("user/inviteToken/{username}")] public async Task CreateUserInviteToken([FromRoute] string? username) { - if (!Configuration.ServerConfiguration.Instance.Authentication.RegistrationEnabled) return this.NotFound(); + if (!Configuration.ServerConfiguration.Instance.Authentication.RegistrationEnabled) + return this.NotFound(); string? authHeader = this.Request.Headers["Authorization"]; if (string.IsNullOrWhiteSpace(authHeader)) return this.NotFound(); @@ -124,29 +125,4 @@ public class UserEndpoints : ApiEndpointController return this.Ok(token.Token); } - - /// - /// Gets a list of online users and returns it. - /// - /// Page number. Increments skip value by clamp value - /// Number of entries to clamp response to - /// Array of online users ordered by login time - /// List of users - [HttpGet("users/online")] - [ProducesResponseType(typeof(ApiUser), StatusCodes.Status200OK)] - public async Task GetOnlineUsers(int page = 0, int clamp = 50) - { - if (clamp > 100) return this.BadRequest(); - - List onlineUsers = (await this.database.Users - .Where(u => u.PermissionLevel != PermissionLevel.Banned) - .Where(u => u.ProfileVisibility == PrivacyType.All) - .Where(u => u.GetStatus(this.database).StatusType == StatusType.Online) - .OrderByDescending(u => u.LastLogin) - .Skip(page * clamp) - .Take(clamp) - .ToListAsync()).ToSerializableList(ApiUser.CreateFromEntity); - - return this.Ok(onlineUsers); - } } \ No newline at end of file