source: Klonkt/src/services/SettingsService.js@ 7d61ab8

main
Last change on this file since 7d61ab8 was 8ef8c3e, checked in by Robin Genis <roboburr@…>, 2 months ago

feat(cirkel): remove the old Cirkels pull-protocol; Cirkels is now AP-only

Phase 4 of the Cirkels-on-AP rework. Removes the legacy custom-Ed25519 pull
protocol and everything around it: /.klonkt/* (federation.js), CircleService +
CircleFederation, the 15-min sync loop, the /admin/circle UI, the remote_posts
union in /cirkel and the /cirkel/:id local-reading page. Tenancy is retired
(getTenancy always 'solo'); the Solo|Circle mode picker is gone. /cirkel is now
purely the auto-boosted (featured) feed. The circle_links/remote_* tables are
kept as dead data. A scripts/migrate-circles.mjs converts existing circle_links
to AP follows with auto-boost (run per instance).

Co-Authored-By: Claude <noreply@…>

  • Property mode set to 100644
File size: 1.9 KB
Line 
1// Global app settings (key/value, cached). Primarily used for the tenancy mode.
2//
3// tenancy = 'solo' -> exactly one site (the primary/owner site)
4// tenancy = 'circle' -> solo site that federates with other solo Klonkt sites
5//
6// HUB MODE IS REMOVED (2026-06-24): multi-artist-per-domain was dropped in favour
7// of solo + Cirkels. getTenancy() coerces any legacy 'hub' value to 'solo' so all
8// the old `tenancy === 'hub'` branches are unreachable; the hub code is being
9// deleted incrementally.
10//
11// The cache is updated immediately on setSetting, so a toggle in admin
12// takes effect live without a restart.
13
14import db from '../config/database.js';
15
16let _cache = null;
17
18function load() {
19 if (!_cache) {
20 _cache = {};
21 for (const r of db.prepare('SELECT key, value FROM app_settings').all()) {
22 _cache[r.key] = r.value;
23 }
24 }
25 return _cache;
26}
27
28export function getSetting(key, fallback = null) {
29 const v = load()[key];
30 return v === undefined ? fallback : v;
31}
32
33export function setSetting(key, value) {
34 db.prepare(`
35 INSERT INTO app_settings (key, value, updated_at) VALUES (?, ?, CURRENT_TIMESTAMP)
36 ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = CURRENT_TIMESTAMP
37 `).run(key, String(value));
38 if (_cache) _cache[key] = String(value);
39}
40
41export function getTenancy() {
42 // Tenancy is retired: 'hub' and 'circle' were both removed. Every site is
43 // 'solo'. Cirkels are now an ActivityPub feature (auto-boost), not a mode.
44 return 'solo';
45}
46
47export function setTenancy() {
48 setSetting('tenancy', 'solo');
49}
50
51// ActivityPub / fediverse federation. ON by default. '0' = off: the site does
52// not federate, /ap/* is gone, and the "from the fediverse" reactions disappear
53// — which (since native comments were removed) means no comments at all.
54export function apEnabled() {
55 return getSetting('ap_enabled', '1') !== '0';
56}
Note: See TracBrowser for help on using the repository browser.