0.6 rust重构01
This commit is contained in:
@@ -4,6 +4,7 @@ import { nowIso } from "./_utils/time";
|
||||
import { enqueueExtractMediaAssetTextJob, enqueueIngestMediaAssetJob } from "./_utils/ingestJobs";
|
||||
import type { MutationCtx, QueryCtx } from "./_generated/server";
|
||||
import { internal } from "./_generated/api";
|
||||
import { getCanonicalDocumentByBusinessId } from "./_utils/documentRecord";
|
||||
|
||||
async function assertWorkspaceMember(ctx: QueryCtx | MutationCtx, userId: string, workspaceId: string) {
|
||||
const membership = await ctx.db
|
||||
@@ -302,10 +303,7 @@ export const createWithStorage = mutation({
|
||||
handler: async (ctx, args) => {
|
||||
await assertWorkspaceMember(ctx, args.userId, args.asset.workspace_id);
|
||||
|
||||
const doc = await ctx.db
|
||||
.query("documents")
|
||||
.withIndex("by_document_id", (q) => q.eq("id", args.asset.document_id))
|
||||
.first();
|
||||
const doc = await getCanonicalDocumentByBusinessId<any>(ctx, args.asset.document_id);
|
||||
|
||||
if (!doc || doc.workspace_id !== args.asset.workspace_id) {
|
||||
throw new Error("目标页面不存在或不属于该工作空间");
|
||||
|
||||
Reference in New Issue
Block a user