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

Function setAutoUpdate

src/features/settings/repositories/sqlite.repository.js:117–136  ·  view source on GitHub ↗
(uid, isEnabled)

Source from the content-addressed store, hash-verified

115}
116
117function setAutoUpdate(uid, isEnabled) {
118 const db = sqliteClient.getDb();
119 const targetUid = uid || sqliteClient.defaultUserId;
120
121 try {
122 const result = db.prepare('UPDATE users SET auto_update_enabled = ? WHERE uid = ?').run(isEnabled ? 1 : 0, targetUid);
123
124 // If no rows were updated, the user might not exist, so create them
125 if (result.changes === 0) {
126 const now = Math.floor(Date.now() / 1000);
127 const stmt = db.prepare('INSERT OR REPLACE INTO users (uid, display_name, email, created_at, auto_update_enabled) VALUES (?, ?, ?, ?, ?)');
128 stmt.run(targetUid, 'User', 'user@example.com', now, isEnabled ? 1 : 0);
129 }
130
131 return { success: true };
132 } catch (error) {
133 console.error('SQLite: Error setting auto-update:', error);
134 throw error;
135 }
136}
137
138module.exports = {
139 getPresets,

Callers

nothing calls this directly

Calls 1

getDbMethod · 0.80

Tested by

no test coverage detected