A Bluesky labeler that labels accounts hosted on PDSes operated by entities other than Bluesky PBC
3
fork

Configure Feed

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

Fix bugs introduced by newfound ability for accounts to migrate back to a PDS operated by Bluesky PBC

gbl08ma 8365dde6 cab62190

+49 -3
+1
global.d.ts
··· 1 + /// <reference types="bun-types/test-globals" />
+27
knownPDSStorage.ts
··· 156 156 } 157 157 } 158 158 159 + async removeKnownPDS(knownPDSURI: string) { 160 + await this.dbInitLock; 161 + 162 + const transaction = await this.db.transaction("write"); 163 + 164 + try { 165 + await transaction.execute({ 166 + sql: ` 167 + DELETE FROM known_pds 168 + WHERE uri = ? 169 + `, 170 + args: [knownPDSURI], 171 + }); 172 + 173 + await transaction.execute({ 174 + sql: ` 175 + DELETE FROM pds_crawling_failures 176 + WHERE uri = ? 177 + `, 178 + args: [knownPDSURI], 179 + }); 180 + await transaction.commit(); 181 + } finally { 182 + transaction.close(); 183 + } 184 + } 185 + 159 186 async markPDSCrawlFailure(uri: string, at: Date) { 160 187 const result = await this.db.execute({ 161 188 sql: `
+8
labelDefiner_test.ts
··· 1 + import { LabelDefiner } from "./labelDefiner"; 2 + 3 + describe('determinePDSLabels', () => { 4 + it('should return no labels for mushroom PDS', () => { 5 + const ld = new LabelDefiner({identifier: "", password: ""}) 6 + expect(ld.determinePDSLabels("https://amanita.us-east.host.bsky.network")).toEqual([]); 7 + }); 8 + })
+13 -3
labeler.ts
··· 318 318 console.log(`Scheduling known PDS ${knownPDS.uri} for re-crawling`); 319 319 this.taskProcessor.schedule(async () => { 320 320 await this.pdsProcessingMutex.runExclusive(knownPDS.uri, async () => { 321 - console.log(`Re-crawling known PDS ${knownPDS.uri}`); 322 - await this.processPDS(knownPDS.uri); 321 + if (this.pdsFilter(knownPDS.uri)) { 322 + console.log(`Re-crawling known PDS ${knownPDS.uri}`); 323 + await this.processPDS(knownPDS.uri); 324 + } else { 325 + console.log(`Removing known PDS ${knownPDS.uri}`); 326 + await this.knownPDSStorage.removeKnownPDS(knownPDS.uri); 327 + } 323 328 }); 324 329 }); 325 330 } ··· 349 354 try { 350 355 const maybeKnownPDS = await this.knownPDSStorage.getKnownPDS(pds); 351 356 352 - if (typeof maybeKnownPDS === "undefined") { 357 + const shouldHaveLabels = this.pdsFilter(pds); 358 + 359 + if (typeof maybeKnownPDS === "undefined" && shouldHaveLabels) { 353 360 console.log(`Crawling new PDS discovered when reprocessing labels for ${did}: ${pds}`); 354 361 await this.processPDS(pds); 355 362 } else { 363 + if (!shouldHaveLabels) { 364 + await this.knownPDSStorage.removeKnownPDS(pds); 365 + } 356 366 await this.processSingleDID(pds, did, false); 357 367 } 358 368 totalProcessed++;