vybe/src/get_keys.js

32 lines
672 B
JavaScript
Raw Normal View History

2023-05-29 18:08:20 -07:00
const db = require("../db");
const authwrap = require("./authwrap");
const get_keys = async (msg, respond, socket, io) => {
// validate inputs
if (!msg.names) {
return respond({
success: false,
message: "user names required",
});
}
if (typeof msg.names !== "object") {
return respond({
success: false,
message: "can't iterate user names",
});
}
const keys = await db.query(
`select name, pubkey from users where name in (${msg.names
.map((i) => "?")
.join(",")})`,
msg.names
);
// respond
return respond({
success: true,
keys: keys.rows,
});
};
module.exports = authwrap(get_keys);