Owner account (ADMIN_EMAIL) has no link or source cap (Marty 2026-11-17: 'since I am the owner, I don't want a limit on my account'); members keep 100 links / 30 sources
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+4
-2
@@ -124,9 +124,11 @@ function bestHours(r) {
|
||||
}
|
||||
async function list(owner) { return J.db.rotations.filter(r => r.owner === norm(owner)).map(pub); }
|
||||
async function get(owner, id) { const r = J.db.rotations.find(r => r.id === Number(id) && r.owner === norm(owner)); return r ? pub(r) : null; }
|
||||
// the owner's account (ADMIN_EMAIL) has no link cap (Marty 2026-11-17: "since I am the owner, I don't want a limit on my account")
|
||||
const isOwner = owner => { const a = String(process.env.ADMIN_EMAIL || '').trim().toLowerCase(); return !!a && norm(owner) === a; };
|
||||
async function create(owner, body) {
|
||||
const name = String(body.name || '').trim().slice(0, 80); if (!name) return { error: 'Give the rotation a name.' };
|
||||
if (J.db.rotations.filter(r => r.owner === norm(owner)).length >= 100) return { error: 'That is a lot of rotations. Archive some first.' };
|
||||
if (!isOwner(owner) && J.db.rotations.filter(r => r.owner === norm(owner)).length >= 100) return { error: 'That is a lot of rotations. Archive some first.' };
|
||||
let code = newCode(); while (J.db.rotations.some(r => r.code === code)) code = newCode();
|
||||
const r = { id: (J.db.rotations.reduce((m, x) => Math.max(m, x.id), 0) + 1), owner: norm(owner), name, code, fallback: cleanUrl(body.fallback) || '', destinations: [], created: Date.now(), paused: false, nextDest: 1 };
|
||||
J.db.rotations.push(r); J.save(); return { ok: true, rotation: pub(r) };
|
||||
@@ -160,7 +162,7 @@ function ensurePartner(owner, key, name, url, sourceId) {
|
||||
const u = cleanUrl(url); if (!u || !/^https:\/\//i.test(u)) return { error: 'Destination must be a full https:// address.' };
|
||||
let r = J.db.rotations.find(x => x.owner === norm(owner) && x.partner === k); let created = false;
|
||||
if (!r) {
|
||||
if (J.db.rotations.filter(x => x.owner === norm(owner)).length >= 100) return { error: 'This LinkSpin account already has 100 links.' };
|
||||
if (!isOwner(owner) && J.db.rotations.filter(x => x.owner === norm(owner)).length >= 100) return { error: 'This LinkSpin account already has 100 links.' };
|
||||
let code = newCode(); while (J.db.rotations.some(x => x.code === code)) code = newCode();
|
||||
r = { id: (J.db.rotations.reduce((m, x) => Math.max(m, x.id), 0) + 1), owner: norm(owner), name: String(name || k).slice(0, 80), code, fallback: '', destinations: [{ id: 1, url: u, label: '', weight: 1, active: true, added: Date.now() }], created: Date.now(), paused: false, nextDest: 2, partner: k };
|
||||
J.db.rotations.push(r); created = true;
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ async function list(owner) {
|
||||
inUse: Array.from(new Set(items.map(s => s.template).filter(k => k && k !== 'custom'))), keys: KEYS, events: postbacks.EVENTS, limits: LIMITS };
|
||||
}
|
||||
async function create(owner, body) {
|
||||
if (mine(owner).length >= LIMITS.perAccount) return { error: 'Up to ' + LIMITS.perAccount + ' sources per account.' };
|
||||
if (String(owner || '').trim().toLowerCase() !== String(process.env.ADMIN_EMAIL || '').trim().toLowerCase() && mine(owner).length >= LIMITS.perAccount) return { error: 'Up to ' + LIMITS.perAccount + ' sources per account.' }; // the owner's account has no source cap (Marty 2026-11-17)
|
||||
const tplKey = String(body.template || 'custom').trim().toLowerCase(); const tpl = tplKey !== 'custom' ? template(tplKey) : null;
|
||||
if (tplKey !== 'custom' && !tpl) return { error: 'No such network template.' };
|
||||
const name = String(body.name || (tpl ? tpl.name : '')).trim().slice(0, LIMITS.name); if (!name) return { error: 'Give the source a name.' };
|
||||
|
||||
Reference in New Issue
Block a user