mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-04-19 19:14:51 +00:00
Revert "Add online users endpoint to user API" (#790)
Revert "Add online users endpoint to user API (#789)"
This reverts commit d1e21b4e18
.
This commit is contained in:
parent
d1e21b4e18
commit
170e824e96
1 changed files with 2 additions and 26 deletions
|
@ -96,7 +96,8 @@ public class UserEndpoints : ApiEndpointController
|
|||
[HttpPost("user/inviteToken/{username}")]
|
||||
public async Task<IActionResult> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of online users and returns it.
|
||||
/// </summary>
|
||||
/// <param name="page">Page number. Increments skip value by clamp value</param>
|
||||
/// <param name="clamp">Number of entries to clamp response to</param>
|
||||
/// <returns>Array of online users ordered by login time</returns>
|
||||
/// <response code="200">List of users</response>
|
||||
[HttpGet("users/online")]
|
||||
[ProducesResponseType(typeof(ApiUser), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetOnlineUsers(int page = 0, int clamp = 50)
|
||||
{
|
||||
if (clamp > 100) return this.BadRequest();
|
||||
|
||||
List<ApiUser> 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue