MCPcopy
hub / github.com/pickle-com/glass / getAutoUpdate

Function getAutoUpdate

src/features/settings/repositories/sqlite.repository.js:93–115  ·  view source on GitHub ↗
(uid)

Source from the content-addressed store, hash-verified

91}
92
93function 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
117function setAutoUpdate(uid, isEnabled) {
118 const db = sqliteClient.getDb();

Callers

nothing calls this directly

Calls 2

getDbMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected