this repo has no description
0
fork

Configure Feed

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

ughhhhhhhhh

alice a569dbd7 e81c78b3

+57 -94
-49
Dockerfile
··· 1 - # # syntax = docker/dockerfile:1 2 - 3 - # # Adjust NODE_VERSION as desired 4 - # ARG NODE_VERSION=18.16.0 5 - # FROM node:${NODE_VERSION}-slim as base 6 - 7 - 8 - 9 - # # Node.js app lives here 10 - # WORKDIR /app 11 - 12 - # # Set production environment 13 - 14 - 15 - # ARG PNPM_VERSION=8.5.1 16 - # RUN npm install -g pnpm@$PNPM_VERSION 17 - 18 - 19 - # # Throw-away build stage to reduce size of final image 20 - # FROM base as build 21 - 22 - # # Install packages needed to build node modules 23 - # RUN apt-get update -qq && \ 24 - # apt-get install -y python-is-python3 pkg-config build-essential 25 - 26 - # # Install node modules 27 - # COPY --link package.json pnpm-lock.yaml ./ 28 - # RUN pnpm install --frozen-lockfile 29 - 30 - # # Copy application code 31 - # COPY --link . . 32 - 33 - # # Build application 34 - # RUN pnpm run build 35 - 36 - # # Remove development dependencies 37 - # RUN pnpm prune --prod 38 - 39 - 40 - # # Final stage for app image 41 - # FROM base 42 - 43 - # # Copy built application 44 - # COPY --from=build /app /app 45 - 46 - # # Start the server by default, this can be overwritten at runtime 47 - # EXPOSE 3000 48 - # CMD [ "pnpm", "run", "start" ] 49 - 50 1 FROM node:18-alpine as builder 51 2 RUN apk add --no-cache libc6-compat 52 3 RUN corepack enable && corepack prepare pnpm@latest --activate
+3
README.md
··· 1 1 # Who's Alice 2 2 3 3 A custom feed for Bluesky featuring all the Alices. 4 + 5 + Local URL: http://localhost:3000/xrpc/app.bsky.feed.getFeedSkeleton?feed=at://did:web:feeds.bsky.sh/app.bsky.feed.generator/whos-alice 6 + Prod URL: http://feeds.bsky.sh/xrpc/app.bsky.feed.getFeedSkeleton?feed=at://did:web:feeds.bsky.sh/app.bsky.feed.generator/whos-alice
+4 -1
src/index.ts
··· 1 1 import dotenv from 'dotenv' 2 2 import FeedGenerator from './server' 3 + import { AddressInfo } from 'net' 3 4 4 5 const run = async () => { 5 6 dotenv.config() ··· 17 18 }) 18 19 await server.start() 19 20 console.log( 20 - `🤖 running feed generator at http://${server.cfg.hostname}:${server.cfg.port}`, 21 + `🤖 running feed generator at http://${server.cfg.hostname}:${ 22 + server.cfg.port 23 + }, bound to ${(server.server?.address() as AddressInfo).address}`, 21 24 ) 22 25 } 23 26
+50 -44
src/subscription.ts
··· 6 6 import { FirehoseSubscriptionBase, getOpsByType } from './util/subscription' 7 7 8 8 export class FirehoseSubscription extends FirehoseSubscriptionBase { 9 + isAlice(alices, did) { 10 + return alices.find((alice) => alice.did === did) 11 + } 12 + 9 13 async handleEvent(evt: RepoEvent, agent: AtpAgent) { 10 14 if (!isCommit(evt)) return 11 15 const ops = await getOpsByType(evt) 12 - const allice = await this.db.selectFrom('alice').select('did').execute() 13 - // console.log('❤️❤️❤️ ALICE DIDS ❤️❤️❤️', allice) 14 - const postsToDelete = ops.posts.deletes.map((del) => del.uri) 16 + const alices = await this.db.selectFrom('alice').select('did').execute() 17 + // console.log('❤️❤️❤️ ALICE DIDS ❤️❤️❤️', alices) 18 + const postsToDelete = ops.posts.deletes 19 + .map((del) => ({ 20 + uri: del.uri, 21 + author: del.uri.split('/')[2], 22 + })) 23 + .filter((del) => this.isAlice(alices, del.author)) 24 + .map((del) => del.uri) 15 25 const postsToCreate = ops.posts.creates 16 - .filter((create) => { 17 - // only alice posts 18 - return allice.find((alice) => alice.did === create.author) 19 - }) 26 + .filter((create) => this.isAlice(alices, create.author)) 20 27 .map((create) => { 21 - // map alice-related posts to a db row 22 28 return { 23 29 uri: create.uri, 24 30 cid: create.cid, ··· 28 34 } 29 35 }) 30 36 31 - const repostsToDelete = ops.reposts.deletes.map((del) => del.uri) 32 - const repostsToCreate = ops.reposts.creates 33 - .filter((create) => { 34 - // only alice posts 35 - return allice.find((alice) => alice.did === create.author) 36 - }) 37 - .map((create) => { 38 - // map alice-related posts to a db row 39 - return { 40 - uri: create.uri, 41 - cid: create.cid, 42 - indexedAt: new Date().toISOString(), 43 - } 44 - }) 37 + // const repostsToDelete = ops.reposts.deletes.map((del) => del.uri) 38 + // const repostsToCreate = ops.reposts.creates 39 + // .filter((create) => { 40 + // // only alice posts 41 + // return alices.find((alice) => alice.did === create.author) 42 + // }) 43 + // .map((create) => { 44 + // // map alice-related posts to a db row 45 + // return { 46 + // uri: create.uri, 47 + // cid: create.cid, 48 + // indexedAt: new Date().toISOString(), 49 + // } 50 + // }) 45 51 46 52 if (postsToDelete.length > 0) { 53 + console.log('🗑️ new deletes 🗑️: ', postsToDelete) 47 54 await this.db 48 55 .deleteFrom('post') 49 56 .where('uri', 'in', postsToDelete) 50 57 .execute() 51 - console.log('🗑️ new deletes 🗑️') 52 58 } 53 59 if (postsToCreate.length > 0) { 60 + console.log('❗️ new posts ❗️: ', postsToCreate) 54 61 await this.db 55 62 .insertInto('post') 56 63 .values(postsToCreate) 57 64 .onConflict((oc) => oc.doNothing()) 58 65 .execute() 59 - console.log('❗️ new posts ❗️') 60 66 } 61 67 62 - if (repostsToDelete.length > 0) { 63 - try { 64 - await this.db 65 - .deleteFrom('repost') 66 - .where('uri', 'in', repostsToDelete) 67 - .execute() 68 - } catch (e) { 69 - console.log( 70 - "delete failed for whatever reason it's fine:", 71 - repostsToDelete, 72 - ) 73 - } 74 - } 75 - if (repostsToCreate.length > 0) { 76 - await this.db 77 - .insertInto('repost') 78 - .values(repostsToCreate) 79 - .onConflict((oc) => oc.doNothing()) 80 - .execute() 81 - } 68 + // if (repostsToDelete.length > 0) { 69 + // try { 70 + // await this.db 71 + // .deleteFrom('repost') 72 + // .where('uri', 'in', repostsToDelete) 73 + // .execute() 74 + // } catch (e) { 75 + // console.log( 76 + // "delete failed for whatever reason it's fine:", 77 + // repostsToDelete, 78 + // ) 79 + // } 80 + // } 81 + // if (repostsToCreate.length > 0) { 82 + // await this.db 83 + // .insertInto('repost') 84 + // .values(repostsToCreate) 85 + // .onConflict((oc) => oc.doNothing()) 86 + // .execute() 87 + // } 82 88 83 89 ops.posts.creates.forEach(async (create) => { 84 90 const user = await this.db