Separate task ID and in-game ID

This commit is contained in:
Jonathan Barrow
2023-08-26 02:05:31 -04:00
parent 3583e3deac
commit 4ecb833d35
10 changed files with 28 additions and 26 deletions

14
package-lock.json generated
View File

@@ -11,7 +11,7 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.395.0",
"@pretendonetwork/boss-crypto": "^1.0.0",
"@pretendonetwork/grpc": "^1.0.2",
"@pretendonetwork/grpc": "^1.0.3",
"@typegoose/auto-increment": "^3.4.0",
"boss-js": "github:PretendoNetwork/boss-js",
"cacache": "^18.0.0",
@@ -1157,9 +1157,9 @@
"integrity": "sha512-ybd3sB356v5Azxj99R62+7kytgAzfUYuXRJbdOznGL6infgCJ056TjTadN4V48m7t+3f6sPOUgo9YWUFNxlLLg=="
},
"node_modules/@pretendonetwork/grpc": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@pretendonetwork/grpc/-/grpc-1.0.2.tgz",
"integrity": "sha512-g78VP+/wY4VIlQ5EXP5lPzXK1uVflrM3ZA0PW1NZi88EaJRqNPVkYmb6iW+FM0j/lxlu07UcwqLJSHsy9eU01Q==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@pretendonetwork/grpc/-/grpc-1.0.3.tgz",
"integrity": "sha512-NlfzonmHqNRUDuc1nCON6u3f6II3KtSQgs7g5u4TEG8KKIIvBWKQT3mWVsRIkBEEpPdtad/dwASVzIR7lymKWw==",
"dependencies": {
"long": "^5.2.1",
"protobufjs": "^7.2.3"
@@ -6291,9 +6291,9 @@
"integrity": "sha512-ybd3sB356v5Azxj99R62+7kytgAzfUYuXRJbdOznGL6infgCJ056TjTadN4V48m7t+3f6sPOUgo9YWUFNxlLLg=="
},
"@pretendonetwork/grpc": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@pretendonetwork/grpc/-/grpc-1.0.2.tgz",
"integrity": "sha512-g78VP+/wY4VIlQ5EXP5lPzXK1uVflrM3ZA0PW1NZi88EaJRqNPVkYmb6iW+FM0j/lxlu07UcwqLJSHsy9eU01Q==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@pretendonetwork/grpc/-/grpc-1.0.3.tgz",
"integrity": "sha512-NlfzonmHqNRUDuc1nCON6u3f6II3KtSQgs7g5u4TEG8KKIIvBWKQT3mWVsRIkBEEpPdtad/dwASVzIR7lymKWw==",
"requires": {
"long": "^5.2.1",
"protobufjs": "^7.2.3"

View File

@@ -15,7 +15,7 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.395.0",
"@pretendonetwork/boss-crypto": "^1.0.0",
"@pretendonetwork/grpc": "^1.0.2",
"@pretendonetwork/grpc": "^1.0.3",
"@typegoose/auto-increment": "^3.4.0",
"boss-js": "github:PretendoNetwork/boss-js",
"cacache": "^18.0.0",

View File

@@ -44,7 +44,7 @@ export function getTask(bossAppID: string, taskID: string): Promise<HydratedTask
return Task.findOne<HydratedTaskDocument>({
deleted: false,
id: taskID,
id: taskID.slice(0, 7),
boss_app_id: bossAppID
});
}
@@ -53,7 +53,7 @@ export function getTaskFiles(allowDeleted: boolean, bossAppID: string, taskID: s
verifyConnected();
const filter: mongoose.FilterQuery<IFile> = {
task_id: taskID,
task_id: taskID.slice(0, 7),
boss_app_id: bossAppID
};
@@ -82,7 +82,7 @@ export function getTaskFile(bossAppID: string, taskID: string, name: string): Pr
return File.findOne<HydratedFileDocument>({
deleted: false,
boss_app_id: bossAppID,
task_id: taskID,
task_id: taskID.slice(0, 7),
name: name
});
}

View File

@@ -7,6 +7,7 @@ const TaskSchema = new mongoose.Schema<ITask, TaskModel, ITaskMethods>({
default: false
},
id: String,
in_game_id: String,
boss_app_id: String,
creator_pid: Number,
status: {

View File

@@ -22,10 +22,6 @@ export async function listFiles(request: ListFilesRequest): Promise<ListFilesRes
throw new ServerError(Status.INVALID_ARGUMENT, 'Missing task ID');
}
if (taskID.length > 8) {
throw new ServerError(Status.INVALID_ARGUMENT, 'Task ID must be 1-8 characters');
}
if (!bossAppID) {
throw new ServerError(Status.INVALID_ARGUMENT, 'Missing BOSS app ID');
}

View File

@@ -8,6 +8,7 @@ export async function listTasks(): Promise<ListTasksResponse> {
tasks: tasks.map(task => ({
deleted: task.deleted,
id: task.id,
inGameId: task.in_game_id,
bossAppId: task.boss_app_id,
creatorPid: task.creator_pid,
status: task.status,

View File

@@ -24,10 +24,6 @@ export async function registerTask(request: RegisterTaskRequest, context: CallCo
throw new ServerError(Status.INVALID_ARGUMENT, 'Missing task ID');
}
if (taskID.length > 8) {
throw new ServerError(Status.INVALID_ARGUMENT, 'Task ID must be 1-8 characters');
}
if (!bossAppID) {
throw new ServerError(Status.INVALID_ARGUMENT, 'Missing BOSS app ID');
}
@@ -44,8 +40,19 @@ export async function registerTask(request: RegisterTaskRequest, context: CallCo
throw new ServerError(Status.ALREADY_EXISTS, `Task ${taskID} already exists for BOSS app ${bossAppID}`);
}
// * BOSS tasks have 2 IDs
// * - 1: The ID which is registered in-game
// * - 2: The ID which is registered on the server
// * The in-game task ID can be any length, but the
// * ID registered on the server is capped at 7 characters.
// * When querying tasks in the API, the server ignores
// * all characters after the 7th. For example, Splatoon
// * registers task optdata2 in-game, but the server
// * tracks it as task optdata
const task = await Task.create({
id: taskID,
id: taskID.slice(0, 7),
in_game_id: taskID,
boss_app_id: bossAppID,
creator_pid: user.pid,
status: 'open', // TODO - Make this configurable
@@ -59,6 +66,7 @@ export async function registerTask(request: RegisterTaskRequest, context: CallCo
task: {
deleted: task.deleted,
id: task.id,
inGameId: task.in_game_id,
bossAppId: task.boss_app_id,
creatorPid: task.creator_pid,
status: task.status,

View File

@@ -41,8 +41,7 @@ export async function updateFileMetadata(request: UpdateFileMetadataRequest, con
}
}
// TODO - Find a better way to remove "as mongoose.Types.Array<string>"
file.task_id = updateData.taskId;
file.task_id = updateData.taskId.slice(0, 7);
file.boss_app_id = updateData.bossAppId;
file.supported_countries = updateData.supportedCountries;
file.supported_languages = updateData.supportedLanguages;

View File

@@ -33,10 +33,6 @@ export async function uploadFile(request: UploadFileRequest, context: CallContex
throw new ServerError(Status.INVALID_ARGUMENT, 'Missing task ID');
}
if (taskID.length > 8) {
throw new ServerError(Status.INVALID_ARGUMENT, 'Task ID must be 1-8 characters');
}
if (!bossAppID) {
throw new ServerError(Status.INVALID_ARGUMENT, 'Missing BOSS app ID');
}

View File

@@ -3,6 +3,7 @@ import { Model, HydratedDocument } from 'mongoose';
export interface ITask {
deleted: boolean;
id: string;
in_game_id: string;
boss_app_id: string;
creator_pid: number;
status: 'open'; // TODO - Make this a union. What else is there?