diff --git a/src/modules/atproto/infrastructure/mappers/CardMapper.ts b/src/modules/atproto/infrastructure/mappers/CardMapper.ts index 72a4cf33..33836006 100644 --- a/src/modules/atproto/infrastructure/mappers/CardMapper.ts +++ b/src/modules/atproto/infrastructure/mappers/CardMapper.ts @@ -10,17 +10,20 @@ import { import { StrongRef } from '../../domain'; import { UrlMetadata as UrlMetadataVO } from 'src/modules/cards/domain/value-objects/UrlMetadata'; import { CuratorId } from 'src/modules/cards/domain/value-objects/CuratorId'; +import { EnvironmentConfigService } from 'src/shared/infrastructure/config/EnvironmentConfigService'; type CardRecordDTO = Record; export class CardMapper { + static cardCollection = new EnvironmentConfigService().getAtProtoCollections() + .card; static toCreateRecordDTO( card: Card, curatorId: CuratorId, parentCard?: Card, ): CardRecordDTO { const record: CardRecordDTO = { - $type: 'network.cosmik.card', + $type: this.cardCollection as any, type: card.type.value, content: this.mapCardContent(card), createdAt: card.createdAt.toISOString(), @@ -55,7 +58,7 @@ export class CardMapper { case CardTypeEnum.URL: { const urlContent = card.content.urlContent!; const urlContentDTO: $Typed = { - $type: 'network.cosmik.card#urlContent', + $type: `${this.cardCollection}#urlContent` as any, url: urlContent.url.value, }; @@ -69,7 +72,7 @@ export class CardMapper { case CardTypeEnum.NOTE: { const noteContent = card.content.noteContent!; const noteContentDTO: $Typed = { - $type: 'network.cosmik.card#noteContent', + $type: `${this.cardCollection}#noteContent` as any, text: noteContent.text, }; @@ -83,7 +86,7 @@ export class CardMapper { private static mapUrlMetadata(metadata: UrlMetadataVO): $Typed { return { - $type: 'network.cosmik.card#urlMetadata', + $type: `${this.cardCollection}#urlMetadata` as any, title: metadata.title, description: metadata.description, author: metadata.author, diff --git a/src/modules/atproto/infrastructure/mappers/CollectionMapper.ts b/src/modules/atproto/infrastructure/mappers/CollectionMapper.ts index d993bb3d..6f6fa4e2 100644 --- a/src/modules/atproto/infrastructure/mappers/CollectionMapper.ts +++ b/src/modules/atproto/infrastructure/mappers/CollectionMapper.ts @@ -1,12 +1,15 @@ import { Collection } from 'src/modules/cards/domain/Collection'; import { Record } from '../lexicon/types/network/cosmik/collection'; +import { EnvironmentConfigService } from 'src/shared/infrastructure/config/EnvironmentConfigService'; type CollectionRecordDTO = Record; export class CollectionMapper { + static readonly collectionType = + new EnvironmentConfigService().getAtProtoCollections().collection; static toCreateRecordDTO(collection: Collection): CollectionRecordDTO { return { - $type: 'network.cosmik.collection', + $type: this.collectionType as any, name: collection.name.value, description: collection.description?.value, accessType: collection.accessType,