Dormant-lead rescue: 10-day warning, 14-day move to the holding tank, Contacted-them reset, dead sponsor links to the tank
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+8
-1
@@ -77,6 +77,13 @@ async function sendChat(fromMember, fromEmail, toEmail, body) {
|
||||
return { id, sent: now };
|
||||
}
|
||||
// messages between two members (both directions), id > afterId, oldest→newest
|
||||
// last message from one member to another, any kind (0 if never)
|
||||
async function lastFrom(fromEmail, toEmail) {
|
||||
const f = String(fromEmail || '').toLowerCase(), t = String(toEmail || '').toLowerCase();
|
||||
if (db.enabled()) { const r = await db.q('SELECT MAX(sent) s FROM sponsor_messages WHERE from_email=? AND to_email=?', [f, t]); return Number((r[0] && r[0].s) || 0); }
|
||||
if (!J.db) J.load();
|
||||
return J.db.items.filter(i => i.fromEmail === f && i.toEmail === t).reduce((m, i) => Math.max(m, i.sent || 0), 0);
|
||||
}
|
||||
async function thread(aEmail, bEmail, afterId = 0, limit = 300) {
|
||||
const a = String(aEmail || '').toLowerCase(), b = String(bEmail || '').toLowerCase();
|
||||
if (db.enabled()) {
|
||||
@@ -170,5 +177,5 @@ async function markRead(email, id) {
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
module.exports = { init, lastBroadcastAt, deliver, inbox, unreadCount, newestUnread, markRead,
|
||||
module.exports = { init, lastFrom, lastBroadcastAt, deliver, inbox, unreadCount, newestUnread, markRead,
|
||||
sendChat, thread, markChatRead, chatUnread, threadList };
|
||||
|
||||
Reference in New Issue
Block a user