diff --git a/carry.js b/carry.js
index db19c2e..94f00f4 100644
--- a/carry.js
+++ b/carry.js
@@ -47,7 +47,7 @@ async function tell(email, subject, text) {
try { if (emailOk && X.mailer && X.mailer.hasKey()) X.mailer.send(email, subject, text + '\n\nLinkSpin').catch(() => {}); } catch (e) {}
try {
const html = '
' + String(text).replace(/&/g, '&').replace(/$1').split('\n\n').join('
').replace(/\n/g, '
') + '
';
- if (X.messages) await X.messages.deliver(1, X.adminEmail || 'house@linkspin.co', [email], subject, html);
+ if (X.messages) await X.messages.deliver(1, X.adminEmail || 'house@linkspin.co', [email], subject, html, 'notice'); // quiet inbox, never the sign-in modal (Marty 2026-10-15)
} catch (e) {}
}
const label = a => a ? (a.username ? '@' + a.username : a.email.replace(/^(.).*(@.*)$/, '$1***$2')) : 'a member';
diff --git a/messages.js b/messages.js
index 67ebf04..53a29f5 100644
--- a/messages.js
+++ b/messages.js
@@ -27,32 +27,38 @@ async function lastBroadcastAt(fromEmail) {
return mine.length ? Math.max(...mine) : 0;
}
// deliver one message to many recipients (already-resolved emails). Returns count.
-async function deliver(fromMember, fromEmail, recipients, subject, body) {
+// `kind` (ported from InstantAdPay 2026-10-15): 'broadcast' = a person wrote it (may pop the sign-in modal);
+// 'alert' = system message where the member loses money by not acting (may pop); 'notice' = system message,
+// nothing required: inbox only, never a modal (carry-over notices, Marty: quiet inbox, seen once they log in).
+async function deliver(fromMember, fromEmail, recipients, subject, body, kind) {
+ const k = ['notice', 'alert'].includes(kind) ? kind : 'broadcast';
const now = Date.now();
let n = 0;
if (db.enabled()) {
for (const to of recipients) {
- await db.q("INSERT INTO sponsor_messages (from_member,from_email,to_email,subject,body,sent,kind) VALUES (?,?,?,?,?,?,'broadcast')",
- [fromMember || 0, fromEmail, to, subject, body, now]);
+ await db.q("INSERT INTO sponsor_messages (from_member,from_email,to_email,subject,body,sent,kind) VALUES (?,?,?,?,?,?,?)",
+ [fromMember || 0, fromEmail, to, subject, body, now, k]);
n++;
}
} else {
if (!J.db) J.load();
for (const to of recipients) {
- J.db.items.push({ id: J.db.nextId++, kind: 'broadcast', fromMember: fromMember || 0, fromEmail, toEmail: to, subject, body, sent: now, readTs: 0 });
+ J.db.items.push({ id: J.db.nextId++, kind: k, fromMember: fromMember || 0, fromEmail, toEmail: to, subject, body, sent: now, readTs: 0 });
n++;
}
J.save();
}
return n;
}
-const isBroadcast = i => (i.kind || 'broadcast') === 'broadcast';
+// every non-chat kind is inbox mail; only a human broadcast or a money-at-stake alert may pop the modal
+const isBroadcast = i => (i.kind || 'broadcast') !== 'chat';
+const popsModal = i => ['broadcast', 'alert'].includes(i.kind || 'broadcast');
const isChat = i => i.kind === 'chat';
async function inbox(email) {
const e = String(email || '').toLowerCase();
if (db.enabled()) {
const rows = await db.q(`SELECT id, from_member, subject, body, sent, read_ts FROM sponsor_messages
- WHERE to_email=? AND kind='broadcast' ORDER BY sent DESC LIMIT 100`, [e]);
+ WHERE to_email=? AND kind<>'chat' ORDER BY sent DESC LIMIT 100`, [e]);
return rows.map(r => ({ id: r.id, fromMember: r.from_member, subject: r.subject, body: r.body,
sent: Number(r.sent), read: !!r.read_ts }));
}
@@ -145,7 +151,7 @@ async function threadList(email) {
async function unreadCount(email) {
const e = String(email || '').toLowerCase();
if (db.enabled()) {
- const r = await db.q("SELECT COUNT(*) n FROM sponsor_messages WHERE to_email=? AND kind='broadcast' AND read_ts IS NULL", [e]);
+ const r = await db.q("SELECT COUNT(*) n FROM sponsor_messages WHERE to_email=? AND kind<>'chat' AND read_ts IS NULL", [e]);
return r[0].n;
}
if (!J.db) J.load();
@@ -156,13 +162,13 @@ async function newestUnread(email) {
const e = String(email || '').toLowerCase();
if (db.enabled()) {
const rows = await db.q(`SELECT id, from_member, subject, body, sent FROM sponsor_messages
- WHERE to_email=? AND kind='broadcast' AND read_ts IS NULL ORDER BY sent DESC LIMIT 1`, [e]);
+ WHERE to_email=? AND kind IN ('broadcast','alert') AND read_ts IS NULL ORDER BY sent DESC LIMIT 1`, [e]);
if (!rows.length) return null;
const r = rows[0];
return { id: r.id, fromMember: r.from_member, subject: r.subject, body: r.body, sent: Number(r.sent) };
}
if (!J.db) J.load();
- const u = J.db.items.filter(i => i.toEmail === e && isBroadcast(i) && !i.readTs).sort((a, b) => b.sent - a.sent)[0];
+ const u = J.db.items.filter(i => i.toEmail === e && popsModal(i) && !i.readTs).sort((a, b) => b.sent - a.sent)[0];
return u ? { id: u.id, fromMember: u.fromMember, subject: u.subject, body: u.body, sent: u.sent } : null;
}
async function markRead(email, id) {
@@ -177,5 +183,19 @@ async function markRead(email, id) {
return { ok: true };
}
+// one-time reclassify: system notices stored as 'broadcast' before the kinds existed become quiet 'notice' (idempotent)
+const CARRY_SUBJECTS = /(Your LinkSpin payouts are switched on|We set up your LinkSpin position|just joined LinkSpin under you|was placed under you on LinkSpin|You missed .* on LinkSpin|is ready to buy on LinkSpin|The seat for .* passed to)/;
+async function reclassifyCarryNotices(fromEmail) {
+ const f = String(fromEmail || '').toLowerCase();
+ if (db.enabled()) {
+ const rows = await db.q("SELECT id, subject FROM sponsor_messages WHERE kind='broadcast' AND from_member=1 AND LOWER(from_email)=?", [f]);
+ let n = 0; for (const r of rows) if (CARRY_SUBJECTS.test(r.subject)) { await db.q("UPDATE sponsor_messages SET kind='notice' WHERE id=?", [r.id]); n++; }
+ return n;
+ }
+ if (!J.db) J.load(); let n = 0;
+ for (const i of J.db.items) if ((i.kind || 'broadcast') === 'broadcast' && Number(i.fromMember) === 1 && String(i.fromEmail || '').toLowerCase() === f && CARRY_SUBJECTS.test(i.subject || '')) { i.kind = 'notice'; n++; }
+ if (n) J.save();
+ return n;
+}
module.exports = { init, lastFrom, lastBroadcastAt, deliver, inbox, unreadCount, newestUnread, markRead,
- sendChat, thread, markChatRead, chatUnread, threadList };
+ sendChat, thread, markChatRead, chatUnread, threadList, reclassifyCarryNotices };
diff --git a/server.js b/server.js
index 18e7e04..b126616 100644
--- a/server.js
+++ b/server.js
@@ -404,6 +404,7 @@ async function boot() {
ads.init({ dataDir: DATA_DIR, chain });
mailer.init({ dataDir: DATA_DIR });
messages.init({ dataDir: DATA_DIR });
+ messages.reclassifyCarryNotices(ADMIN_EMAIL || 'house@linkspin.co').then(n => { if (n) console.log('messages: ' + n + ' carry notices made quiet (notice kind)'); }).catch(() => {});
reports.init({ dataDir: DATA_DIR });
drip.init({ dataDir: DATA_DIR, mailer, accounts, chain, site: SITE_URL });
chatbot.init({ dataDir: DATA_DIR, chain });