manual commit 2026-04-10T19:27:53Z
This commit is contained in:
25
services/staffSignature.js
Normal file
25
services/staffSignature.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const { mongoose } = require('../db-connection');
|
||||
|
||||
/**
|
||||
* Returns { text, html } for a staff member's signature.
|
||||
* Returns { text: '', html: '' } if no signature is set.
|
||||
*/
|
||||
async function getStaffSignatureBlocks(userId) {
|
||||
const StaffSignature = mongoose.model('StaffSignature');
|
||||
const sig = await StaffSignature.findOne({ userId }).lean();
|
||||
if (!sig || (!sig.valediction && !sig.displayName && !sig.tagline)) {
|
||||
return { text: '', html: '' };
|
||||
}
|
||||
|
||||
const lines = [];
|
||||
if (sig.valediction) lines.push(sig.valediction);
|
||||
if (sig.displayName) lines.push(sig.displayName);
|
||||
if (sig.tagline) lines.push(sig.tagline);
|
||||
|
||||
const text = lines.join('\n');
|
||||
const html = lines.map(l => `<div>${l}</div>`).join('');
|
||||
|
||||
return { text, html };
|
||||
}
|
||||
|
||||
module.exports = { getStaffSignatureBlocks };
|
||||
Reference in New Issue
Block a user