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.

Avoid looking up DIDs for handles which we know can't be on an independent PDS

gbl08ma 0c5deed2 422db931

+15 -5
+10 -4
labelDefiner.ts
··· 29 29 /^atproto\.brid\.gy$/ // It's too slow to respond 30 30 ]; 31 31 32 + const ignoredHandlePatterns: RegExp[] = [ 33 + /^.+\.bsky\.social$/, // (I think) it's safe to assume these handles can't point to a DID hosted on an independent PDS 34 + ]; 35 + 32 36 export class LabelDefiner { 33 37 private loginCredentials: LoginCredentials; 34 38 private setPDSOnCredentials = false; ··· 126 130 const pdsURL = new URL(pds); 127 131 const possibleLabel = pdsURL.hostname.replaceAll("-", "--").split(".").reverse().join("-"); 128 132 129 - for(const r of ignoredPDSHostnamePatterns) { 130 - if(r.test(pdsURL.hostname)) { 131 - return []; 132 - } 133 + if (ignoredPDSHostnamePatterns.findIndex(r => r.test(pdsURL.hostname)) >= 0) { 134 + return []; 133 135 } 134 136 135 137 return [baseLabel, this.dedicatedLabelsMap.get(possibleLabel) ?? fallbackLabel]; 138 + } 139 + 140 + shouldIgnoreHandle(handle: string): boolean { 141 + return ignoredHandlePatterns.findIndex(r => r.test(handle)) >= 0; 136 142 } 137 143 }
+5 -1
labeler.ts
··· 152 152 console.log("Fell more than 30s behind, reconnecting to jetstream"); 153 153 break; 154 154 } 155 + // avoid looking up DIDs for handles which we know can't be on an independent PDS 156 + if (event.kind === "identity" && this.labelDefiner.shouldIgnoreHandle(event.identity.handle)) { 157 + continue; 158 + } 155 159 try { 156 - const mayUseCache = event.kind != "identity"; 160 + const mayUseCache = event.kind !== "identity"; 157 161 const pds = await this.crawler.identifyPDSofDID(event.did as `did:${"plc" | "web"}:${string}`, mayUseCache); 158 162 159 163 yield {