Files
cline-multi-mirror/src/core/controller/web/fetchOpenGraphData.ts
T
Sarah Fortune a1bf1f95a3 refactor(proto): Align proto directory structure with package names to follow best practices (#5171)
* Reorganized proto directory structure to match package naming convention

Moved cline package protos from the proto directory to proto/cline/ directory
Host package protos remain in proto/host/ directory

Updated all import statements across codebase to reflect new proto paths

Removed proto linter exception for package/directory mismatch rule

Fix Vscode proto indexing errors by setting the proto path in the Vscode settings.

* Update imports to use new package

Update imports from @shared/proto/<thing> to @share/proto/cline/<thing>
2025-07-26 00:58:16 -04:00

27 lines
1.1 KiB
TypeScript

import { Controller } from ".."
import { StringRequest } from "@shared/proto/cline/common"
import { OpenGraphData } from "@shared/proto/cline/web"
import { fetchOpenGraphData as fetchOGData } from "../../../integrations/misc/link-preview"
import { convertDomainOpenGraphDataToProto } from "../../../shared/proto-conversions/web/open-graph-conversion"
/**
* Fetches Open Graph metadata from a URL
* @param controller The controller instance
* @param request The request containing the URL to fetch metadata from
* @returns Promise resolving to OpenGraphData
*/
export async function fetchOpenGraphData(controller: Controller, request: StringRequest): Promise<OpenGraphData> {
try {
const url = request.value || ""
// Fetch open graph data using the existing utility
const ogData = await fetchOGData(url)
// Convert domain model to proto model
return convertDomainOpenGraphDataToProto(ogData)
} catch (error) {
console.error(`Error fetching Open Graph data: ${request.value}`, error)
// Return empty OpenGraphData object
return OpenGraphData.create({})
}
}