mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-26 07:28:45 -07:00
6ee1d6f9b3
Every change below was checked against the 2023-03-21 client disassembly;
file:line evidence is in the code comments and in
docs/recroom-2023-client-api-complete.md.
Presence
- matchmake/none means "online, in no room" (its only caller is
TryGoToOfflineRoom, which ignores the reply). The server used to keep the
old room or invent a dorm, so the next heartbeat looked out of sync and
the client cancelled its load to chase that room.
- The join watchdog no longer clears presence 30 s into a long room load;
it is a 3 minute backstop that drops the room only.
- One fan-out (PresenceBroadcastService) for every transition: deferred
joins, matchmake/none, logout, failed joins, visibility changes, SignalR
connect/disconnect. isOnline is sent on its own; pushes never go to the
subject, because a self push moves the player.
- Online-status visibility (Public / Friends / Favorites / Appear offline)
is stored and honoured by GET /player and by the live pushes.
Profile
- PUT account/me/{emoji,personalpronouns,identityflags,bannerimage} were
404; added with the client's real form keys and persisted (new Players
columns plus migration). Every account read now returns them, and edits
push AccountUpdate to everyone.
Outfit menu
- Saved outfits kept OutfitSelectionsV2 and CustomAvatarItems, so loading a
slot restores what was saved instead of a stale outfit.
- isCreationAllowedForAccount answers the {Success, Error} envelope the
client parses; minPriceForPublicItem is a bare int; gifts/generate accepts
form bodies; lockeditems returns the full owned-item shape; colourways no
longer share their base item's AvatarItemId.
RecNetResult writes
- About 40 writes look status-only but parse the body as {Success, Error}.
An empty 200 showed "Failed to ..." after the server applied the change,
and a body without Success threw "Error message cannot be null". Clubs,
announcements, keepsakes, comments/read, subscriptions, purchase offers
and privacy settings now answer RecNetResult.
- Login token and device-code grants are real; remoteauth approves the
device code; createlogintoken returns a bare string.
- New: incentivizedreferrals/referrals, account/bulk/{email,phone},
GET strings, account/me/confirmphone, PlayMenuCarouselOrdering_1.
Route inventory and coverage test extended to match.
README now describes the 2023 branch.
81 lines
3.8 KiB
C#
81 lines
3.8 KiB
C#
using System.Net.Http.Headers;
|
|
using System.Text.Json;
|
|
using DorkNet.Server.Data;
|
|
using DorkNet.Server.Data.Entities;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace DorkNet.Server.Tests;
|
|
|
|
/// <summary>
|
|
/// <c>GET api/incentivizedreferrals/referrals?take=&continuationToken=</c> is
|
|
/// assembled by the client's URL builder (RecNet.Runtime/LINKIECPDML.txt:677-737),
|
|
/// so it never showed up as a route literal and had no handler. The reply is the
|
|
/// GPJIMAHMAIO page: <c>{Referrals:[{InviteeAccountId, CreatedAt, VerifiedAt}],
|
|
/// ContinuationToken}</c> (KOEEACLMAFE.txt:203-238, ADAFNGNADFH.txt:279-346).
|
|
/// </summary>
|
|
public sealed class IncentivizedReferralsTests : IClassFixture<DorkNetServerFactory>
|
|
{
|
|
private readonly DorkNetServerFactory _factory;
|
|
|
|
public IncentivizedReferralsTests(DorkNetServerFactory factory) => _factory = factory;
|
|
|
|
[Fact]
|
|
public async Task Referrals_page_lists_credited_invitees_with_a_continuation_token()
|
|
{
|
|
using var setup = Client();
|
|
var referrer = await GameClientSessionFactory.CreateAsync(setup, _factory.ApexDomain);
|
|
var inviteeA = await GameClientSessionFactory.CreateAsync(setup, _factory.ApexDomain);
|
|
var inviteeB = await GameClientSessionFactory.CreateAsync(setup, _factory.ApexDomain);
|
|
|
|
await using (var scope = _factory.Services.CreateAsyncScope())
|
|
{
|
|
var db = scope.ServiceProvider.GetRequiredService<DorkNetDbContext>();
|
|
// Same row LinkController.CreditReferralAsync writes on the invitee.
|
|
foreach (var invitee in new[] { inviteeA, inviteeB })
|
|
db.PlayerSettings.Add(new PlayerSettingEntity
|
|
{
|
|
PlayerId = invitee.PlayerId,
|
|
Key = $"referral:credited:{referrer.PlayerId}:{invitee.PlayerId}",
|
|
Value = DateTime.UtcNow.ToString("O"),
|
|
});
|
|
await db.SaveChangesAsync();
|
|
}
|
|
|
|
using var client = Client(referrer);
|
|
var first = JsonDocument.Parse(
|
|
await client.GetStringAsync("/api/incentivizedreferrals/referrals?take=1")).RootElement;
|
|
var firstPage = Get(first, "Referrals");
|
|
Assert.Equal(1, firstPage.GetArrayLength());
|
|
var token = Get(first, "ContinuationToken").GetString();
|
|
Assert.False(string.IsNullOrEmpty(token));
|
|
|
|
var second = JsonDocument.Parse(await client.GetStringAsync(
|
|
$"/api/incentivizedreferrals/referrals?take=1&continuationToken={token}")).RootElement;
|
|
var secondPage = Get(second, "Referrals");
|
|
Assert.Equal(1, secondPage.GetArrayLength());
|
|
Assert.Equal(JsonValueKind.Null, Get(second, "ContinuationToken").ValueKind);
|
|
|
|
var ids = new[] { firstPage[0], secondPage[0] }
|
|
.Select(e => Get(e, "InviteeAccountId").GetInt64())
|
|
.OrderBy(x => x)
|
|
.ToArray();
|
|
Assert.Equal(new[] { inviteeA.PlayerId, inviteeB.PlayerId }.OrderBy(x => x), ids);
|
|
// CreatedAt is a non-nullable DateTime on the client: it must be present.
|
|
Assert.Equal(JsonValueKind.String, Get(firstPage[0], "CreatedAt").ValueKind);
|
|
}
|
|
|
|
// The client formatter registers PascalCase, camelCase and lowercase.
|
|
private static JsonElement Get(JsonElement e, string pascal) =>
|
|
e.TryGetProperty(pascal, out var v) ? v : e.GetProperty(char.ToLowerInvariant(pascal[0]) + pascal[1..]);
|
|
|
|
private HttpClient Client(GameClientSession? session = null)
|
|
{
|
|
var client = _factory.CreateClient(new() { AllowAutoRedirect = false });
|
|
client.BaseAddress = new Uri($"http://api.{_factory.ApexDomain}");
|
|
if (session is not null)
|
|
client.DefaultRequestHeaders.Authorization =
|
|
new AuthenticationHeaderValue("Bearer", session.AccessToken);
|
|
return client;
|
|
}
|
|
}
|