alpha
Login
or
Join now
nandi.uk
/
semble
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
formatting and type changes
author
Wesley Finck
date
8 months ago
(Nov 15, 2025, 11:39 AM -0800)
commit
4ece9f4e
4ece9f4e28821b5741efef2b8ca3459b9f40f06f
parent
25fa259f
25fa259fc6062db6f43d88ba62929f34c31c477e
+38
-15
1 changed file
Expand all
Collapse all
Unified
Split
src
modules
atproto
application
useCases
ProcessCardFirehoseEventUseCase.ts
+38
-15
src/modules/atproto/application/useCases/ProcessCardFirehoseEventUseCase.ts
View file
Reviewed
···
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
8
-
import { Record as CardRecord } from '../../infrastructure/lexicon/types/network/cosmik/card';
8
8
+
import {
9
9
+
Record as CardRecord,
10
10
+
NoteContent,
11
11
+
UrlContent,
12
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
78
-
const urlContent = request.record.content as any;
82
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
95
-
console.log(`Successfully created URL card from firehose event: ${result.value.urlCardId}`);
99
99
+
console.log(
100
100
+
`Successfully created URL card from firehose event: ${result.value.urlCardId}`,
101
101
+
);
96
102
} else if (request.record.type === 'NOTE') {
97
103
// Handle note card creation
98
98
-
const noteContent = request.record.content as any;
104
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
106
-
console.warn(`Note card missing parent card reference: ${request.atUri}`);
112
112
+
console.warn(
113
113
+
`Note card missing parent card reference: ${request.atUri}`,
114
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
115
-
console.warn(`Failed to resolve parent card: ${request.record.parentCard.uri}`);
123
123
+
console.warn(
124
124
+
`Failed to resolve parent card: ${request.record.parentCard.uri}`,
125
125
+
);
116
126
return ok(undefined);
117
127
}
118
128
···
128
138
return ok(undefined);
129
139
}
130
140
131
131
-
console.log(`Successfully created note card from firehose event: ${result.value.noteCardId}`);
141
141
+
console.log(
142
142
+
`Successfully created note card from firehose event: ${result.value.noteCardId}`,
143
143
+
);
132
144
}
133
145
134
146
return ok(undefined);
···
163
175
}
164
176
const curatorDid = atUriResult.value.did.value;
165
177
166
166
-
const noteContent = request.record.content as any;
178
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
174
-
console.warn(`Note card missing parent card reference: ${request.atUri}`);
186
186
+
console.warn(
187
187
+
`Note card missing parent card reference: ${request.atUri}`,
188
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
183
-
console.warn(`Failed to resolve parent card: ${request.record.parentCard.uri}`);
197
197
+
console.warn(
198
198
+
`Failed to resolve parent card: ${request.record.parentCard.uri}`,
199
199
+
);
184
200
return ok(undefined);
185
201
}
186
202
···
196
212
return ok(undefined);
197
213
}
198
214
199
199
-
console.log(`Successfully updated note card from firehose event: ${result.value.noteCardId}`);
215
215
+
console.log(
216
216
+
`Successfully updated note card from firehose event: ${result.value.noteCardId}`,
217
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
225
-
console.warn(`Failed to resolve card ID: ${cardIdResult.error.message}`);
243
243
+
console.warn(
244
244
+
`Failed to resolve card ID: ${cardIdResult.error.message}`,
245
245
+
);
226
246
return ok(undefined);
227
247
}
228
248
···
243
263
});
244
264
245
265
if (result.isErr()) {
246
246
-
console.warn(`Failed to remove card from library: ${result.error.message}`);
266
266
+
console.warn(
267
267
+
`Failed to remove card from library: ${result.error.message}`,
268
268
+
);
247
269
return ok(undefined);
248
270
}
249
271
250
250
-
console.log(`Successfully removed card from library: ${result.value.cardId}`);
272
272
+
console.log(
273
273
+
`Successfully removed card from library: ${result.value.cardId}`,
274
274
+
);
251
275
}
252
276
253
277
return ok(undefined);
···
256
280
return ok(undefined);
257
281
}
258
282
}
259
259
-
260
283
}