stable
This commit is contained in:
24
database.js
24
database.js
@@ -59,4 +59,28 @@ export async function GetPrivateKey(pubkey){
|
||||
export async function GetKeypairFromEmail(email){
|
||||
const [rows] = await pool.query("SELECT Users.pub_key,Users.email, PrivateKeys.private_key FROM Users JOIN PrivateKeys ON Users.pub_key = PrivateKeys.pub_key WHERE email=?", [email]);
|
||||
return rows[0];
|
||||
}
|
||||
|
||||
export async function CreateNewRequest(){
|
||||
const id = uuidv4();
|
||||
|
||||
await pool.query(`INSERT INTO Requests (id) VALUES(?)`, [id]);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
export async function SetRequestResult(id,result){
|
||||
const [rows] = await pool.query("UPDATE Requests SET result=?, status=1 WHERE id=?", [result,id]);
|
||||
|
||||
return rows.length;
|
||||
}
|
||||
|
||||
|
||||
function uuidv4() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
||||
.replace(/[xy]/g, function (c) {
|
||||
const r = Math.random() * 16 | 0,
|
||||
v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user