Skip to content

Commit

Permalink
fix(bluesky): use provided users did instead of hard coded one
Browse files Browse the repository at this point in the history
  • Loading branch information
async3619 committed Jul 3, 2023
1 parent 66b3379 commit f3ec641
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/watchers/bluesky/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface BlueSkyWatcherOptions extends BaseWatcherOptions<BlueSkyWatcher

export class BlueSkyWatcher extends BaseWatcher<"BlueSky"> {
private agent: BskyAgent | null = null;
private userId: string | null = null;

constructor(private readonly options: BlueSkyWatcherOptions) {
super("BlueSky");
Expand All @@ -18,22 +19,24 @@ export class BlueSkyWatcher extends BaseWatcher<"BlueSky"> {
public async initialize(): Promise<void> {
this.agent = new BskyAgent({ service: this.options.service || "https://bsky.social" });

await this.agent.login({
const response = await this.agent.login({
identifier: this.options.email,
password: this.options.password,
});

this.userId = response.data.did;
}

protected async getFollowers(): Promise<PartialUser[]> {
if (!this.agent) {
if (!this.agent || !this.userId) {
throw new Error("Bluesky watcher has not initialized");
}

let cursor: string | undefined;
let cursor: string | undefined = undefined;
const result: PartialUser[] = [];
while (true) {
const { data } = await this.agent.getFollowers({
actor: "lunamoth.bsky.social",
actor: this.userId,
limit: 100,
cursor,
});
Expand Down

0 comments on commit f3ec641

Please sign in to comment.