This repository has no description
0

Configure Feed

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

formatting and type changes

+38 -15
+38 -15
src/modules/atproto/application/useCases/ProcessCardFirehoseEventUseCase.ts
··· 5 5 import { IAtUriResolutionService } from '../../../cards/domain/services/IAtUriResolutionService'; 6 6 import { PublishedRecordId } from '../../../cards/domain/value-objects/PublishedRecordId'; 7 7 import { ATUri } from '../../domain/ATUri'; 8 - import { Record as CardRecord } from '../../infrastructure/lexicon/types/network/cosmik/card'; 8 + import { 9 + Record as CardRecord, 10 + NoteContent, 11 + UrlContent, 12 + } from '../../infrastructure/lexicon/types/network/cosmik/card'; 9 13 import { AddUrlToLibraryUseCase } from '../../../cards/application/useCases/commands/AddUrlToLibraryUseCase'; 10 14 import { UpdateUrlCardAssociationsUseCase } from '../../../cards/application/useCases/commands/UpdateUrlCardAssociationsUseCase'; 11 15 import { RemoveCardFromLibraryUseCase } from '../../../cards/application/useCases/commands/RemoveCardFromLibraryUseCase'; ··· 75 79 76 80 if (request.record.type === 'URL') { 77 81 // Handle URL card creation 78 - const urlContent = request.record.content as any; 82 + const urlContent = request.record.content as UrlContent; 79 83 if (!urlContent.url) { 80 84 console.warn(`URL card missing URL: ${request.atUri}`); 81 85 return ok(undefined); ··· 92 96 return ok(undefined); 93 97 } 94 98 95 - console.log(`Successfully created URL card from firehose event: ${result.value.urlCardId}`); 99 + console.log( 100 + `Successfully created URL card from firehose event: ${result.value.urlCardId}`, 101 + ); 96 102 } else if (request.record.type === 'NOTE') { 97 103 // Handle note card creation 98 - const noteContent = request.record.content as any; 104 + const noteContent = request.record.content as NoteContent; 99 105 if (!noteContent.text) { 100 106 console.warn(`Note card missing text: ${request.atUri}`); 101 107 return ok(undefined); ··· 103 109 104 110 // Get parent card from parentCard reference 105 111 if (!request.record.parentCard) { 106 - console.warn(`Note card missing parent card reference: ${request.atUri}`); 112 + console.warn( 113 + `Note card missing parent card reference: ${request.atUri}`, 114 + ); 107 115 return ok(undefined); 108 116 } 109 117 ··· 112 120 request.record.parentCard.uri, 113 121 ); 114 122 if (parentCardId.isErr() || !parentCardId.value) { 115 - console.warn(`Failed to resolve parent card: ${request.record.parentCard.uri}`); 123 + console.warn( 124 + `Failed to resolve parent card: ${request.record.parentCard.uri}`, 125 + ); 116 126 return ok(undefined); 117 127 } 118 128 ··· 128 138 return ok(undefined); 129 139 } 130 140 131 - console.log(`Successfully created note card from firehose event: ${result.value.noteCardId}`); 141 + console.log( 142 + `Successfully created note card from firehose event: ${result.value.noteCardId}`, 143 + ); 132 144 } 133 145 134 146 return ok(undefined); ··· 163 175 } 164 176 const curatorDid = atUriResult.value.did.value; 165 177 166 - const noteContent = request.record.content as any; 178 + const noteContent = request.record.content as NoteContent; 167 179 if (!noteContent.text) { 168 180 console.warn(`Note card missing text: ${request.atUri}`); 169 181 return ok(undefined); ··· 171 183 172 184 // Get parent card from parentCard reference 173 185 if (!request.record.parentCard) { 174 - console.warn(`Note card missing parent card reference: ${request.atUri}`); 186 + console.warn( 187 + `Note card missing parent card reference: ${request.atUri}`, 188 + ); 175 189 return ok(undefined); 176 190 } 177 191 ··· 180 194 request.record.parentCard.uri, 181 195 ); 182 196 if (parentCardId.isErr() || !parentCardId.value) { 183 - console.warn(`Failed to resolve parent card: ${request.record.parentCard.uri}`); 197 + console.warn( 198 + `Failed to resolve parent card: ${request.record.parentCard.uri}`, 199 + ); 184 200 return ok(undefined); 185 201 } 186 202 ··· 196 212 return ok(undefined); 197 213 } 198 214 199 - console.log(`Successfully updated note card from firehose event: ${result.value.noteCardId}`); 215 + console.log( 216 + `Successfully updated note card from firehose event: ${result.value.noteCardId}`, 217 + ); 200 218 return ok(undefined); 201 219 } catch (error) { 202 220 console.error(`Error processing card update event: ${error}`); ··· 222 240 request.atUri, 223 241 ); 224 242 if (cardIdResult.isErr()) { 225 - console.warn(`Failed to resolve card ID: ${cardIdResult.error.message}`); 243 + console.warn( 244 + `Failed to resolve card ID: ${cardIdResult.error.message}`, 245 + ); 226 246 return ok(undefined); 227 247 } 228 248 ··· 243 263 }); 244 264 245 265 if (result.isErr()) { 246 - console.warn(`Failed to remove card from library: ${result.error.message}`); 266 + console.warn( 267 + `Failed to remove card from library: ${result.error.message}`, 268 + ); 247 269 return ok(undefined); 248 270 } 249 271 250 - console.log(`Successfully removed card from library: ${result.value.cardId}`); 272 + console.log( 273 + `Successfully removed card from library: ${result.value.cardId}`, 274 + ); 251 275 } 252 276 253 277 return ok(undefined); ··· 256 280 return ok(undefined); 257 281 } 258 282 } 259 - 260 283 }