feat: Update PlayerCheer and Avatar handling; enhance API responses and add new fields for 2023 client compatibility

This commit is contained in:
Alexa
2026-07-12 23:54:11 +03:00
parent 3d7d7ebdf1
commit 757308b44d
8 changed files with 415 additions and 185 deletions
@@ -10,28 +10,50 @@ namespace DorkNet.Server.Controllers.API.InfluencerPartnerProgram;
[ApiController]
public class InfluencerPartnerProgramController(DorkNetDbContext db) : ControllerBase
{
// The 2023 client's influencer API (RecNet.Runtime IBEEFFGHGND) reads
// BARE scalars, NOT wrapped account objects:
// influencers → List<Int32> (account ids)
// influencer → Nullable<Int32> (the account id, or null)
// myinfluencer → Nullable<Int32> (supported influencer's id, or null)
// Returning an object here crashes the strict reader
// ("expected:'Number Token', actual:'{'"), which is what broke the
// profile view (and the cheer flow that opens it).
// 2023 client influencer API (RecNet.Runtime IBEEFFGHGND) — REAL wire
// shapes verified against the 2023.03.21 ISIL decompile:
//
// influencers → OBJECT {"InfluencerIds":[...],"ContinuationToken":null}
// - IBEEFFGHGND.txt:1612 — response callback is
// Func<FEAJJMACBMF, FGLDKEJLAKB<List<Int32>>>, i.e. the body is
// deserialized as DTO object FEAJJMACBMF, NOT a bare array
// (a bare array crashes the strict reader:
// "FGNDDNDAFCI: expected:'{', actual:'['").
// - FLEDNKHKIND.txt:215-265 — FEAJJMACBMF's generated reader
// registers keys "InfluencerIds" and "ContinuationToken"
// (Pascal/camel/lower probes, so camelCase is accepted).
// - IBEEFFGHGND_NestedType___c.txt:318-358
// (<GetAllInfluencersInternal>b__12_0) — a non-null
// ContinuationToken triggers a recursive next-page fetch, so it
// must be null once the single page is exhausted.
// - IBEEFFGHGND.txt:1547-1575 (OELDHDEIFGP) — client sends
// take=1000 + continuationToken query params.
[HttpGet("api/influencerpartnerprogram/influencers")]
[AllowAnonymous]
public async Task<IActionResult> Influencers([FromQuery] int take = 50)
{
take = Math.Clamp(take, 1, 100);
take = Math.Clamp(take, 1, 1000);
var creatorIds = await db.Rooms.Select(r => r.CreatorPlayerId)
.Concat(db.Inventions.Where(i => !i.IsDeleted).Select(i => i.CreatorPlayerId))
.Concat(db.CustomAvatarItems.Select(i => i.CreatorPlayerId))
.Distinct()
.Take(take)
.ToListAsync();
return Ok(creatorIds.Select(id => (int)id).ToArray());
return Ok(new
{
InfluencerIds = creatorIds.Select(id => (int)id).ToArray(),
ContinuationToken = (string?)null,
});
}
// influencer / myinfluencer → bare Int32 scalar, "no influencer" = 0:
// - IBEEFFGHGND.txt:598/951 — both pipelines parse the body as Int32
// and convert via Func<Int32, Nullable<Int32>>.
// - IBEEFFGHGND_NestedType___c.txt:61-111
// (<GetMySupportedInfluencer>b__8_0) — the converter maps
// id == 0 → null, else (int?)id. So the correct "none" response is
// the literal number 0. A "null"/empty body throws
// CHGIJBGGJAG "Response was empty" (Player.log:1947-2031).
[HttpGet("api/influencerpartnerprogram/influencer")]
[AllowAnonymous]
public async Task<IActionResult> Influencer([FromQuery] long? accountId = null, [FromQuery] string? username = null)
@@ -39,7 +61,7 @@ public class InfluencerPartnerProgramController(DorkNetDbContext db) : Controlle
var playerId = accountId is long id
? await db.Players.Where(p => p.Id == id).Select(p => (long?)p.Id).FirstOrDefaultAsync()
: await db.Players.Where(p => p.Username == username).Select(p => (long?)p.Id).FirstOrDefaultAsync();
return Content(playerId is long pid ? ((int)pid).ToString() : "null", "application/json");
return Content(playerId is long pid ? ((int)pid).ToString() : "0", "application/json");
}
[HttpGet("api/influencerpartnerprogram/myinfluencer")]
@@ -52,7 +74,7 @@ public class InfluencerPartnerProgramController(DorkNetDbContext db) : Controlle
return Content(
setting is not null && long.TryParse(setting.Value, out var influencerId)
? ((int)influencerId).ToString()
: "null",
: "0",
"application/json");
}