idz: Add explicit CreateProfileResponse

This commit is contained in:
Tau 2020-10-31 16:36:52 -04:00 committed by da5669c09fdb0a288ba01e259a609d7779ac7fc9
parent 2a546c0d9d
commit efcc1caa76
5 changed files with 30 additions and 4 deletions

View File

@ -0,0 +1,11 @@
import { CreateProfileResponse } from "../response/createProfile";
export function createProfile(res: CreateProfileResponse) {
const buf = Buffer.alloc(0x0020);
// Shares message type code with the "generic" response
buf.writeInt16LE(0x0001, 0x0000);
buf.writeInt32LE(res.aimeId, 0x0004);
return buf;
}

View File

@ -2,6 +2,7 @@ import logger from "debug";
import { _team } from "./_team";
import { checkTeamName } from "./checkTeamName";
import { createProfile } from "./createProfile";
import { createTeam } from "./createTeam";
import { discoverProfile } from "./discoverProfile";
import { generic } from "./generic";
@ -47,6 +48,9 @@ function encode110(res: Response): Buffer {
case "create_auto_team_res":
return _team(res);
case "create_profile_res":
return createProfile(res);
case "create_team_res":
return createTeam(res);
@ -149,6 +153,9 @@ function encode130(res: Response): Buffer {
case "create_auto_team_res":
return _team(res);
case "create_profile_res":
return createProfile(res);
case "create_team_res":
return createTeam(res);

View File

@ -4,13 +4,13 @@ import { Settings } from "../model/settings";
import { Story } from "../model/story";
import { Unlocks } from "../model/unlocks";
import { CreateProfileRequest } from "../request/createProfile";
import { GenericResponse } from "../response/generic";
import { CreateProfileResponse } from "../response/createProfile";
import { Repositories } from "../repo";
export async function createProfile(
w: Repositories,
req: CreateProfileRequest
): Promise<GenericResponse> {
): Promise<CreateProfileResponse> {
const { aimeId, version, name } = req;
const now = new Date();
@ -58,7 +58,7 @@ export async function createProfile(
await w.teamReservations().commitHack(aimeId);
return {
type: "generic_res",
status: aimeId, // "Generic response" my fucking *ass*
type: "create_profile_res",
aimeId: aimeId,
};
}

View File

@ -0,0 +1,6 @@
import { AimeId } from "../../../model";
export interface CreateProfileResponse {
type: "create_profile_res";
aimeId: AimeId;
}

View File

@ -1,5 +1,6 @@
import { CheckTeamNameResponse } from "./checkTeamName";
import { CreateAutoTeamResponse } from "./createAutoTeam";
import { CreateProfileResponse } from "./createProfile";
import { CreateTeamResponse } from "./createTeam";
import { DiscoverProfileResponse } from "./discoverProfile";
import { GenericResponse } from "./generic";
@ -33,6 +34,7 @@ import { UnlockProfileResponse } from "./unlockProfile";
export type Response =
| CheckTeamNameResponse
| CreateAutoTeamResponse
| CreateProfileResponse
| CreateTeamResponse
| DiscoverProfileResponse
| GenericResponse