mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
* 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
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
import nconf from 'nconf';
|
|
import { convertVariableObjectToArray, sendTxn } from './email';
|
|
|
|
export async function bugReportLogic (
|
|
user, userEmail, message, BROWSER_UA,
|
|
) {
|
|
const emailData = {
|
|
USER_ID: user._id,
|
|
USER_EMAIL: userEmail,
|
|
USER_USERNAME: user.auth.local.username,
|
|
USER_LEVEL: user.stats.lvl,
|
|
USER_CLASS: user.stats.class,
|
|
USER_DAILIES_PAUSED: user.preferences.sleep === 1 ? 'true' : 'false',
|
|
USER_COSTUME: user.preferences.costume === 1 ? 'true' : 'false',
|
|
USER_CUSTOM_DAY: user.preferences.dayStart,
|
|
USER_TIMEZONE_OFFSET: user.preferences.timezoneOffset,
|
|
USER_SUBSCRIPTION: user.purchased.plan.planId,
|
|
USER_PAYMENT_PLATFORM: user.purchased.plan.paymentMethod,
|
|
USER_CUSTOMER_ID: user.purchased.plan.customerId,
|
|
USER_CONSECUTIVE_MONTHS: user.purchased.plan.consecutive.count,
|
|
USER_OFFSET_MONTHS: user.purchased.plan.consecutive.offset,
|
|
USER_HOURGLASSES: user.purchased.plan.consecutive.trinkets,
|
|
REPORT_MSG: message,
|
|
BROWSER_UA,
|
|
};
|
|
|
|
const adminMail = { email: nconf.get('ADMIN_EMAIL') };
|
|
|
|
const sendMailResult = await sendTxn(
|
|
adminMail,
|
|
'report-a-bug',
|
|
convertVariableObjectToArray(emailData),
|
|
);
|
|
|
|
return {
|
|
sendMailResult,
|
|
emailData,
|
|
};
|
|
}
|