Q32: documents and knowledge appear in global search
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c8233d258
commit
cb464c3ee4
5 files changed
+58
No files matched your search
@@ -88,6 +88,8 @@ export class SearchService {
|
||||
...this.providerDocs(orgId),
|
||||
...this.socialDocs(orgId),
|
||||
...this.scheduledPostDocs(orgId),
|
||||
...this.documentDocs(orgId),
|
||||
...this.knowledgeDocs(orgId),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -156,6 +158,24 @@ export class SearchService {
|
||||
return rows.map((row) => doc("scheduled_post", row.id, createTitle(row.body_md), row.body_md, { type: "Social", state: row.state, account: row.social_account_id }));
|
||||
}
|
||||
|
||||
private documentDocs(orgId: string): SearchDoc[] {
|
||||
const rows = this.db.prepare("select id, title, doc_type, status, content from documents where org_id = ?").all(orgId) as Array<{ id: string; title: string; doc_type: string; status: string; content: string }>;
|
||||
return rows.map((row) => doc("document", row.id, row.title, row.content, { type: "Library", kind: row.doc_type, status: row.status }));
|
||||
}
|
||||
|
||||
private knowledgeDocs(orgId: string): SearchDoc[] {
|
||||
const rows = this.db.prepare("select id, topic, category, content, scope_type, superseded_by, valid_until from knowledge_entries where org_id = ?").all(orgId) as Array<{
|
||||
id: string; topic: string; category: string; content: string; scope_type: string; superseded_by: string | null; valid_until: string | null;
|
||||
}>;
|
||||
const now = new Date().toISOString();
|
||||
return rows.map((row) => doc("knowledge", row.id, row.topic, row.content, {
|
||||
type: "Library",
|
||||
category: row.category,
|
||||
scope: row.scope_type,
|
||||
state: row.superseded_by ? "superseded" : row.valid_until && row.valid_until <= now ? "expired" : "active",
|
||||
}));
|
||||
}
|
||||
|
||||
private canRead(orgId: string, employeeId: string, entityType: SearchEntityType, entityId: string): boolean {
|
||||
if (entityType === "chat_space") return this.canReadSpace(entityId, employeeId);
|
||||
if (entityType === "chat_message") return this.canReadMessage(orgId, entityId, employeeId);
|
||||
|
||||
Reference in new issue
Block a user