-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from Gml-Launcher/develop
Update to v1.0.3
- Loading branch information
Showing
25 changed files
with
468 additions
and
141 deletions.
There are no files selected for viewing
Submodule Gml.Core
updated
12 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace Gml.Web.Api.Dto.Player; | ||
|
||
public class AuthUserHistoryDto | ||
{ | ||
public DateTime Date { get; set; } | ||
public string Device { get; set; } | ||
public string? Address { get; set; } | ||
public string Protocol { get; set; } | ||
public string? Hwid { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Gml.Web.Api.Dto.Player; | ||
|
||
public class ExtendedPlayerReadDto : PlayerReadDto | ||
{ | ||
public bool IsBanned { get; set; } | ||
public List<AuthUserHistoryDto> AuthHistory { get; set; } = new(); | ||
public List<ServerJoinHistoryDto> ServerJoinHistory { get; set; } = new(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System; | ||
|
||
namespace Gml.Web.Api.Dto.Player; | ||
|
||
public record ServerJoinHistoryDto | ||
{ | ||
public string ServerUuid { get; set; } | ||
public DateTime Date { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
182 changes: 133 additions & 49 deletions
182
src/Gml.Web.Api/Core/Extensions/EndpointsExtensions.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Gml.Web.Api.Core.Handlers; | ||
|
||
public interface IPlayersHandler | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Net; | ||
using AutoMapper; | ||
using Gml.Web.Api.Dto.Messages; | ||
using Gml.Web.Api.Dto.Player; | ||
using GmlCore.Interfaces; | ||
|
||
namespace Gml.Web.Api.Core.Handlers; | ||
|
||
public class PlayersHandler : IPlayersHandler | ||
{ | ||
public static async Task<IResult> GetPlayers(IGmlManager gmlManager, IMapper mapper, int? take, int? offset, string? findName) | ||
{ | ||
var players = await gmlManager.Users.GetUsers(take ?? 20, offset ?? 0, findName ?? string.Empty); | ||
|
||
return Results.Ok(ResponseMessage.Create(mapper.Map<List<ExtendedPlayerReadDto>>(players), "Список пользователей успешно получен", HttpStatusCode.OK)); | ||
} | ||
|
||
public static async Task<IResult> BanPlayer( | ||
IGmlManager gmlManager, | ||
IMapper mapper, | ||
IList<string> playerUuids, | ||
bool deviceBlock = false) | ||
{ | ||
if (!playerUuids.Any()) | ||
{ | ||
return Results.BadRequest(ResponseMessage.Create("Не передан ни один пользователь для блокировки", | ||
HttpStatusCode.BadRequest)); | ||
} | ||
|
||
foreach (var playerUuid in playerUuids) | ||
{ | ||
var player = await gmlManager.Users.GetUserByUuid(playerUuid); | ||
|
||
if (player is null) continue; | ||
player.IsBanned = true; | ||
await gmlManager.Users.UpdateUser(player); | ||
} | ||
|
||
return Results.Ok(ResponseMessage.Create("Пользователь(и) успешно заблокированы", HttpStatusCode.OK)); | ||
} | ||
|
||
public static async Task<IResult> PardonPlayer( | ||
IGmlManager gmlManager, | ||
IMapper mapper, | ||
IList<string> playerUuids) | ||
{ | ||
if (!playerUuids.Any()) | ||
{ | ||
return Results.BadRequest(ResponseMessage.Create("Не передан ни один пользователь для блокировки", | ||
HttpStatusCode.BadRequest)); | ||
} | ||
|
||
foreach (var playerUuid in playerUuids) | ||
{ | ||
var player = await gmlManager.Users.GetUserByUuid(playerUuid); | ||
|
||
if (player is null) continue; | ||
player.IsBanned = false; | ||
await gmlManager.Users.UpdateUser(player); | ||
} | ||
|
||
return Results.Ok(ResponseMessage.Create("Пользователь(и) успешно разблокированы", HttpStatusCode.OK)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.