user picker

This commit is contained in:
2026-03-25 21:17:55 +01:00
parent 24bf3e38a7
commit 2fb6bd3783
6 changed files with 346 additions and 2 deletions

20
server/dist/index.js vendored
View File

@@ -472,6 +472,15 @@ app.get('/api/auth/session', async (request, reply) => {
messageEncryptionKey: authContext.user.messageEncryptionKey,
};
});
app.get('/api/users', async (request, reply) => {
const authContext = await authenticateRequest(request, reply);
if (!authContext) {
return;
}
return {
users: listDiscoverableUsers(authContext.user.id),
};
});
app.post('/api/files/document-preview-image', { bodyLimit: 64 * 1024 * 1024 }, async (request, reply) => {
const authContext = await authenticateRequest(request, reply);
if (!authContext) {
@@ -981,6 +990,17 @@ function listAdminUsers() {
approvedAt: row.approved_at,
}));
}
function listDiscoverableUsers(currentUserId) {
const rows = selectAllUsersStatement.all();
return rows
.filter((row) => row.is_active === 1 && row.id !== currentUserId)
.map((row) => ({
id: row.id,
username: row.username,
displayName: row.display_name,
}))
.sort((left, right) => left.displayName.localeCompare(right.displayName) || left.username.localeCompare(right.username));
}
function approveUser(userId) {
const approvedAt = new Date().toISOString();
const result = approveUserStatement.run(approvedAt, userId);