chunithm: Save and load user duel list
This commit is contained in:
@@ -1,14 +1,23 @@
|
||||
import { Repositories } from "../repo";
|
||||
import { GetUserDuelRequest } from "../request/getUserDuel";
|
||||
import { GetUserDuelResponse } from "../response/getUserDuel";
|
||||
import { readAimeId } from "../proto/base";
|
||||
import { writeUserDuelList } from "../proto/userDuelList";
|
||||
|
||||
export default async function getUserDuel(
|
||||
rep: Repositories,
|
||||
req: GetUserDuelRequest
|
||||
): Promise<GetUserDuelResponse> {
|
||||
const aimeId = readAimeId(req.userId);
|
||||
// Get all duel entities if the client specifies to.
|
||||
const duelId = req.isAllDuel ? undefined : parseInt(req.duelId);
|
||||
|
||||
const profileId = await rep.userData().lookup(aimeId);
|
||||
const items = await rep.userDuelList().load(profileId, duelId);
|
||||
|
||||
return {
|
||||
userId: req.userId,
|
||||
length: "0",
|
||||
userDuelList: [],
|
||||
length: items.length.toString(),
|
||||
userDuelList: items.map(writeUserDuelList),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { readUserItem } from "../proto/userItem";
|
||||
import { readUserMusicDetail } from "../proto/userMusic";
|
||||
import { readUserActivity } from "../proto/userActivity";
|
||||
import { readUserDataEx } from "../proto/userDataEx";
|
||||
import { readUserDuelList } from "../proto/userDuelList";
|
||||
import { readUserPlaylog } from "../proto/userPlaylog";
|
||||
|
||||
// It shouldn't need to be said really, but seeing as this message (A) requires
|
||||
@@ -69,5 +70,9 @@ export default async function upsertUserAll(
|
||||
await rep.userDataEx().save(profileId, readUserDataEx(item));
|
||||
}
|
||||
|
||||
for (const item of payload.userDuelList || []) {
|
||||
await rep.userDuelList().save(profileId, readUserDuelList(item));
|
||||
}
|
||||
|
||||
return { returnCode: "1" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user