using DorkNet.Server.Auth;
using Microsoft.AspNetCore.Mvc;
namespace DorkNet.Server.Controllers.API.Pageview;
///
/// Endpoints behind the watch's COFHGNFJMOG page-view + link
/// system. The 2020.12 client fires POST pageview/consume on
/// every screen change in the boot/menu flow expecting a response
/// that tells it (a) whether there's an in-app deep-link URL to
/// resolve and (b) how long the answer is fresh for. Returning a 404
/// here surfaces as red toast spam in the menus and (per
/// BootSequence.OINIBKFNFAJ) can short-circuit the avatar /
/// inventory bootstrap.
///
/// Response shape verified at
/// Cpp2IL_ISIL/.../MPHABHIMOOO.txt:45,50 — the watch's
/// MPHABHIMOOO.PPGFHEDFBEA(Dictionary) reads two camelCase
/// keys:
///
/// - url — string. Empty means "no deep-link to load".
/// - freshnessSeconds — int. How long the client can
/// cache this response before re-polling.
///
/// Returning a long freshness (1 hour) keeps a private server's
/// chattiness low when there's no real linking layer.
///
/// Sibling endpoints from the same watch class
/// (actionlink/*, datalink/*, referral) are out
/// of scope for now — they fire only on explicit user share/click,
/// not in the boot path. Add them as separate routes when they show
/// up in the production log.
///
[ApiController]
public class PageviewController(ILogger logger) : ControllerBase
{
/// POST pageview/consume — record a screen
/// transition. The body is empty in 2020.12.
/// Promise<MPHABHIMOOO> result; the watch only uses
/// the url / freshnessSeconds fields. We
/// intentionally return an empty url + a 1-hour freshness — the
/// private server has no in-app deep-link system, so there's
/// nothing to navigate to and no reason to be polled more often.
[HttpPost("pageview/consume", Order = 10)]
[HttpPost("/pageview/consume")]
[HttpGet("pageview/consume", Order = 10)]
[HttpGet("/pageview/consume")]
public IActionResult Consume()
{
logger.LogDebug("[pageview] consume callerId={Caller}", this.CurrentPlayerId() ?? 0);
return Ok(new
{
url = string.Empty,
freshnessSeconds = 3600,
});
}
}