mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-02 03:48:14 +03:00
+1
-1
@@ -82,7 +82,7 @@
|
||||
"rimraf": "3.0.2",
|
||||
"safe-json-stringify": "1.2.0",
|
||||
"seq-logging": "1.1.1",
|
||||
"tachi-common": "0.6.11",
|
||||
"tachi-common": "0.7.0",
|
||||
"ts-node": "10.4.0",
|
||||
"tsconfig-paths": "3.12.0",
|
||||
"typescript": "4.5.5",
|
||||
|
||||
Generated
+3596
-1716
File diff suppressed because it is too large
Load Diff
@@ -48,6 +48,7 @@ export async function UpdateGoalsForUser(
|
||||
|
||||
const importInfo = [];
|
||||
const bulkWrite = [];
|
||||
const webhookEventContent = [];
|
||||
|
||||
for (const ret of returns) {
|
||||
if (!ret) {
|
||||
@@ -56,6 +57,10 @@ export async function UpdateGoalsForUser(
|
||||
|
||||
importInfo.push(ret.import);
|
||||
bulkWrite.push(ret.bwrite);
|
||||
|
||||
if (ret.webhookEvent) {
|
||||
webhookEventContent.push(ret.webhookEvent);
|
||||
}
|
||||
}
|
||||
|
||||
if (bulkWrite.length === 0) {
|
||||
@@ -64,6 +69,13 @@ export async function UpdateGoalsForUser(
|
||||
return [];
|
||||
}
|
||||
|
||||
if (webhookEventContent.length !== 0) {
|
||||
await EmitWebhookEvent({
|
||||
type: "goals-achieved/v1",
|
||||
content: { goals: webhookEventContent, userID },
|
||||
});
|
||||
}
|
||||
|
||||
await db["user-goals"].bulkWrite(bulkWrite, { ordered: false });
|
||||
|
||||
return importInfo;
|
||||
@@ -109,19 +121,16 @@ export async function ProcessGoal(
|
||||
achieved: userGoal.achieved,
|
||||
};
|
||||
|
||||
let webhookEvent = null;
|
||||
// if this is a newly-achieved goal
|
||||
if (res.achieved && !userGoal.achieved) {
|
||||
EmitWebhookEvent({
|
||||
type: "goal-achieved/v1",
|
||||
content: {
|
||||
userID,
|
||||
goalID: goal.goalID,
|
||||
old: oldData,
|
||||
new: newData,
|
||||
game: goal.game,
|
||||
playtype: goal.playtype,
|
||||
},
|
||||
});
|
||||
webhookEvent = {
|
||||
goalID: goal.goalID,
|
||||
old: oldData,
|
||||
new: newData,
|
||||
game: goal.game,
|
||||
playtype: goal.playtype,
|
||||
};
|
||||
}
|
||||
|
||||
const bulkWrite = {
|
||||
@@ -147,6 +156,7 @@ export async function ProcessGoal(
|
||||
old: oldData,
|
||||
new: newData,
|
||||
},
|
||||
webhookEvent,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -164,7 +174,7 @@ export async function GetRelevantGoals(
|
||||
chartIDs: Set<string>,
|
||||
logger: KtLogger
|
||||
): Promise<{ goals: GoalDocument[]; userGoalsMap: Map<string, UserGoalDocument> }> {
|
||||
const userGoals = await db["user-goals"].find({ game, userID });
|
||||
const userGoals = await db["user-goals"].find({ game, userID }, { projectID: true });
|
||||
|
||||
logger.verbose(`Found user has ${userGoals.length} goals.`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user