mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Feature: new "report a bug" modal (#13530)
* WIP: report a bug api/ui * fix lint * add USER_USERNAME * extend sendTxn tests / checks + fix bug report email * fix lint * add more checks to sendTxn - fix bug-report variables * fix lint / ci * fix test: reset email config url * fix test stub * fix tests * refactor the variables checks * lint. * move bug-report page as a modal * send user_email to the email * show true/false instead 1/0 * fix issues * fix footer report bug email if not logged in * fix styles/margins * prefill user's email * show facebook email if local email not existing * bugReportSuccessModal.vue * add BROWSER_UA to mail properties * extract bugReportLogic to its own lib file for unit test * test api validators * fix lint
This commit is contained in:
@@ -67,12 +67,32 @@ export function getGroupUrl (group) {
|
||||
|
||||
// Send a transactional email using Mandrill through the external email server
|
||||
export async function sendTxn (mailingInfoArray, emailType, variables, personalVariables) {
|
||||
mailingInfoArray = Array.isArray(mailingInfoArray) ? mailingInfoArray : [mailingInfoArray]; // eslint-disable-line no-param-reassign, max-len
|
||||
if (!Array.isArray(mailingInfoArray)) {
|
||||
mailingInfoArray = [mailingInfoArray]; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
|
||||
for (const entry of mailingInfoArray) {
|
||||
if (typeof entry === 'string'
|
||||
&& (typeof entry._id === 'undefined' && typeof entry.email === 'undefined')
|
||||
) {
|
||||
throw new Error('Argument Error mailingInfoArray: does not contain email or _id');
|
||||
}
|
||||
}
|
||||
|
||||
if (variables && !Array.isArray(variables)) {
|
||||
throw new Error('Argument Error variables: is not an array');
|
||||
}
|
||||
|
||||
variables = [ // eslint-disable-line no-param-reassign
|
||||
{ name: 'BASE_URL', content: BASE_URL },
|
||||
].concat(variables || []);
|
||||
|
||||
for (const variable of variables) {
|
||||
if (typeof variable.name === 'undefined' && typeof variable.content === 'undefined') {
|
||||
throw new Error('Argument Error variables: does not contain name or content');
|
||||
}
|
||||
}
|
||||
|
||||
// It's important to pass at least a user with its `preferences`
|
||||
// as we need to check if he unsubscribed
|
||||
mailingInfoArray = mailingInfoArray // eslint-disable-line no-param-reassign
|
||||
@@ -157,3 +177,17 @@ export async function sendTxn (mailingInfoArray, emailType, variables, personalV
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function convertVariableObjectToArray (variableObject) {
|
||||
const variablesArray = [];
|
||||
|
||||
const objectKeys = Object.keys(variableObject);
|
||||
for (const propName of objectKeys) {
|
||||
variablesArray.push({
|
||||
name: propName,
|
||||
content: variableObject[propName],
|
||||
});
|
||||
}
|
||||
|
||||
return variablesArray;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user