This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

clean up how we handle URLs in connection creation

+28 -34
+28 -34
src/modules/cards/application/useCases/commands/CreateConnectionUseCase.ts
··· 80 80 } 81 81 const curatorId = curatorIdResult.value; 82 82 83 - // Create source UrlOrCardId 83 + // Create source UrlOrCardId - validates and normalizes URLs automatically 84 84 const sourceResult = UrlOrCardId.reconstruct( 85 85 request.sourceType, 86 86 request.sourceValue, ··· 92 92 } 93 93 const source = sourceResult.value; 94 94 95 - // Create target UrlOrCardId 95 + // Create target UrlOrCardId - validates and normalizes URLs automatically 96 96 const targetResult = UrlOrCardId.reconstruct( 97 97 request.targetType, 98 98 request.targetValue, ··· 142 142 }>[] = []; 143 143 144 144 // Fetch source metadata if it's a URL 145 - if (source.type === 'URL') { 146 - const urlResult = URL.create(source.stringValue); 147 - if (urlResult.isOk()) { 148 - metadataFetches.push( 149 - this.metadataService 150 - .fetchMetadata(urlResult.value) 151 - .then((result) => ({ 152 - type: 'source' as const, 153 - metadata: result.isOk() ? result.value : undefined, 154 - })) 155 - .catch(() => ({ 156 - type: 'source' as const, 157 - metadata: undefined, 158 - })), 159 - ); 160 - } 145 + if (source.type === UrlOrCardIdType.URL && source.url) { 146 + metadataFetches.push( 147 + this.metadataService 148 + .fetchMetadata(source.url) 149 + .then((result) => ({ 150 + type: 'source' as const, 151 + metadata: result.isOk() ? result.value : undefined, 152 + })) 153 + .catch(() => ({ 154 + type: 'source' as const, 155 + metadata: undefined, 156 + })), 157 + ); 161 158 } 162 159 163 160 // Fetch target metadata if it's a URL 164 - if (target.type === 'URL') { 165 - const urlResult = URL.create(target.stringValue); 166 - if (urlResult.isOk()) { 167 - metadataFetches.push( 168 - this.metadataService 169 - .fetchMetadata(urlResult.value) 170 - .then((result) => ({ 171 - type: 'target' as const, 172 - metadata: result.isOk() ? result.value : undefined, 173 - })) 174 - .catch(() => ({ 175 - type: 'target' as const, 176 - metadata: undefined, 177 - })), 178 - ); 179 - } 161 + if (target.type === UrlOrCardIdType.URL && target.url) { 162 + metadataFetches.push( 163 + this.metadataService 164 + .fetchMetadata(target.url) 165 + .then((result) => ({ 166 + type: 'target' as const, 167 + metadata: result.isOk() ? result.value : undefined, 168 + })) 169 + .catch(() => ({ 170 + type: 'target' as const, 171 + metadata: undefined, 172 + })), 173 + ); 180 174 } 181 175 182 176 // Wait for all metadata fetches to complete