Revert "moving developer-only strings to api messages (#10188)"

This reverts commit a42cb0e3ab. Testing hypothesis that this was causing Staging to break.
This commit is contained in:
SabreCat
2018-04-15 17:09:15 +00:00
parent ac98aa9271
commit 9f06d78db6
55 changed files with 136 additions and 179 deletions

View File

@@ -1,3 +1,4 @@
import i18n from '../../i18n';
import get from 'lodash/get';
import {
BadRequest,
@@ -10,7 +11,6 @@ import {BuyQuestWithGoldOperation} from './buyQuest';
import buySpecialSpell from './buySpecialSpell';
import purchaseOp from './purchase';
import hourglassPurchase from './hourglassPurchase';
import apiMessages from '../../../../server/libs/apiMessages';
// @TODO: remove the req option style. Dependency on express structure is an anti-pattern
// We should either have more parms or a set structure validated by a Type checker
@@ -19,7 +19,7 @@ import apiMessages from '../../../../server/libs/apiMessages';
module.exports = function buy (user, req = {}, analytics) {
let key = get(req, 'params.key');
if (!key) throw new BadRequest(apiMessages('missingKeyParam'));
if (!key) throw new BadRequest(i18n.t('missingKeyParam', req.language));
// @TODO: Slowly remove the need for key and use type instead
// This should evenutally be the 'factory' function with vendor classes

View File

@@ -13,7 +13,6 @@ import ultimateGear from '../../fns/ultimateGear';
import {removePinnedGearAddPossibleNewOnes} from '../pinnedGearUtils';
import { AbstractGoldItemOperation } from './abstractBuyOperation';
import apiMessages from '../../../../server/libs/apiMessages';
export class BuyMarketGearOperation extends AbstractGoldItemOperation {
constructor (user, req, analytics) {
@@ -26,10 +25,9 @@ export class BuyMarketGearOperation extends AbstractGoldItemOperation {
extractAndValidateParams (user, req) {
let key = this.key = get(req, 'params.key');
if (!key) throw new BadRequest(apiMessages('missingKeyParam'));
if (!key) throw new BadRequest(this.i18n('missingKeyParam'));
let item = content.gear.flat[key];
if (!item) throw new NotFound(apiMessages('itemNotFound', {key}));
if (!item) throw new NotFound(this.i18n('itemNotFound', {key}));
this.canUserPurchase(user, item);

View File

@@ -7,11 +7,10 @@ import {
NotAuthorized,
NotFound,
} from '../../libs/errors';
import apiMessages from '../../../../server/libs/apiMessages';
module.exports = function buyMysterySet (user, req = {}, analytics) {
let key = get(req, 'params.key');
if (!key) throw new BadRequest(apiMessages('missingKeyParam'));
if (!key) throw new BadRequest(i18n.t('missingKeyParam', req.language));
if (!(user.purchased.plan.consecutive.trinkets > 0)) {
throw new NotAuthorized(i18n.t('notEnoughHourglasses', req.language));

View File

@@ -5,7 +5,6 @@ import {
} from '../../libs/errors';
import content from '../../content/index';
import get from 'lodash/get';
import apiMessages from '../../../../server/libs/apiMessages';
import {AbstractGoldItemOperation} from './abstractBuyOperation';
@@ -31,7 +30,7 @@ export class BuyQuestWithGoldOperation extends AbstractGoldItemOperation {
extractAndValidateParams (user, req) {
let key = this.key = get(req, 'params.key');
if (!key) throw new BadRequest(apiMessages('missingKeyParam'));
if (!key) throw new BadRequest(this.i18n('missingKeyParam'));
if (key === 'lostMasterclasser1' && !this.userAbleToStartMasterClasser(user)) {
throw new NotAuthorized(this.i18n('questUnlockLostMasterclasser'));
@@ -39,7 +38,7 @@ export class BuyQuestWithGoldOperation extends AbstractGoldItemOperation {
let item = content.quests[key];
if (!item) throw new NotFound(apiMessages('questNotFound', {key}));
if (!item) throw new NotFound(this.i18n('questNotFound', {key}));
if (!(item.category === 'gold' && item.goldValue)) {
throw new NotAuthorized(this.i18n('questNotGoldPurchasable', {key}));

View File

@@ -8,16 +8,15 @@ import {
NotAuthorized,
NotFound,
} from '../../libs/errors';
import apiMessages from '../../../../server/libs/apiMessages';
module.exports = function buySpecialSpell (user, req = {}, analytics) {
let key = get(req, 'params.key');
let quantity = req.quantity || 1;
if (!key) throw new BadRequest(apiMessages('missingKeyParam'));
if (!key) throw new BadRequest(i18n.t('missingKeyParam', req.language));
let item = content.special[key];
if (!item) throw new NotFound(apiMessages('spellNotFound', {spellId: key}));
if (!item) throw new NotFound(i18n.t('spellNotFound', {spellId: key}, req.language));
if (user.stats.gp < item.value * quantity) {
throw new NotAuthorized(i18n.t('messageNotEnoughGold', req.language));

View File

@@ -7,14 +7,13 @@ import {
BadRequest,
NotAuthorized,
} from '../../libs/errors';
import apiMessages from '../../../../server/libs/apiMessages';
module.exports = function purchaseHourglass (user, req = {}, analytics) {
let key = get(req, 'params.key');
if (!key) throw new BadRequest(apiMessages('missingKeyParam'));
if (!key) throw new BadRequest(i18n.t('missingKeyParam', req.language));
let type = get(req, 'params.type');
if (!type) throw new BadRequest(apiMessages('missingTypeParam'));
if (!type) throw new BadRequest(i18n.t('missingTypeParam', req.language));
if (!content.timeTravelStable[type]) {
throw new NotAuthorized(i18n.t('typeNotAllowedHourglass', {allowedTypes: keys(content.timeTravelStable).toString()}, req.language));

View File

@@ -6,7 +6,6 @@ import {
BadRequest,
} from '../libs/errors';
import get from 'lodash/get';
import apiMessages from '../../../server/libs/apiMessages';
module.exports = function equip (user, req = {}) {
// Being type a parameter followed by another parameter
@@ -14,9 +13,9 @@ module.exports = function equip (user, req = {}) {
let type = get(req, 'params.type', 'equipped');
let key = get(req, 'params.key');
if (!key || !type) throw new BadRequest(apiMessages('missingTypeKeyEquip'));
if (!key || !type) throw new BadRequest(i18n.t('missingTypeKeyEquip', req.language));
if (['mount', 'pet', 'costume', 'equipped'].indexOf(type) === -1) {
throw new BadRequest(apiMessages('invalidTypeEquip'));
throw new BadRequest(i18n.t('invalidTypeEquip', req.language));
}
let message;

View File

@@ -6,7 +6,6 @@ import {
NotAuthorized,
NotFound,
} from '../libs/errors';
import apiMessages from '../../../server/libs/apiMessages';
function evolve (user, pet, req) {
user.items.pets[pet.key] = -1;
@@ -25,7 +24,7 @@ module.exports = function feed (user, req = {}) {
let pet = get(req, 'params.pet');
let foodK = get(req, 'params.food');
if (!pet || !foodK) throw new BadRequest(apiMessages('missingPetFoodFeed'));
if (!pet || !foodK) throw new BadRequest(i18n.t('missingPetFoodFeed', req.language));
pet = content.petInfo[pet];

View File

@@ -6,14 +6,13 @@ import {
NotAuthorized,
NotFound,
} from '../libs/errors';
import apiMessages from '../../../server/libs/apiMessages';
module.exports = function hatch (user, req = {}) {
let egg = get(req, 'params.egg');
let hatchingPotion = get(req, 'params.hatchingPotion');
if (!(egg && hatchingPotion)) {
throw new BadRequest(apiMessages('missingEggHatchingPotion'));
throw new BadRequest(i18n.t('missingEggHatchingPotionHatch', req.language));
}
if (!(user.items.eggs[egg] > 0 && user.items.hatchingPotions[hatchingPotion] > 0)) {

View File

@@ -7,13 +7,12 @@ import {
NotAuthorized,
} from '../../libs/errors';
import i18n from '../../i18n';
import apiMessages from '../../../../server/libs/apiMessages';
module.exports = function allocate (user, req = {}) {
let stat = get(req, 'query.stat', 'str');
if (ATTRIBUTES.indexOf(stat) === -1) {
throw new BadRequest(apiMessages('invalidAttribute', {attr: stat}));
throw new BadRequest(i18n.t('invalidAttribute', {attr: stat}, req.language));
}
if (user.stats.points > 0) {

View File

@@ -7,18 +7,17 @@ import {
NotAuthorized,
} from '../../libs/errors';
import i18n from '../../i18n';
import apiMessages from '../../../../server/libs/apiMessages';
module.exports = function allocateBulk (user, req = {}) {
const stats = get(req, 'body.stats');
if (!stats) throw new BadRequest(apiMessages('statsObjectRequired'));
if (!stats) throw new BadRequest(i18n.t('statsObjectRequired', req.language));
const statKeys = Object.keys(stats);
const invalidStats = statKeys.filter(statKey => {
return ATTRIBUTES.indexOf(statKey) === -1;
});
if (invalidStats.length > 0) {
throw new BadRequest(apiMessages('invalidAttribute', {attr: invalidStats.join(',')}));
throw new BadRequest(i18n.t('invalidAttribute', {attr: invalidStats.join(',')}, req.language));
}
if (user.stats.points <= 0) {