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

This commit is contained in:
Zeeshaun
2026-04-01 20:22:05 +00:00
parent bed8e91bc0
commit c718fb343d
14 changed files with 413 additions and 15 deletions
@@ -22,6 +22,7 @@ public class InventoryStore
private readonly string _dbName;
public sealed record GrantResult(List<InventoryItem> Items, int RequestedQuantity, int GrantedQuantity, int OverflowQuantity);
public sealed record ReassignLocationInventoryResult(bool TargetLocationExists, int ReassignedItemCount);
public InventoryStore(IConfiguration cfg)
{
@@ -114,6 +115,35 @@ public class InventoryStore
.ToDictionary(group => group.Key, group => group.ToList(), StringComparer.Ordinal);
}
public async Task<ReassignLocationInventoryResult> ReassignLocationInventoryOwnersAsync(IEnumerable<string> fromOwnerIds, string toOwnerId)
{
var normalizedToOwnerId = toOwnerId.Trim();
var targetExists = await _locations.Find(location => location.Id == normalizedToOwnerId).AnyAsync();
if (!targetExists)
return new ReassignLocationInventoryResult(false, 0);
var sourceOwnerIds = fromOwnerIds
.Where(id => !string.IsNullOrWhiteSpace(id))
.Select(id => id.Trim())
.Where(id => !string.Equals(id, normalizedToOwnerId, StringComparison.Ordinal))
.Distinct(StringComparer.Ordinal)
.ToList();
if (sourceOwnerIds.Count == 0)
return new ReassignLocationInventoryResult(true, 0);
var filter = Builders<InventoryItem>.Filter.And(
Builders<InventoryItem>.Filter.Eq(item => item.OwnerType, LocationOwnerType),
Builders<InventoryItem>.Filter.In(item => item.OwnerId, sourceOwnerIds));
var update = Builders<InventoryItem>.Update
.Set(item => item.OwnerId, normalizedToOwnerId)
.Set(item => item.OwnerUserId, null)
.Unset(item => item.Slot)
.Unset(item => item.EquippedSlot)
.Set(item => item.UpdatedUtc, DateTime.UtcNow);
var result = await _items.UpdateManyAsync(filter, update);
return new ReassignLocationInventoryResult(true, (int)result.ModifiedCount);
}
public Task<List<ItemDefinition>> ListItemDefinitionsAsync() =>
_definitions.Find(Builders<ItemDefinition>.Filter.Empty).SortBy(d => d.ItemKey).ToListAsync();