| 91 | } |
| 92 | |
| 93 | function getAutoUpdate(uid) { |
| 94 | const db = sqliteClient.getDb(); |
| 95 | const targetUid = uid; |
| 96 | |
| 97 | try { |
| 98 | const row = db.prepare('SELECT auto_update_enabled FROM users WHERE uid = ?').get(targetUid); |
| 99 | |
| 100 | if (row) { |
| 101 | console.log('SQLite: Auto update setting found:', row.auto_update_enabled); |
| 102 | return row.auto_update_enabled !== 0; |
| 103 | } else { |
| 104 | // User doesn't exist, create them with default settings |
| 105 | const now = Math.floor(Date.now() / 1000); |
| 106 | const stmt = db.prepare( |
| 107 | 'INSERT OR REPLACE INTO users (uid, display_name, email, created_at, auto_update_enabled) VALUES (?, ?, ?, ?, ?)'); |
| 108 | stmt.run(targetUid, 'User', 'user@example.com', now, 1); |
| 109 | return true; // default to enabled |
| 110 | } |
| 111 | } catch (error) { |
| 112 | console.error('SQLite: Error getting auto_update_enabled setting:', error); |
| 113 | return true; // fallback to enabled |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | function setAutoUpdate(uid, isEnabled) { |
| 118 | const db = sqliteClient.getDb(); |