A decentralized music tracking and discovery platform built on AT Protocol 馃幍 rocksky.app
spotify atproto lastfm musicbrainz scrobbling listenbrainz
96
fork

Configure Feed

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

at feat/pgpull 28 lines 744 B view raw
1import { Agent } from "@atproto/api"; 2import type { NodeOAuthClient } from "@atproto/oauth-client-node"; 3 4export async function createAgent( 5 oauthClient: NodeOAuthClient, 6 did: string, 7): Promise<Agent | null> { 8 let agent = null; 9 let retry = 0; 10 do { 11 try { 12 const oauthSession = await oauthClient.restore(did); 13 agent = oauthSession ? new Agent(oauthSession) : null; 14 if (agent === null) { 15 await new Promise((r) => setTimeout(r, 1000)); 16 retry += 1; 17 } 18 } catch (e) { 19 console.log("Error creating agent"); 20 console.log(did); 21 console.log(e); 22 await new Promise((r) => setTimeout(r, 1000)); 23 retry += 1; 24 } 25 } while (agent === null && retry < 5); 26 27 return agent; 28}