Kill switch
Deploy Promiscuity Auth API / deploy (push) Successful in 47s
Deploy Promiscuity Crafting API / deploy (push) Has been cancelled
Deploy Promiscuity Inventory API / deploy (push) Has been cancelled
Deploy Promiscuity Locations API / deploy (push) Has been cancelled
Deploy Promiscuity Mail API / deploy (push) Has been cancelled
Deploy Promiscuity World API / deploy (push) Has been cancelled
Deploy Promiscuity Character API / deploy (push) Has been cancelled
k8s smoke test / test (push) Has been cancelled
Deploy Promiscuity Auth API / deploy (push) Successful in 47s
Deploy Promiscuity Crafting API / deploy (push) Has been cancelled
Deploy Promiscuity Inventory API / deploy (push) Has been cancelled
Deploy Promiscuity Locations API / deploy (push) Has been cancelled
Deploy Promiscuity Mail API / deploy (push) Has been cancelled
Deploy Promiscuity World API / deploy (push) Has been cancelled
Deploy Promiscuity Character API / deploy (push) Has been cancelled
k8s smoke test / test (push) Has been cancelled
This commit is contained in:
@@ -68,11 +68,28 @@ public class CharactersController : ControllerBase
|
||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (string.IsNullOrWhiteSpace(userId))
|
||||
return Unauthorized();
|
||||
|
||||
|
||||
var characters = await _characters.GetForOwnerAsync(userId);
|
||||
return Ok(characters);
|
||||
}
|
||||
|
||||
[HttpPost("internal/reset-coords")]
|
||||
public async Task<IActionResult> ResetCoordsInternal([FromBody] InternalResetCharactersToCoordRequest req)
|
||||
{
|
||||
var configuredKey = (_configuration["InternalApi:Key"] ?? _configuration["Jwt:Key"] ?? string.Empty).Trim();
|
||||
var requestKey = (Request.Headers["X-Internal-Api-Key"].FirstOrDefault() ?? string.Empty).Trim();
|
||||
if (string.IsNullOrWhiteSpace(configuredKey) || !string.Equals(configuredKey, requestKey, StringComparison.Ordinal))
|
||||
return Unauthorized();
|
||||
if (req.Coord is null)
|
||||
return BadRequest("coord required");
|
||||
|
||||
var updatedCharacterCount = await _characters.ResetAllCoordsAsync(req.Coord);
|
||||
return Ok(new InternalResetCharactersToCoordResponse
|
||||
{
|
||||
UpdatedCharacterCount = updatedCharacterCount
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet("{id}/visible-locations")]
|
||||
[Authorize(Roles = "USER,SUPER")]
|
||||
public async Task<IActionResult> VisibleLocations(string id)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace CharacterApi.Models;
|
||||
|
||||
public class InternalResetCharactersToCoordRequest
|
||||
{
|
||||
public required Coord Coord { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace CharacterApi.Models;
|
||||
|
||||
public class InternalResetCharactersToCoordResponse
|
||||
{
|
||||
public int UpdatedCharacterCount { get; set; }
|
||||
}
|
||||
@@ -49,6 +49,15 @@ public class CharacterStore
|
||||
return result.ModifiedCount > 0 || result.MatchedCount > 0;
|
||||
}
|
||||
|
||||
public async Task<int> ResetAllCoordsAsync(Coord coord)
|
||||
{
|
||||
var update = Builders<Character>.Update
|
||||
.Set(c => c.Coord, coord)
|
||||
.Set(c => c.LastSeenUtc, DateTime.UtcNow);
|
||||
var result = await _col.UpdateManyAsync(Builders<Character>.Filter.Empty, update);
|
||||
return (int)result.MatchedCount;
|
||||
}
|
||||
|
||||
public async Task<List<VisibleCharacter>> GetVisibleOthersAsync(string characterId, int x, int y, int radius, DateTime onlineSinceUtc)
|
||||
{
|
||||
var characters = await _col.Find(c =>
|
||||
|
||||
Reference in New Issue
Block a user