mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-08 14:58:12 +03:00
Rename goal.title to goal.name
This commit is contained in:
@@ -141,7 +141,7 @@ export async function EvaluateMilestoneProgress(userID: integer, milestone: Mile
|
||||
|
||||
if (!result) {
|
||||
logger.error(
|
||||
`Failed to calculate ${userID} result for goal '${goal.title}'. Is the goal valid?`,
|
||||
`Failed to calculate ${userID} result for goal '${goal.name}'. Is the goal valid?`,
|
||||
{ goal, milestone }
|
||||
);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ router.get("/:goalID", ResolveGoalID, async (req, res) => {
|
||||
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
description: `Retrieved information about ${goal.title}.`,
|
||||
description: `Retrieved information about ${goal.name}.`,
|
||||
body: {
|
||||
goal,
|
||||
goalSubs,
|
||||
@@ -170,7 +170,7 @@ router.get(
|
||||
|
||||
if (!results) {
|
||||
throw new Error(
|
||||
`Failed to evaluate goal ${goal.title} (${goal.goalID}) for user ${user.id}. More information above.`
|
||||
`Failed to evaluate goal ${goal.name} (${goal.goalID}) for user ${user.id}. More information above.`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ router.get(
|
||||
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
description: `Evaluated ${goal.title} for ${user.username}.`,
|
||||
description: `Evaluated ${goal.name} for ${user.username}.`,
|
||||
body: goalResults,
|
||||
});
|
||||
}
|
||||
|
||||
+2
-2
@@ -176,7 +176,7 @@ router.post(
|
||||
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
description: `Subscribed to ${goal.title}.`,
|
||||
description: `Subscribed to ${goal.name}.`,
|
||||
body: {
|
||||
goal,
|
||||
goalSub,
|
||||
@@ -228,7 +228,7 @@ router.get("/:goalID", GetGoalSubscription, async (req, res) => {
|
||||
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
description: `Returned information about goal ${goal.title}.`,
|
||||
description: `Returned information about goal ${goal.name}.`,
|
||||
body: {
|
||||
goal,
|
||||
goalSub,
|
||||
|
||||
+9
-16
@@ -2,15 +2,14 @@ import { RequestHandler, Router } from "express";
|
||||
import db from "external/mongo/db";
|
||||
import { SYMBOL_TachiData } from "lib/constants/tachi";
|
||||
import {
|
||||
CalculateMilestoneOutOf,
|
||||
EvaluateMilestoneProgress,
|
||||
GetGoalsInMilestone,
|
||||
SubscribeToMilestone,
|
||||
} from "lib/targets/milestones";
|
||||
import { RequirePermissions } from "server/middleware/auth";
|
||||
import { MilestoneSubscriptionDocument } from "tachi-common";
|
||||
import { GetMilestoneForIDGuaranteed } from "utils/db";
|
||||
import { AssignToReqTachiData } from "utils/req-tachi-data";
|
||||
import { FormatUserDoc } from "utils/user";
|
||||
import { FormatUserDoc, GetUserWithID } from "utils/user";
|
||||
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
|
||||
@@ -104,7 +103,7 @@ router.get("/:milestoneID", GetMilestoneSubscription, async (req, res) => {
|
||||
*
|
||||
* @name PUT /api/v1/users/:userID/games/:game/:playtype/targets/milestones/:milestoneID
|
||||
*/
|
||||
router.put("/:milestoneID", RequirePermissions(""), async (req, res) => {
|
||||
router.put("/:milestoneID", RequirePermissions("manage_targets"), async (req, res) => {
|
||||
const user = req[SYMBOL_TachiData]!.requestedUser!;
|
||||
const game = req[SYMBOL_TachiData]!.game!;
|
||||
const playtype = req[SYMBOL_TachiData]!.playtype!;
|
||||
@@ -147,7 +146,7 @@ router.put("/:milestoneID", RequirePermissions(""), async (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
const { progress, achieved } = await EvaluateMilestoneProgress(user.id, milestone);
|
||||
const x = await SubscribeToMilestone(user.id, milestone);
|
||||
|
||||
if (achieved) {
|
||||
return res.status(400).json({
|
||||
@@ -156,17 +155,11 @@ router.put("/:milestoneID", RequirePermissions(""), async (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
const milestoneSub: MilestoneSubscriptionDocument = {
|
||||
achieved,
|
||||
game,
|
||||
milestoneID: milestone.milestoneID,
|
||||
playtype,
|
||||
progress,
|
||||
timeAchieved: null,
|
||||
timeSet: Date.now(),
|
||||
userID: user.id,
|
||||
wasInstantlyAchieved: false,
|
||||
};
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
description: `Subscribed to milestone '${milestone.name}'.`,
|
||||
body:
|
||||
});
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user