+17
-29
src/main.ts
+17
-29
src/main.ts
···
95
95
const tasks: Promise<void>[] = [];
96
96
97
97
// Check if the record has facets
98
-
if (hasFacets) {
99
-
const hasLinkType = event.commit.record.facets!.some((facet) =>
98
+
if (hasFacets && event.commit.record.facets) {
99
+
const hasLinkType = event.commit.record.facets.some((facet) =>
100
100
facet.features.some(
101
101
(feature) => feature.$type === "app.bsky.richtext.facet#link",
102
102
),
103
103
);
104
104
105
105
if (hasLinkType) {
106
-
const urls = event.commit.record
107
-
.facets!.flatMap((facet) =>
106
+
const urls = event.commit.record.facets
107
+
.flatMap((facet) =>
108
108
facet.features.filter(
109
109
(feature) => feature.$type === "app.bsky.richtext.facet#link",
110
110
),
···
166
166
async (event: CommitUpdateEvent<"app.bsky.actor.profile">) => {
167
167
try {
168
168
if (event.commit.record.displayName || event.commit.record.description) {
169
-
checkDescription(
170
-
event.did,
171
-
event.time_us,
172
-
event.commit.record.displayName as string,
173
-
event.commit.record.description as string,
174
-
);
175
-
checkDisplayName(
176
-
event.did,
177
-
event.time_us,
178
-
event.commit.record.displayName as string,
179
-
event.commit.record.description as string,
180
-
);
169
+
const displayName = event.commit.record.displayName ?? "";
170
+
const description = event.commit.record.description ?? "";
171
+
172
+
checkDescription(event.did, event.time_us, displayName, description);
173
+
checkDisplayName(event.did, event.time_us, displayName, description);
181
174
}
182
175
183
176
if (event.commit.record.joinedViaStarterPack) {
···
200
193
async (event: CommitCreateEvent<"app.bsky.actor.profile">) => {
201
194
try {
202
195
if (event.commit.record.displayName || event.commit.record.description) {
203
-
checkDescription(
204
-
event.did,
205
-
event.time_us,
206
-
event.commit.record.displayName as string,
207
-
event.commit.record.description as string,
208
-
);
209
-
checkDisplayName(
210
-
event.did,
211
-
event.time_us,
212
-
event.commit.record.displayName as string,
213
-
event.commit.record.description as string,
214
-
);
196
+
const displayName = event.commit.record.displayName ?? "";
197
+
const description = event.commit.record.description ?? "";
198
+
199
+
checkDescription(event.did, event.time_us, displayName, description);
200
+
checkDisplayName(event.did, event.time_us, displayName, description);
215
201
}
216
202
217
203
if (event.commit.record.joinedViaStarterPack) {
···
289
275
function shutdown() {
290
276
try {
291
277
logger.info("Shutting down gracefully...");
292
-
fs.writeFileSync("cursor.txt", jetstream.cursor!.toString(), "utf8");
278
+
if (jetstream.cursor) {
279
+
fs.writeFileSync("cursor.txt", jetstream.cursor.toString(), "utf8");
280
+
}
293
281
jetstream.close();
294
282
metricsServer.close();
295
283
} catch (error) {