Untrusted global scripts support

This commit is contained in:
mdecimus
2024-09-02 11:18:00 +02:00
parent 3e0946743d
commit c10a8827c6
20 changed files with 295 additions and 180 deletions

View File

@@ -344,17 +344,25 @@ impl DirectoryStore {
if self.is_postgresql() {
concat!(
"INSERT INTO accounts (name, secret, description, ",
"type, active) VALUES ($1, $2, $3, $4, true) ON CONFLICT (name) DO NOTHING"
"type, active) VALUES ($1, $2, $3, $4, true) ",
"ON CONFLICT (name) ",
"DO UPDATE SET secret = $2, description = $3, type = $4, active = true"
)
} else if self.is_mysql() {
concat!(
"INSERT IGNORE INTO accounts (name, secret, description, ",
"type, active) VALUES (?, ?, ?, ?, true)"
"INSERT INTO accounts (name, secret, description, ",
"type, active) VALUES (?, ?, ?, ?, true) ",
"ON DUPLICATE KEY UPDATE ",
"secret = VALUES(secret), description = VALUES(description), ",
"type = VALUES(type), active = true"
)
} else {
concat!(
"INSERT OR IGNORE INTO accounts (name, secret, description, ",
"type, active) VALUES (?, ?, ?, ?, true)"
"INSERT INTO accounts (name, secret, description, ",
"type, active) VALUES (?, ?, ?, ?, true) ",
"ON CONFLICT(name) DO UPDATE SET ",
"secret = excluded.secret, description = excluded.description, ",
"type = excluded.type, active = true"
)
},
vec![