From 893dc7e6c03c5ec93def91c81036eae3846a8202 Mon Sep 17 00:00:00 2001 From: flipsimon <28535045+flipsimon@users.noreply.github.com> Date: Tue, 12 Dec 2023 02:58:25 +0100 Subject: [PATCH 1/2] Added check for same uris in one batch and fixed ContentItem to Concept relation bug --- packages/repco-core/package.json | 4 ++-- packages/repco-core/src/datasources/activitypub.ts | 2 +- packages/repco-core/src/repo/relation-finder.ts | 10 ++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/repco-core/package.json b/packages/repco-core/package.json index c79de625..1b16dc3e 100644 --- a/packages/repco-core/package.json +++ b/packages/repco-core/package.json @@ -27,14 +27,14 @@ "iso8601-duration": "^2.1.1", "level": "^8.0.0", "multiformats": "^11.0.2", - "repco-common": "*", "repco-activitypub": "*", + "repco-common": "*", "repco-prisma": "*", "rss-parser": "^3.12.0", "speedometer": "^1.1.0", "streamx": "^2.12.5", "uint8arrays": "^4.0.3", - "undici": "=5.16.0", + "undici": "^5.28.2", "vscode-uri": "^3.0.6", "zod": "^3.19" }, diff --git a/packages/repco-core/src/datasources/activitypub.ts b/packages/repco-core/src/datasources/activitypub.ts index 362fc905..7fb6e0c2 100644 --- a/packages/repco-core/src/datasources/activitypub.ts +++ b/packages/repco-core/src/datasources/activitypub.ts @@ -633,7 +633,7 @@ export class ActivityPubDataSource const category = video.category && video.category !== undefined && - this._uriLink('category', video.category.identifier) + this._uriLink('category', video.category.name) category && conceptLinks.push(category) const tags = diff --git a/packages/repco-core/src/repo/relation-finder.ts b/packages/repco-core/src/repo/relation-finder.ts index ff858bbb..4632cfdb 100644 --- a/packages/repco-core/src/repo/relation-finder.ts +++ b/packages/repco-core/src/repo/relation-finder.ts @@ -43,7 +43,6 @@ export class RelationFinder { // check if already in map: resolve now if (this.uriMap.has(value.uri)) { value.uid = this.uriMap.get(value.uri) - // BUG? NOTHING HAPPENS WITH value.uid } else { this.pendingUris.add(value.uri) if (relation) this.relsByUri.push(value.uri, relation) @@ -51,11 +50,18 @@ export class RelationFinder { } pushEntity(entity: EntityInputWithHeaders) { - const uid = entity.uid + let uid = entity.uid if (this.entities.has(uid)) return this.entities.set(uid, entity) if (entity.headers.EntityUris) { for (const uri of entity.headers.EntityUris) { + const foundUid = this.uriMap.get(uri) + if (foundUid) { + // if entity with the same uri already exists delete it from entities + this.entities.delete(uid) + uid = foundUid + break + } this.discoveredUid(uri, uid) } } From b905ea52dc2ebd0b0c172674f358a533560ad272 Mon Sep 17 00:00:00 2001 From: flipsimon <28535045+flipsimon@users.noreply.github.com> Date: Tue, 12 Dec 2023 18:36:07 +0100 Subject: [PATCH 2/2] Fixed link from ContentItem to Concept with kind category --- packages/repco-core/src/datasources/activitypub.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/repco-core/src/datasources/activitypub.ts b/packages/repco-core/src/datasources/activitypub.ts index 7fb6e0c2..ed0c0911 100644 --- a/packages/repco-core/src/datasources/activitypub.ts +++ b/packages/repco-core/src/datasources/activitypub.ts @@ -633,7 +633,7 @@ export class ActivityPubDataSource const category = video.category && video.category !== undefined && - this._uriLink('category', video.category.name) + this._uriLink('category', 'peertube:' + video.category.name) category && conceptLinks.push(category) const tags =