Let the coordinator create workspaces and write findings in tasks
create_workspace gives the coordinator a way to start a workspace with its shared context, and the tool list is shared, so a new id can be used by create_bot or add_bot_to_workspace in the same reply. A coordinator's tasks now get create_workspace and update_workspace too: the research task that had the material could only report it, never write it into the workspace, so the coordinator promised an update it had no turn to make. A workspace created from chat is pushed as server:workspace-created, from the tool and from the live relay, so the rail shows it without a reload.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import BunSQLite from "@moduletrace/bun-sqlite";
|
||||
|
||||
type Params = {
|
||||
workspace_id: number | string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Every user who sees a workspace (`workspacesSql`), for live updates
|
||||
* about it: super admins and admins, and the members added to it
|
||||
* (`workspace_users`). A new workspace has none of those yet.
|
||||
*/
|
||||
export default async function grabWorkspaceAudience({ workspace_id }: Params): Promise<number[]> {
|
||||
const res = await BunSQLite.sql<{ user_id: number }>({
|
||||
sql: `SELECT user_id FROM user_types WHERE user_type IN ('super_admin', 'admin')
|
||||
UNION
|
||||
SELECT user_id FROM workspace_users WHERE workspace_id = ?`,
|
||||
values: [workspace_id],
|
||||
});
|
||||
|
||||
return (res.payload || []).map((row) => Number(row.user_id)).filter(Boolean);
|
||||
}
|
||||
Reference in New Issue
Block a user