mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
29 lines
1.5 KiB
JavaScript
29 lines
1.5 KiB
JavaScript
/***********************************************************************************************************************************************************************
|
|
* File Name: email_template_enrichers.data.js
|
|
* Type of Program: Data / Registry
|
|
* Description: Admin-edited templates are plain HTML — no conditionals or
|
|
* expressions allowed. Any type that used to branch on data in
|
|
* JS (e.g. BANNED's permanent/temporary wording) gets that branch
|
|
* precomputed here into flat placeholder keys BEFORE substitution,
|
|
* so the stored HTML only ever needs straight {{key}} swaps.
|
|
* Adding a new derived placeholder for a type should only require
|
|
* adding/editing one entry here.
|
|
* Author: Kenneth Obsequio (@lash0000)
|
|
* Date Created: Jul. 3, 2026
|
|
***********************************************************************************************************************************************************************/
|
|
|
|
const ENRICHERS = {
|
|
OTP: (data) => ({ expiryMinutes: 10, ...data }),
|
|
|
|
BANNED: (data) => ({
|
|
...data,
|
|
duration_word: data.ban_type === 'permanent' ? 'permanently' : 'temporarily',
|
|
duration_label: data.ban_type === 'permanent' ? 'Permanent' : 'Temporary',
|
|
suspension_note: data.ban_type === 'permanent' ? '' : ' This suspension may be lifted upon review by the administrator.',
|
|
}),
|
|
};
|
|
|
|
const enrichEmailData = (type, data = {}) => (ENRICHERS[type] ? ENRICHERS[type](data) : data);
|
|
|
|
module.exports = { enrichEmailData };
|