Misc Webhooks Fixes (#12038)
* fix(webhooks): don t parse response as json * upgrade got to version 10 * remove old header * fix tests * fix email auth * add migration * update email error * split migration in two
This commit is contained in:
@@ -133,9 +133,9 @@ export async function sendTxn (mailingInfoArray, emailType, variables, personalV
|
||||
return got.post(`${EMAIL_SERVER.url}/job`, {
|
||||
retry: 5, // retry the http request to the email server 5 times
|
||||
timeout: 60000, // wait up to 60s before timing out
|
||||
auth: `${EMAIL_SERVER.auth.user}:${EMAIL_SERVER.auth.password}`,
|
||||
json: true,
|
||||
body: {
|
||||
username: EMAIL_SERVER.auth.user,
|
||||
password: EMAIL_SERVER.auth.password,
|
||||
json: {
|
||||
type: 'email',
|
||||
data: {
|
||||
emailType,
|
||||
@@ -149,7 +149,7 @@ export async function sendTxn (mailingInfoArray, emailType, variables, personalV
|
||||
backoff: { delay: 10 * 60 * 1000, type: 'fixed' },
|
||||
},
|
||||
},
|
||||
}).catch(err => logger.error(err));
|
||||
}).json().catch(err => logger.error(err, 'Error while sending an email.'));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -13,10 +13,10 @@ function sendWebhook (webhook, body, user) {
|
||||
const { url, lastFailureAt } = webhook;
|
||||
|
||||
got.post(url, {
|
||||
body,
|
||||
json: true,
|
||||
json: body,
|
||||
timeout: 30000, // wait up to 30s before timing out
|
||||
retry: 3, // retry the request up to 3 times
|
||||
// Not calling .json() to parse the response because we simply ignore it
|
||||
}).catch(webhookErr => {
|
||||
// Log the error
|
||||
logger.error(webhookErr, 'Error while sending a webhook request.');
|
||||
|
||||
@@ -58,6 +58,8 @@ export const schema = new Schema({
|
||||
required: true,
|
||||
validate: [v => validator.isURL(v, {
|
||||
require_tld: !!IS_PRODUCTION, // eslint-disable-line camelcase
|
||||
require_protocol: true, // TODO migrate existing ones
|
||||
protocols: ['http', 'https'],
|
||||
}), shared.i18n.t('invalidUrl')],
|
||||
},
|
||||
enabled: { $type: Boolean, required: true, default: true },
|
||||
|
||||
Reference in New Issue
Block a user