diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..5e218ef --- /dev/null +++ b/.env.sample @@ -0,0 +1,16 @@ +POCKET_BASE_PW=xxxxxxxx +POCKET_BASE_USER=micro_blog_fetchers +POCKET_BASE_HOST=https://pocketbase.test.com + +BLUE_SKY_API_KEY=xxxx-xxxx-xxxx-xxxx +BLUE_SKY_USERNAME=johndoe.bsky.social + +MASTODON_BASE_URL=https://mastodon.social +MASTODON_ACCOUNT_ID=111111111111111111 + +PIXELFED_BASE_URL=https://pics.social/api/pixelfed/v1/accounts/ +PIXELFED_ACCOUNT_ID=111111111111111111 + +NOSTR_FETCHER_NPUB=npub1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +NOSTR_ID=5e3xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +NOSTR_RELAY=wss://relay.test.com diff --git a/README.md b/README.md index a1108b6..93ecb33 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,15 @@ # Micro Blog Repo Fetchers -The Micro Blog Repo is made up of a PocketBase db and these lambda functions. Together they aggregate, backup, and make my various social media posts available to my personal site. +The Micro Blog Repo is a personal project of mine to aggregate, backup, and make +my various social media posts. It is made up of a self-hosted [PocketBase](https://pocketbase.io/) +and these lambda function. ## Progress -- [X] [BlueSky](https://bsky.app/profile/travisshears.bsky.social) -- [ ] Old Pleroma formally social.travisshears.xyz - - [ ] Video support - - [X] Post support - - [X] Post with image support -- [X] [Pixelfed via gram.social](https://gram.social/i/web/profile/703621281309160235) -- [X] [Mastodon via dice.camp](https://dice.camp/@travisshears) -- [X] [Nostr profile1qqs9....](https://snort.social/nprofile1qqs9udcv9uhqggjz87js9rtaph4lajlxnxsvwvm7zwdjt6etzyk52rgpypmhxue69uhkummnw3ezuetfde6kuer6wasku7nfvuh8xurpvdjj7qgkwaehxw309ajkgetw9ehx7um5wghxcctwvshszrnhwden5te0dehhxtnvdakz7z94haj) +- [X] BlueSky +- [X] Pixelfed +- [X] Mastodon +- [X] Nostr ## Deployment diff --git a/serverless.yml b/serverless.yml index 29b586f..d41b748 100644 --- a/serverless.yml +++ b/serverless.yml @@ -15,6 +15,14 @@ provider: POCKET_BASE_USER: ${env:POCKET_BASE_USER} BLUE_SKY_API_KEY: ${env:BLUE_SKY_API_KEY} BLUE_SKY_USERNAME: ${env:BLUE_SKY_USERNAME} + POCKET_BASE_HOST: ${env:POCKET_BASE_HOST} + MASTODON_BASE_URL: ${env:MASTODON_BASE_URL} + MASTODON_ACCOUNT_ID: ${env:MASTODON_ACCOUNT_ID} + PIXELFED_BASE_URL: ${env:PIXELFED_BASE_URL} + PIXELFED_ACCOUNT_ID: ${env:PIXELFED_ACCOUNT_ID} + NOSTR_FETCHER_NPUB: ${env:NOSTR_FETCHER_NPUB} + NOSTR_ID: ${env:NOSTR_ID} + NOSTR_RELAY: ${env:NOSTR_RELAY} functions: nostr: diff --git a/src/mastodon.ts b/src/mastodon.ts index 802983e..63d13c6 100644 --- a/src/mastodon.ts +++ b/src/mastodon.ts @@ -9,9 +9,8 @@ const withRequest = lambdaRequestTracker(); const pb = new MicroBlogBackend(logger); -const baseURL = "https://dice.camp"; -const accountId = "112364858295724350"; -const username = "travisshears"; +const baseURL = process.env.MASTODON_BASE_URL; +const accountId = process.env.MASTODON_ACCOUNT_ID; type MastodonPost = { media_attachments: { diff --git a/src/nostr.ts b/src/nostr.ts index 8fcee7c..d2b5538 100644 --- a/src/nostr.ts +++ b/src/nostr.ts @@ -10,10 +10,8 @@ const withRequest = lambdaRequestTracker(); const pb = new MicroBlogBackend(logger); -const fetcherNpub = - "npub1qqqqqqp350slvdds7028l4yre5cuh8v38zseert25mxf7lkr2trsy0j2m8"; -const myNpub = - "5e370c2f2e0422423fa5028d7d0debfecbe699a0c7337e139b25eb2b112d450d"; +const fetcherNpub = process.env.NOSTR_FETCHER_NPUB!; +const myNpub = process.env.NOSTR_ID!; type NostrTag = ["t" | "r" | "imeta", string]; type NostrEvent = [ @@ -42,7 +40,7 @@ exports.run = async (event: any, context: any) => { } // listen for new events for 30 seconds logger.info("trying to connecting to nostr relay"); - const ws = new WebSocket("wss://travis-shears-nostr-relay-v2.fly.dev/"); + const ws = new WebSocket(process.env.NOSTR_RELAY!); // Other Relay URLs // "wss://nos.lol", // "wss://nostr.wine", diff --git a/src/pixelfed.ts b/src/pixelfed.ts index 0d13e19..a2ce146 100644 --- a/src/pixelfed.ts +++ b/src/pixelfed.ts @@ -7,8 +7,8 @@ const destination = pinoLambdaDestination(); const logger = pino({}, destination); const withRequest = lambdaRequestTracker(); -const baseURL = `https://gram.social/api/pixelfed/v1/accounts/`; -const accountID = `703621281309160235`; +const baseURL = process.env.PIXELFED_BASE_URL; +const accountID = process.env.PIXELFED_ACCOUNT_ID; const pb = new MicroBlogBackend(logger); diff --git a/src/pocketbase.ts b/src/pocketbase.ts index 8ef275e..f6d4f5f 100644 --- a/src/pocketbase.ts +++ b/src/pocketbase.ts @@ -40,7 +40,7 @@ export class MicroBlogBackend { private pb: PocketBase; private clientSetTime?: Date; constructor(private logger: Logger) { - this.pb = new PocketBase("https://personal-pocket-base.fly.dev"); + this.pb = new PocketBase(process.env.POCKET_BASE_HOST); } private async login() {