mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
moving developer-only strings to api/common messages (#10258)
* move translatable string to apiMessages * use apiMessages instead of res.t for groupIdRequired / keepOrRemove * move pageMustBeNumber to apiMessages * change apimessages * move missingKeyParam to apiMessages * move more strings to apiMessages * fix lint * revert lodash imports to fix tests * fix webhook test * fix test * rollback key change of `keepOrRemove` * remove unneeded `req.language` param * extract more messages from i18n * add missing `missingTypeParam` message * Split api- and commonMessages * fix test * fix sanity * merge messages to an object, rename commonMessage to errorMessage * apiMessages -> apiError, commonMessages -> errorMessage, extract messages to separate objects * fix test * module.exports
This commit is contained in:
@@ -8,8 +8,7 @@ import {
|
||||
import {
|
||||
BadRequest,
|
||||
} from '../../../libs/errors';
|
||||
|
||||
const i18n = shared.i18n;
|
||||
import apiError from '../../../libs/apiError';
|
||||
|
||||
let api = {};
|
||||
|
||||
@@ -54,8 +53,8 @@ api.checkoutSuccess = {
|
||||
let gift = req.session.gift ? JSON.parse(req.session.gift) : undefined;
|
||||
delete req.session.gift;
|
||||
|
||||
if (!paymentId) throw new BadRequest(i18n.t('missingPaymentId'));
|
||||
if (!customerId) throw new BadRequest(i18n.t('missingCustomerId'));
|
||||
if (!paymentId) throw new BadRequest(apiError('missingPaymentId'));
|
||||
if (!customerId) throw new BadRequest(apiError('missingCustomerId'));
|
||||
|
||||
await paypalPayments.checkoutSuccess({user, gift, paymentId, customerId});
|
||||
|
||||
@@ -78,7 +77,7 @@ api.subscribe = {
|
||||
url: '/paypal/subscribe',
|
||||
middlewares: [authWithUrl],
|
||||
async handler (req, res) {
|
||||
if (!req.query.sub) throw new BadRequest(i18n.t('missingSubKey'));
|
||||
if (!req.query.sub) throw new BadRequest(apiError('missingSubKey'));
|
||||
|
||||
let sub = shared.content.subscriptionBlocks[req.query.sub];
|
||||
let coupon = req.query.coupon;
|
||||
@@ -109,7 +108,7 @@ api.subscribeSuccess = {
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
|
||||
if (!req.session.paypalBlock) throw new BadRequest(i18n.t('missingPaypalBlock'));
|
||||
if (!req.session.paypalBlock) throw new BadRequest(apiError('missingPaypalBlock'));
|
||||
|
||||
let block = shared.content.subscriptionBlocks[req.session.paypalBlock];
|
||||
let groupId = req.session.groupId;
|
||||
|
||||
Reference in New Issue
Block a user