mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-26 07:28:45 -07:00
feat: Add tests for 2023 watch shop tab and room consumables; implement new storefront endpoint and update documentation
This commit is contained in:
@@ -32,7 +32,6 @@ public class StorefrontsController(
|
||||
[HttpGet("api/storefronts/v1/all")]
|
||||
[HttpGet("api/storefronts/v2/all")]
|
||||
[HttpGet("api/storefronts/v3/all")]
|
||||
[HttpGet("api/storefronts/v1/toptoday")]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> All()
|
||||
{
|
||||
@@ -40,6 +39,24 @@ public class StorefrontsController(
|
||||
return Ok(items.Select(i => StoreService.ToItemDto(i, domain.Apex)).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>GET <c>api/storefronts/v1/toptoday</c> — the 2023 Shop
|
||||
/// tab's "featured today" strip. The client (DCFKEFHJAGC.IDCIMNLBINC)
|
||||
/// deserialises the body as a bare <c>List<int></c> of
|
||||
/// PurchasableItemIds and resolves each against the gift-drop cache
|
||||
/// it loaded from <c>/v3/giftdropstore/{id}</c> — so these ids MUST
|
||||
/// be ids that appear on that storefront's rows, or the client logs
|
||||
/// "Could not find purchasable giftdrop" and drops them. Returning
|
||||
/// item OBJECTS here (the old /all alias) made the whole featured
|
||||
/// fetch fail to parse.</summary>
|
||||
[HttpGet("api/storefronts/v1/toptoday")]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> TopToday()
|
||||
{
|
||||
var items = await store.GetRenderableGiftDropItemsAsync();
|
||||
var max = Math.Max(1, config.GetValue("Store:MaxTopTodayItems", 12));
|
||||
return Ok(items.Take(max).Select(StoreService.PurchasableItemIdFor).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>GET <c>api/storefronts/v1/adcarouselitems</c> — the rotating
|
||||
/// promo banner at the top of the Shop, NOT the main catalog. The client
|
||||
/// (AdCarouselItemListModel) keys these by <c>AdCarouselItemId</c> in a
|
||||
|
||||
@@ -973,6 +973,13 @@ public class StoreService(DorkNetDbContext db, LevelService level, IConfiguratio
|
||||
// REQUIRED.
|
||||
GiftDropId = itemId,
|
||||
Rarity = MapRarity(i.Category),
|
||||
// 2023 additions (EMBCEDNHFLB formatter): TagList is a CSV
|
||||
// string, Currency is the CurrencyType enum repeated, ItemSet*
|
||||
// group multi-part outfits (we don't sell sets).
|
||||
TagList = "",
|
||||
Currency = i.CurrencyType,
|
||||
ItemSetId = (int?)null,
|
||||
ItemSetFriendlyName = "",
|
||||
// Optional / nullable string fields the watch reads.
|
||||
FriendlyName = i.DisplayName,
|
||||
Tooltip = i.Description,
|
||||
@@ -1008,11 +1015,22 @@ public class StoreService(DorkNetDbContext db, LevelService level, IConfiguratio
|
||||
IsFeatured = positionalIndex < 12, // first dozen show in Featured tab
|
||||
Prices = new[] { price },
|
||||
SubscriberPrices = Array.Empty<object>(),
|
||||
// PurchasableGiftDrop adds GiftDrops on top.
|
||||
// 2020 PurchasableGiftDrop carries a GiftDrops LIST; the 2023
|
||||
// row (POGBAGAHGIA formatter) reads a single "GiftDrop" object
|
||||
// instead. Ship both: whichever formatter parses the row skips
|
||||
// the key it doesn't know. Missing "GiftDrop" leaves the 2023
|
||||
// row's inner desc null and StoreItemListModel's filter
|
||||
// predicate NREs on every item — the Shop tab shows nothing.
|
||||
GiftDrop = giftDrop,
|
||||
GiftDrops = new[] { giftDrop },
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The wire PurchasableItemId for a store row — must match
|
||||
/// what <see cref="BuildPurchasableGiftDrop"/> puts on the row so
|
||||
/// id-lists (toptoday) resolve against the gift-drop cache.</summary>
|
||||
public static int PurchasableItemIdFor(StoreItemEntity i) => (int)(i.Id & 0x7fffffff);
|
||||
|
||||
/// <summary>GiftManager.GiftRarity wire values:
|
||||
/// None=-1, Common=0, Uncommon=10, Rare=20, Epic=30, Legendary=50.</summary>
|
||||
private static int MapRarity(string? category) => category?.ToLowerInvariant() switch
|
||||
|
||||
Reference in New Issue
Block a user