@xuda.io/account_module 1.2.2295 → 1.2.2297
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +38 -2
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2289,6 +2289,11 @@ export const ops_seed_do_datacenters = async function (req = {}) {
|
|
|
2289
2289
|
docType: 'do_datacenter',
|
|
2290
2290
|
provider: 'digitalocean',
|
|
2291
2291
|
is_do_datacenter: true,
|
|
2292
|
+
// Inventory doc, NOT a live controller: keep the server-health check from
|
|
2293
|
+
// probing https://do_<slug>.xuda.ai/cpi/... (there is no such endpoint - DNS
|
|
2294
|
+
// fails). The health loop skips any doc with application_server === false
|
|
2295
|
+
// (controller_module codex_check_xuda_servers_health), same as farm nodes.
|
|
2296
|
+
application_server: false,
|
|
2292
2297
|
region_slug: dc.slug, // DO createDroplet region
|
|
2293
2298
|
location: dc.slug, // strips (\d+$) to the metro for macro scoping, like a farm node's hel1
|
|
2294
2299
|
metro: dc.metro,
|
|
@@ -7545,6 +7550,30 @@ const _nl_one = async (db, docType) => {
|
|
|
7545
7550
|
}
|
|
7546
7551
|
};
|
|
7547
7552
|
|
|
7553
|
+
// The newsletter/content list + random-pick queries above all select on a single
|
|
7554
|
+
// `docType` field. Without an index Couch full-scans each content DB and logs
|
|
7555
|
+
// "No matching index found". These DBs live locally on dev + master (regions read
|
|
7556
|
+
// newsletter from master via DSN), so ensure a [docType] index on each at module
|
|
7557
|
+
// load, idempotent, only on the content-home nodes.
|
|
7558
|
+
(async () => {
|
|
7559
|
+
const host = process.env.XUDA_HOSTNAME;
|
|
7560
|
+
if (host !== 'dev.xuda.ai' && host !== 'master.xuda.ai') return;
|
|
7561
|
+
const content_dbs = ['xuda_newsletter', 'xuda_dev_articles', 'xuda_news_articles', 'xuda_did_you_know'];
|
|
7562
|
+
for (const db of content_dbs) {
|
|
7563
|
+
try {
|
|
7564
|
+
const ret = await db_module.create_couch_index(db, {
|
|
7565
|
+
index: { fields: ['docType'] },
|
|
7566
|
+
name: 'idx_content_docType',
|
|
7567
|
+
ddoc: 'idx_content_docType',
|
|
7568
|
+
type: 'json',
|
|
7569
|
+
});
|
|
7570
|
+
if (ret?.error) console.error(`[newsletter] ${db} docType index create failed:`, ret.error);
|
|
7571
|
+
} catch (err) {
|
|
7572
|
+
console.error(`[newsletter] ${db} docType index init failed:`, err?.message || err);
|
|
7573
|
+
}
|
|
7574
|
+
}
|
|
7575
|
+
})();
|
|
7576
|
+
|
|
7548
7577
|
const _nl_fashion_url = (p) => {
|
|
7549
7578
|
const rel = p.custom_url || (p.slug ? '/' + p.slug : '');
|
|
7550
7579
|
return `https://xuda.fashion${rel}`;
|
|
@@ -7905,7 +7934,12 @@ export const newsletter_generate = async function (req = {}) {
|
|
|
7905
7934
|
if (!req.system && !_ops_is_super(req)) return { code: -403, data: 'superuser only' };
|
|
7906
7935
|
// Master-only (dev exempt for testing): the issue DB must never be created
|
|
7907
7936
|
// on a regional couch, and the weekly coupon/sample flow belongs to master.
|
|
7908
|
-
|
|
7937
|
+
// MASTER ONLY, dev included. Dev is is_debug but still sends real [SAMPLE]/
|
|
7938
|
+
// [OPS] mail and keeps its own issue counter, so a "Generate now" on dev
|
|
7939
|
+
// blasts live info@ inboxes and creates dev-only drafts that never appear in
|
|
7940
|
+
// the master Newsletter Manager (dev does not replicate to master). Preview /
|
|
7941
|
+
// Test still work on dev for reviewing render; only issuing is locked here.
|
|
7942
|
+
if (process.env.XUDA_HOSTNAME !== 'master.xuda.ai') return { code: -1, data: 'newsletter_generate runs on master only' };
|
|
7909
7943
|
await _nl_ensure_storage();
|
|
7910
7944
|
|
|
7911
7945
|
// Two DISTINCT tips: one for "Did you know?", one for "Tip of the week".
|
|
@@ -8066,7 +8100,9 @@ export const newsletter_publish = async function (req = {}) {
|
|
|
8066
8100
|
if (!_ops_is_super(req)) return { code: -403, data: 'superuser only' };
|
|
8067
8101
|
// Same master-only gate as generate: the blast must run where xuda_newsletter
|
|
8068
8102
|
// and the authoritative xuda_accounts live (dev exempt for testing).
|
|
8069
|
-
|
|
8103
|
+
// MASTER ONLY, dev included: a publish on dev would blast dev's opted-in
|
|
8104
|
+
// accounts with real mail. Locked so only the real master issues a newsletter.
|
|
8105
|
+
if (process.env.XUDA_HOSTNAME !== 'master.xuda.ai') return { code: -1, data: 'newsletter_publish runs on master only' };
|
|
8070
8106
|
const id = req.id || `nl_issue_${req.issue_number}`;
|
|
8071
8107
|
const gret = await db_module.get_couch_doc(NEWSLETTER_DB, id);
|
|
8072
8108
|
if (gret.code < 0 || !gret.data) return { code: -1, data: 'issue not found' };
|