32 lines
672 B
JavaScript
32 lines
672 B
JavaScript
|
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);
|