Build & Deploy / build (push) Successful in 24s
- RequestUsersPingRequest: the client sends ping=2147483648 (int.MaxValue+1) for "no ping", which overflowed the int field and made every ping request return 500. Widened to long. - ClientsideFriendsImport: persist the imported Steam friend ids per user. - GetFriendList: resolve those ids to the players that exist on this server (batch lookup by Steam auth key) and return them as friends. Response shape is best-effort pending in-game confirmation. - DbUserService.FindManyAsync: batch-resolve auth keys to players. First step of the station lobby (see friends on the server). Squad formation / invite flow to follow once friends are visible. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
using Microsoft.Extensions.Options;
|
|
using MongoDB.Driver;
|
|
using Prospect.Server.Api.Config;
|
|
using Prospect.Server.Api.Services.Database.Models;
|
|
|
|
namespace Prospect.Server.Api.Services.Database;
|
|
|
|
public class DbUserService : BaseDbService<PlayFabUser>
|
|
{
|
|
public DbUserService(IOptions<DatabaseSettings> settings) : base(settings, nameof(PlayFabUser))
|
|
{
|
|
}
|
|
|
|
public async Task<PlayFabUser> FindAsync(PlayFabUserAuthType type, string key)
|
|
{
|
|
return await Collection.Find(user => user.Auth.Any(auth =>
|
|
auth.Type == type &&
|
|
auth.Key == key)).FirstOrDefaultAsync();
|
|
}
|
|
|
|
private async Task<PlayFabUser> CreateAsync(PlayFabUserAuthType type, string key)
|
|
{
|
|
var user = new PlayFabUser
|
|
{
|
|
DisplayName = "Unknown",
|
|
Auth = new List<PlayFabUserAuth>
|
|
{
|
|
new PlayFabUserAuth
|
|
{
|
|
Type = type,
|
|
Key = key
|
|
}
|
|
}
|
|
};
|
|
|
|
await Collection.InsertOneAsync(user);
|
|
|
|
return user;
|
|
}
|
|
|
|
public async Task<PlayFabUser> FindOrCreateAsync(PlayFabUserAuthType type, string key)
|
|
{
|
|
return await FindAsync(type, key) ??
|
|
await CreateAsync(type, key);
|
|
}
|
|
|
|
// Resolve several auth keys (e.g. a batch of Steam IDs) to the players that exist on
|
|
// this server in a single query. Used by the friends list to keep only the imported
|
|
// Steam friends who have actually played here.
|
|
public async Task<List<PlayFabUser>> FindManyAsync(PlayFabUserAuthType type, IReadOnlyCollection<string> keys)
|
|
{
|
|
if (keys == null || keys.Count == 0)
|
|
{
|
|
return new List<PlayFabUser>();
|
|
}
|
|
var wanted = new HashSet<string>(keys);
|
|
return await Collection.Find(user => user.Auth.Any(auth =>
|
|
auth.Type == type && wanted.Contains(auth.Key))).ToListAsync();
|
|
}
|
|
} |