MCPcopy Create free account
hub / github.com/deta/surf / processLink

Method processLink

packages/services/src/lib/sync.ts:102–133  ·  view source on GitHub ↗
(link: SyncLinkItem)

Source from the content-addressed store, hash-verified

100 }
101
102 private async processLink(link: SyncLinkItem) {
103 this.log.debug('syncing link', link)
104
105 const matchingResources = await this.resourceManager.getResourcesFromSourceURL(link.url)
106 let bookmarkedResource = matchingResources.find(
107 (resource) =>
108 resource.type !== ResourceTypes.ANNOTATION && resource.type !== ResourceTypes.HISTORY_ENTRY
109 )
110
111 if (bookmarkedResource) {
112 this.log.debug('found existing bookmarked resource', bookmarkedResource)
113 return null
114 }
115
116 const date = new Date(link.timestamp)
117
118 const parsed = await extractAndCreateWebResource(
119 this.resourceManager,
120 link.url,
121 {
122 sourceURI: link.url
123 },
124 [
125 ResourceTag.canonicalURL(link.url),
126 ResourceTag.import(),
127 ResourceTag.viewedByUser(false),
128 ...(link.timestamp ? [ResourceTag.sourcePublishedAt(date.toISOString())] : [])
129 ]
130 )
131
132 return parsed.resource
133 }
134
135 async sync() {
136 let toast: Toast | null = null

Callers 1

syncMethod · 0.95

Calls 7

debugMethod · 0.80
canonicalURLMethod · 0.80
importMethod · 0.80
viewedByUserMethod · 0.80
sourcePublishedAtMethod · 0.80

Tested by

no test coverage detected