Add contacts features: tags, history, CSV import/export, merge, last-contacted; fix CalendarPage unused var; v1.1.23

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nmemmert
2026-07-28 17:00:21 -04:00
parent 5e43c41b2b
commit e2c560a1ab
6 changed files with 902 additions and 282 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "siteforge", "name": "siteforge",
"private": true, "private": true,
"version": "1.1.22", "version": "1.1.23",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
+5 -1
View File
@@ -1113,7 +1113,11 @@ function sanitizeLoadedContactSubmissions(value) {
snoozedUntil: typeof entry.snoozedUntil === 'string' && !isNaN(Date.parse(entry.snoozedUntil)) ? entry.snoozedUntil : null, snoozedUntil: typeof entry.snoozedUntil === 'string' && !isNaN(Date.parse(entry.snoozedUntil)) ? entry.snoozedUntil : null,
threadId: typeof entry.threadId === 'string' && entry.threadId.trim() ? entry.threadId.trim() : randomUUID(), threadId: typeof entry.threadId === 'string' && entry.threadId.trim() ? entry.threadId.trim() : randomUUID(),
emailStatus: normalizeContactEmailStatus(entry.emailStatus, entry.subscribe === true), emailStatus: normalizeContactEmailStatus(entry.emailStatus, entry.subscribe === true),
source: entry.source === 'inbound-email' || entry.source === 'download' ? entry.source : 'contact-form', source: ['inbound-email', 'download', 'manual'].includes(entry.source) ? entry.source : 'contact-form',
notes: typeof entry.notes === 'string' ? entry.notes.trim().slice(0, 2000) : '',
tags: Array.isArray(entry.tags)
? [...new Set(entry.tags.filter(t => typeof t === 'string' && t.trim()).map(t => t.trim().slice(0, 50)))].slice(0, 20)
: [],
htmlBody: typeof entry.htmlBody === 'string' && entry.htmlBody.trim() ? entry.htmlBody : null, htmlBody: typeof entry.htmlBody === 'string' && entry.htmlBody.trim() ? entry.htmlBody : null,
inboundTo: typeof entry.inboundTo === 'string' ? entry.inboundTo : '', inboundTo: typeof entry.inboundTo === 'string' ? entry.inboundTo : '',
messageId: typeof entry.messageId === 'string' ? entry.messageId : '', messageId: typeof entry.messageId === 'string' ? entry.messageId : '',
+62
View File
@@ -442,6 +442,9 @@ export function register(app) {
if (typeof req.body?.starred === 'boolean') patch.starred = req.body.starred if (typeof req.body?.starred === 'boolean') patch.starred = req.body.starred
if (typeof req.body?.name === 'string') patch.name = req.body.name.trim().slice(0, 200) if (typeof req.body?.name === 'string') patch.name = req.body.name.trim().slice(0, 200)
if (typeof req.body?.notes === 'string') patch.notes = req.body.notes.trim().slice(0, 2000) if (typeof req.body?.notes === 'string') patch.notes = req.body.notes.trim().slice(0, 2000)
if (Array.isArray(req.body?.tags)) {
patch.tags = [...new Set(req.body.tags.filter(t => typeof t === 'string' && t.trim()).map(t => t.trim().slice(0, 50)))].slice(0, 20)
}
if ('snoozedUntil' in (req.body ?? {})) { if ('snoozedUntil' in (req.body ?? {})) {
const v = req.body.snoozedUntil const v = req.body.snoozedUntil
patch.snoozedUntil = v === null ? null : (typeof v === 'string' && !isNaN(Date.parse(v)) ? v : undefined) patch.snoozedUntil = v === null ? null : (typeof v === 'string' && !isNaN(Date.parse(v)) ? v : undefined)
@@ -507,6 +510,65 @@ export function register(app) {
res.json({ ok: true, affected }) res.json({ ok: true, affected })
}) })
app.post('/api/admin-contacts/merge', requireAdminAuth, (req, res) => {
const keepEmail = typeof req.body?.keepEmail === 'string' ? req.body.keepEmail.trim().toLowerCase() : ''
const mergeEmail = typeof req.body?.mergeEmail === 'string' ? req.body.mergeEmail.trim().toLowerCase() : ''
if (!keepEmail || !mergeEmail || keepEmail === mergeEmail) {
res.status(400).json({ message: 'keepEmail and mergeEmail must be different non-empty addresses.' }); return
}
let affected = 0
state.contactSubmissions = state.contactSubmissions.map(s => {
if ((s.email ?? '').trim().toLowerCase() !== mergeEmail) return s
affected++
return { ...s, email: keepEmail }
})
queueContactSubmissionsWrite()
res.json({ ok: true, affected })
})
app.post('/api/admin-contacts/import', requireAdminAuth, (req, res) => {
const rows = req.body?.rows
if (!Array.isArray(rows) || rows.length === 0) {
res.status(400).json({ message: 'rows must be a non-empty array.' }); return
}
const EMAIL_RE = /^[a-zA-Z0-9._%+\-]{1,64}@[a-zA-Z0-9.\-]{1,253}\.[a-zA-Z]{2,}$/
let created = 0
let skipped = 0
const toAdd = []
for (const row of rows.slice(0, 1000)) {
const name = typeof row.name === 'string' ? row.name.trim().slice(0, 200) : ''
const email = typeof row.email === 'string' ? row.email.trim().toLowerCase().slice(0, 320) : ''
const notes = typeof row.notes === 'string' ? row.notes.trim().slice(0, 2000) : ''
const tags = Array.isArray(row.tags)
? row.tags.filter(t => typeof t === 'string' && t.trim()).map(t => t.trim().slice(0, 50)).slice(0, 20)
: (typeof row.tags === 'string' ? row.tags.split(';').map(t => t.trim()).filter(Boolean).slice(0, 20) : [])
if (!name && !email) { skipped++; continue }
if (email && !EMAIL_RE.test(email)) { skipped++; continue }
toAdd.push({ name, email, notes, tags })
}
for (const row of toAdd) {
const submission = {
id: randomUUID(),
submittedAt: new Date().toISOString(),
name: row.name,
email: row.email,
message: '',
messageType: 'general',
subscribe: false,
archived: false,
source: 'manual',
notes: row.notes,
tags: row.tags,
emailStatus: normalizeContactEmailStatus(null, false),
}
state.contactSubmissions.unshift(submission)
created++
}
state.contactSubmissions = state.contactSubmissions.slice(0, MAX_CONTACT_SUBMISSIONS)
if (created > 0) queueContactSubmissionsWrite()
res.json({ ok: true, created, skipped })
})
app.get('/api/admin-contact-submissions/:id/attachments/:attachmentId', requireAdminAuth, (req, res) => { app.get('/api/admin-contact-submissions/:id/attachments/:attachmentId', requireAdminAuth, (req, res) => {
const { id, attachmentId } = req.params const { id, attachmentId } = req.params
const submission = state.contactSubmissions.find(s => s.id === id) const submission = state.contactSubmissions.find(s => s.id === id)
+254
View File
@@ -10461,6 +10461,260 @@
margin-top: 0.2rem; margin-top: 0.2rem;
} }
.ct-card-meta-row {
margin-top: 0.2rem;
}
.ct-card-date {
color: #6b6560;
font-size: 0.78rem;
}
.ct-last-contacted {
color: #8a8070;
}
.ct-card-preview {
color: #9a9088;
font-size: 0.82rem;
margin-top: 0.25rem;
line-height: 1.4;
white-space: pre-wrap;
word-break: break-word;
}
/* Tags */
.ct-tags-row {
display: flex;
flex-wrap: wrap;
gap: 0.35rem;
margin-top: 0.3rem;
}
.ct-tag {
align-items: center;
border-radius: 12px;
color: rgba(255,255,255,0.85);
display: inline-flex;
font-size: 0.72rem;
font-weight: 500;
gap: 0.25rem;
padding: 0.18rem 0.55rem;
}
.ct-tag-remove {
background: none;
border: none;
color: inherit;
cursor: pointer;
font-size: 1rem;
line-height: 1;
opacity: 0.7;
padding: 0;
margin-left: 0.1rem;
}
.ct-tag-remove:hover { opacity: 1; }
.ct-tag-editor {
align-items: center;
background: #1a1a1a;
border: 1px solid #2a2a2a;
border-radius: 6px;
display: flex;
flex-wrap: wrap;
gap: 0.3rem;
min-height: 34px;
padding: 0.3rem 0.5rem;
}
.ct-tag-editor:focus-within { border-color: #c8860a; }
.ct-tag-input {
background: none;
border: none;
color: #e8e2d5;
flex: 1;
font-size: 0.82rem;
min-width: 80px;
outline: none;
padding: 0;
}
.ct-tag-input::placeholder { color: #554f45; }
.ct-tag-filter {
appearance: none;
background: #1a1a1a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E") no-repeat right 0.6rem center;
border: 1px solid #2a2a2a;
border-radius: 6px;
color: #c0b8a8;
font-size: 0.82rem;
padding: 0.42rem 2rem 0.42rem 0.75rem;
cursor: pointer;
}
.ct-tag-filter:focus { outline: none; border-color: #c8860a; }
/* Merge picker */
.ct-merge-picker {
background: #141414;
border: 1px solid #2a2a2a;
border-radius: 8px;
margin-top: 0.5rem;
padding: 0.75rem;
}
.ct-merge-label {
color: #a09880;
font-size: 0.82rem;
margin: 0 0 0.5rem;
}
.ct-merge-search {
margin-bottom: 0.5rem;
width: 100%;
}
.ct-merge-list {
display: flex;
flex-direction: column;
gap: 0.3rem;
max-height: 240px;
overflow-y: auto;
}
.ct-merge-option {
align-items: center;
background: #1a1a1a;
border: 1px solid #252525;
border-radius: 6px;
color: #d4c8a8;
cursor: pointer;
display: flex;
gap: 0.75rem;
padding: 0.5rem 0.75rem;
text-align: left;
transition: background 0.12s;
}
.ct-merge-option:hover:not(:disabled) { background: #222; border-color: #363636; }
.ct-merge-option:disabled { opacity: 0.5; cursor: not-allowed; }
.ct-merge-name { font-weight: 500; font-size: 0.86rem; }
.ct-merge-email { color: #8a8070; font-size: 0.78rem; flex: 1; }
.ct-merge-count { color: #6b6560; font-size: 0.75rem; }
/* Conversation history */
.ct-history-panel {
background: #111;
border-top: 1px solid #1e1e1e;
display: flex;
flex-direction: column;
gap: 0.5rem;
grid-column: 1 / -1;
padding: 0.75rem 1rem;
width: 100%;
}
.ct-history-empty {
color: #554f45;
font-size: 0.82rem;
font-style: italic;
}
.ct-history-item {
border-radius: 8px;
padding: 0.5rem 0.75rem;
}
.ct-history-item--in {
background: #1a1a1a;
border-left: 3px solid #3a5a4a;
}
.ct-history-item--out {
background: #191419;
border-left: 3px solid #5a3a5a;
}
.ct-history-meta {
align-items: baseline;
display: flex;
gap: 0.5rem;
margin-bottom: 0.2rem;
}
.ct-history-who {
color: #c0b8a8;
font-size: 0.78rem;
font-weight: 500;
}
.ct-history-date {
color: #6b6560;
font-size: 0.72rem;
margin-left: auto;
}
.ct-history-subject {
color: #a09880;
font-size: 0.78rem;
font-style: italic;
margin-bottom: 0.15rem;
}
.ct-history-body {
color: #9a9088;
font-size: 0.8rem;
line-height: 1.45;
margin: 0;
white-space: pre-wrap;
word-break: break-word;
}
/* Import banner */
.ct-import-banner {
align-items: flex-start;
background: #13181a;
border-bottom: 1px solid #2a3a2a;
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
padding: 0.75rem 1.25rem;
}
.ct-import-info {
color: #d4c8a8;
flex: 1;
font-size: 0.84rem;
}
.ct-import-cols {
color: #8a8070;
}
.ct-import-actions {
display: flex;
gap: 0.5rem;
}
.ct-import-msg {
color: #4ade80;
font-size: 0.82rem;
margin: 0;
width: 100%;
}
/* Flash message */
.ct-flash {
background: #1a2a1a;
border-bottom: 1px solid #2a3a2a;
color: #4ade80;
font-size: 0.84rem;
padding: 0.5rem 1.25rem;
}
/* ── Calendar Page (/calendar) ─────────────────────────────────────────────── */ /* ── Calendar Page (/calendar) ─────────────────────────────────────────────── */
.cal-app { .cal-app {
+1 -2
View File
@@ -657,8 +657,7 @@ function CalendarClient() {
// ── Render chip ── // ── Render chip ──
function renderEpChip(ep: PodcastChecklistEpisode, dk: string) { function renderEpChip(ep: PodcastChecklistEpisode, _dk: string) {
const isScheduled = ep.datePublished === dk
return ( return (
<button <button
key={ep.id} key={ep.id}
+579 -278
View File
File diff suppressed because it is too large Load Diff