Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aliceisjustplaying committed Nov 11, 2024
1 parent 30b91b7 commit 59628b7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v22.9.0
v22.11.0
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ DID=did:plc:xxx
SIGNING_KEY=xxx
BSKY_IDENTIFIER=xxx
BSKY_PASSWORD=xxx
PORT=4002
METRICS_PORT=4102
PORT=4100
METRICS_PORT=4101
FIREHOSE_URL=wss://jetstream.atproto.tools/subscribe
CURSOR_UPDATE_INTERVAL=10000
```
Expand All @@ -47,7 +47,7 @@ The server needs to be reachable outside your local network using the URL you pr

```Caddyfile
labeler.example.com {
reverse_proxy 127.0.0.1:4002
reverse_proxy 127.0.0.1:4100
}
```

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
"@types/eslint__js": "^8.42.3",
"@types/express": "^4.17.21",
"@types/node": "^22.9.0",
"@types/ws": "^8.5.13",
"eslint": "^9.14.0",
"prettier": "^3.3.3",
"tsx": "^4.19.2",
"typescript": "^5.6.3",
"typescript-eslint": "^8.13.0"
"typescript-eslint": "^8.14.0"
},
"dependencies": {
"@atproto/api": "^0.13.15",
Expand All @@ -38,7 +37,7 @@
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"pino": "^9.5.0",
"pino-pretty": "^12.1.0",
"pino-pretty": "^13.0.0",
"prom-client": "^15.1.3"
}
}
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import 'dotenv/config';

export const DID = process.env.DID ?? '';
export const SIGNING_KEY = process.env.SIGNING_KEY ?? '';
export const PORT = process.env.PORT ? Number(process.env.PORT) : 4002;
export const METRICS_PORT = process.env.METRICS_PORT ? Number(process.env.METRICS_PORT) : 4102;
export const PORT = process.env.PORT ? Number(process.env.PORT) : 4100;
export const METRICS_PORT = process.env.METRICS_PORT ? Number(process.env.METRICS_PORT) : 4101;
export const FIREHOSE_URL = process.env.FIREHOSE_URL ?? 'wss://jetstream.atproto.tools/subscribe';
export const WANTED_COLLECTION = 'app.bsky.feed.like';
export const BSKY_IDENTIFIER = process.env.BSKY_IDENTIFIER ?? '';
export const BSKY_PASSWORD = process.env.BSKY_PASSWORD ?? '';
export const CURSOR_UPDATE_INTERVAL =
process.env.CURSOR_UPDATE_INTERVAL ? Number(process.env.CURSOR_UPDATE_INTERVAL) : 10000;
process.env.CURSOR_UPDATE_INTERVAL ? Number(process.env.CURSOR_UPDATE_INTERVAL) : 60000;
10 changes: 7 additions & 3 deletions src/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ function deleteAllLabels(did: string, labels: Set<string>) {

function addOrUpdateLabel(did: string, rkey: string, labels: Set<string>) {
const newLabel = LABELS.find((label) => label.rkey === rkey);
logger.info(`New label: ${newLabel?.identifier}`);
if (!newLabel) {
logger.warn(`New label not found: ${rkey}. Likely liked a post that's not one for labels.`);
return;
}
logger.info(`New label: ${newLabel.identifier}`);

if (labels.size >= LABEL_LIMIT) {
try {
Expand All @@ -75,8 +79,8 @@ function addOrUpdateLabel(did: string, rkey: string, labels: Set<string>) {
}

try {
labelerServer.createLabel({ uri: did, val: newLabel!.identifier });
logger.info(`Successfully labeled ${did} with ${newLabel?.identifier}`);
labelerServer.createLabel({ uri: did, val: newLabel.identifier });
logger.info(`Successfully labeled ${did} with ${newLabel.identifier}`);
} catch (error) {
logger.error(`Error adding new label: ${error}`);
}
Expand Down
4 changes: 1 addition & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ jetstream.on('error', (error) => {
jetstream.onCreate(WANTED_COLLECTION, (event: CommitCreateEvent<typeof WANTED_COLLECTION>) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (event.commit?.record?.subject?.uri?.includes(DID)) {
label(event.did, event.commit.record.subject.uri.split('/').pop()!).catch((error: unknown) => {
logger.error(`Unexpected error labeling ${event.did}: ${error}`);
});
label(event.did, event.commit.record.subject.uri.split('/').pop()!);
}
});

Expand Down

0 comments on commit 59628b7

Please sign in to comment.