Skip to content

Commit 452f79e

Browse files
committed
Fixing duplicate fonts bug
1 parent 4f8b6f9 commit 452f79e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

server/claim/claim-revision/claim-revision.service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,17 @@ export class ClaimRevisionService {
204204
if (sources && Array.isArray(sources)) {
205205
for (let source of sources) {
206206
try {
207-
if (typeof source === "string") {
207+
const existingSource = await this.sourceService.findHref(source);
208+
if (existingSource && existingSource.length > 0) {
209+
for (let source of existingSource) {
210+
await this.sourceService.updateTargetId(source._id, claimId);
211+
}
212+
} else {
208213
await this.sourceService.create({
209214
href: source,
210215
targetId: claimId,
211216
targetModel: SourceTargetModel.Claim,
212217
});
213-
} else {
214-
await this.sourceService.updateTargetId(
215-
source._id,
216-
claimId
217-
);
218218
}
219219
} catch (e) {
220220
this.logger.error(e);

server/source/source.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ export class SourceService {
6363
return this.SourceModel.find({ match }, { _id: 1, href: 1 });
6464
}
6565

66+
findHref(href: string) {
67+
return this.SourceModel.find({ href }).exec();
68+
}
69+
6670
getById(_id) {
6771
return this.SourceModel.findById(_id);
6872
}

0 commit comments

Comments
 (0)