Skip to content

Commit

Permalink
Check for null gamertags from older netplay builds
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianCassar committed Jun 17, 2024
1 parent ba4f559 commit e21ba47
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/application/commands/CreatePlayerCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import Gamertag from 'src/domain/value-objects/Gamertag';
export class CreatePlayerCommand {
constructor(
public readonly xuid: Xuid,
public readonly gamertag: Gamertag,
public readonly machineId: Xuid,
public readonly hostAddress: IpAddress,
public readonly macAddress: MacAddress,
public readonly gamertag?: Gamertag,
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class FindLeaderboardsQueryHandler

leaderboardResponse.players.push({
xuid: player.value,
gamertag: user.gamertag.value,
gamertag: user.gamertag?.value,
stats,
});
}),
Expand Down
4 changes: 2 additions & 2 deletions src/domain/aggregates/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Gamertag from '../value-objects/Gamertag';

interface PlayerProps {
xuid: Xuid;
gamertag: Gamertag;
gamertag?: Gamertag;
hostAddress: IpAddress;
macAddress: MacAddress;
machineId: Xuid;
Expand All @@ -16,7 +16,7 @@ interface PlayerProps {

interface CreateProps {
xuid: Xuid;
gamertag: Gamertag;
gamertag?: Gamertag;
hostAddress: IpAddress;
macAddress: MacAddress;
machineId: Xuid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class PlayerDomainMapper {
public mapToDomainModel(player: PlayerModel): Player {
return new Player({
xuid: new Xuid(player.xuid),
gamertag: new Gamertag(player.gamertag),
gamertag: player.gamertag ? new Gamertag(player.gamertag) : undefined,
hostAddress: new IpAddress(player.hostAddress),
macAddress: new MacAddress(player.macAddress),
machineId: new Xuid(player.machineId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class PlayerPersistanceMapper {
public mapToDataModel(player: Player): PlayerModel {
return {
xuid: player.xuid.value,
gamertag: player.gamertag.value,
gamertag: player.gamertag?.value,
hostAddress: player.hostAddress.value,
machineId: player.machineId.value,
macAddress: player.macAddress.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ export class PlayerController {
await this.commandBus.execute(
new CreatePlayerCommand(
new Xuid(request.xuid),
new Gamertag(request.gamertag),
new Xuid(request.machineId),
new IpAddress(request.hostAddress),
new MacAddress(request.macAddress),
request.gamertag ? new Gamertag(request.gamertag) : undefined,
),
);
}
Expand All @@ -60,7 +60,7 @@ export class PlayerController {

return {
xuid: player.xuid.value,
gamertag: player.gamertag.value,
gamertag: player.gamertag ? player.gamertag.value : '',
hostAddress: player.hostAddress.value,
machineId: player.machineId.value,
port: player.port,
Expand Down

0 comments on commit e21ba47

Please sign in to comment.