user picker
This commit is contained in:
20
server/dist/index.js
vendored
20
server/dist/index.js
vendored
@@ -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);
|
||||
|
||||
@@ -806,6 +806,18 @@ app.get('/api/auth/session', async (request, reply) => {
|
||||
};
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
@@ -1497,6 +1509,21 @@ function listAdminUsers(): AdminUserSummary[] {
|
||||
}));
|
||||
}
|
||||
|
||||
function listDiscoverableUsers(currentUserId: string): PublicUser[] {
|
||||
const rows = selectAllUsersStatement.all() as DatabaseUserRow[];
|
||||
|
||||
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: string): UserRecord | null {
|
||||
const approvedAt = new Date().toISOString();
|
||||
const result = approveUserStatement.run(approvedAt, userId);
|
||||
|
||||
Reference in New Issue
Block a user