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

* 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
This commit is contained in:
negue
2018-04-14 16:13:13 +02:00
committed by Matteo Pagliazzi
parent d05d2fb9d7
commit a42cb0e3ab
55 changed files with 179 additions and 136 deletions

View File

@@ -8,8 +8,7 @@ import {
import {
BadRequest,
} from '../../../libs/errors';
const i18n = shared.i18n;
import apiMessages from '../../../libs/apiMessages';
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(apiMessages('missingPaymentId'));
if (!customerId) throw new BadRequest(apiMessages('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(apiMessages('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(apiMessages('missingPaypalBlock'));
let block = shared.content.subscriptionBlocks[req.session.paypalBlock];
let groupId = req.session.groupId;