Changeset 5f483e3 in Klonkt for src/config/database.js


Ignore:
Timestamp:
06/27/2026 03:01:13 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
3746f6a
Parents:
98fe58a
Message:

chore: code cleanup — remove dead files, deps, DB tables, Google-login remnants

  • Deleted dead files: routes/notifications.js + services/NotificationService.js + views/pages/notifications.ejs (old bell, unmounted; live fedi notifications live in posts.js); deploy/verify.ps1 (stale smoke test).
  • package.json — drop unused ws dependency (no WebSocket since Prutter was removed).
  • .env.example — drop GOOGLE_* vars (Google login removed).
  • config/database.js — remove CREATE statements for dead tables (circle_links/remote_actors/ remote_posts from old Circles v1; user_notifications; post_likes). No DROP — existing rows stay.
  • services/i18n.js — remove dead keys: hub, prutter, and the whole Google-login set (+ the agoog.* wizard + glog.* notices, ~280 lines). Kept aseo.verify_google. solo_desc/login_google_only de-Googled.
  • views/pages/auth-login.ejs — drop the dead Google error block + button CSS; the password login form is unchanged.
  • deploy/post-receive — fix stale pm2 reload prutcms -> klonkt.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/config/database.js

    r98fe58a r5f483e3  
    163163  `);
    164164
    165   // ── Circles (federation) ────────────────────────────────────
    166   // Decentralised, asymmetric connections between solo instances.
    167   db.exec(`
    168     CREATE TABLE IF NOT EXISTS circle_links (
    169       id TEXT PRIMARY KEY,
    170       local_site_id TEXT NOT NULL,
    171       remote_url TEXT NOT NULL,
    172       remote_actor_id TEXT,
    173       label TEXT,
    174       status TEXT DEFAULT 'active',
    175       added_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    176       last_synced DATETIME,
    177       last_error TEXT,
    178       UNIQUE(local_site_id, remote_url),
    179       FOREIGN KEY (local_site_id) REFERENCES sites(id)
    180     );
    181     CREATE TABLE IF NOT EXISTS remote_actors (
    182       id TEXT PRIMARY KEY,
    183       url TEXT UNIQUE NOT NULL,
    184       name TEXT,
    185       summary TEXT,
    186       avatar TEXT,
    187       public_key TEXT NOT NULL,
    188       fetched_at DATETIME DEFAULT CURRENT_TIMESTAMP
    189     );
    190     CREATE TABLE IF NOT EXISTS remote_posts (
    191       id TEXT PRIMARY KEY,
    192       actor_id TEXT NOT NULL,
    193       published DATETIME,
    194       title TEXT,
    195       summary TEXT,
    196       url TEXT,
    197       media_json TEXT,
    198       raw_json TEXT,
    199       fetched_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    200       FOREIGN KEY (actor_id) REFERENCES remote_actors(id)
    201     );
    202   `);
    203 
    204   // Tags from the original post — shown in the circle feed (comma-separated string).
    205   ensureColumn('remote_posts', 'tags', 'TEXT');
    206 
    207165  // Newsletter / mailing list (premium). Subscribers per site; double opt-in when SMTP
    208166  // is configured (status 'pending' until confirmed), otherwise single opt-in ('confirmed').
     
    252210  `);
    253211
    254   // Notifications: someone replies to your comment / post, or likes your post. Snapshots
    255   // of name/title so the list can be shown cheaply without joins.
    256   // NB: deliberately named 'user_notifications' — some older DBs still have a stale,
    257   // unused 'notifications' table with a different schema (no read column).
    258   db.exec(`
    259     CREATE TABLE IF NOT EXISTS user_notifications (
    260       id TEXT PRIMARY KEY,
    261       user_id TEXT NOT NULL,
    262       type TEXT NOT NULL,
    263       actor_id TEXT,
    264       actor_name TEXT,
    265       post_slug TEXT,
    266       post_title TEXT,
    267       url TEXT,
    268       read INTEGER DEFAULT 0,
    269       created_at DATETIME DEFAULT CURRENT_TIMESTAMP
    270     );
    271   `);
    272   // Older DBs may have a user_notifications table predating these columns — add
    273   // them before the index (which references `read`), else boot crashes.
    274   ensureColumn('user_notifications', 'type', 'TEXT');
    275   ensureColumn('user_notifications', 'actor_id', 'TEXT');
    276   ensureColumn('user_notifications', 'actor_name', 'TEXT');
    277   ensureColumn('user_notifications', 'post_slug', 'TEXT');
    278   ensureColumn('user_notifications', 'post_title', 'TEXT');
    279   ensureColumn('user_notifications', 'url', 'TEXT');
    280   ensureColumn('user_notifications', 'read', 'INTEGER DEFAULT 0');
    281   db.exec('CREATE INDEX IF NOT EXISTS idx_unotif_user ON user_notifications(user_id, read, created_at);');
    282 
    283212  // Link-in-bio click statistics (premium #6). One counter per (site, url); the
    284213  // link-in-bio page links via /links/go/:i which counts the click and redirects.
     
    293222  `);
    294223
    295   // Likes / favourites: a logged-in user can like a post. The set of
    296   // posts a user liked = their favourites (/favorieten page). One row
    297   // per (post, user); unique so that liking is idempotent.
    298   db.exec(`
    299     CREATE TABLE IF NOT EXISTS post_likes (
    300       post_id TEXT NOT NULL,
    301       user_id TEXT NOT NULL,
    302       created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    303       PRIMARY KEY (post_id, user_id)
    304     );
    305     CREATE INDEX IF NOT EXISTS idx_post_likes_user ON post_likes(user_id, created_at);
    306     CREATE INDEX IF NOT EXISTS idx_post_likes_post ON post_likes(post_id);
    307   `);
    308224
    309225  // ── ActivityPub (fediverse bridge) ──────────────────────────
Note: See TracChangeset for help on using the changeset viewer.