Skip to content

Commit

Permalink
Use proper inheritance for BlueskyUser type to Rss
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Nov 20, 2024
1 parent 87a5ef0 commit 5954f33
Showing 1 changed file with 8 additions and 42 deletions.
50 changes: 8 additions & 42 deletions src/DataSource/BlueskyUser.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import path from "node:path";
import { DataSource } from "../DataSource.js";
import { Rss } from "./Rss.js";

class BlueskyUser extends DataSource {
class BlueskyUser extends Rss {
static TYPE = "bluesky";
static TYPE_FRIENDLY = "Bluesky";

#username;

constructor(username) {
super();
super(`https://bsky.app/profile/${username}/rss`);
this.username = username;
}

Expand All @@ -24,52 +24,18 @@ class BlueskyUser extends DataSource {
return this.#username;
}

getType() {
return "xml";
}

getUrl() {
return `https://bsky.app/profile/${this.username}/rss`
}

getEntriesFromData(data) {
if(Array.isArray(data.rss?.channel?.item)) {
return data.rss.channel.item;
}

if(data.rss?.channel?.item) {
return [data.rss.channel.item];
}

return [];
}

getUniqueIdFromEntry(entry) {
return `${DataSource.UUID_PREFIX}::${BlueskyUser.TYPE}::${entry.link}`;
}

static getFilePath(url) {
let {pathname} = new URL(url);
let [empty, profile, username, post, id] = pathname.split("/");
return path.join(username, id);
}

cleanEntry(entry, data) {
return {
uuid: this.getUniqueIdFromEntry(entry),
type: BlueskyUser.TYPE,
title: this.toReadableDate(entry.pubDate),
url: entry.link,
authors: [
{
name: data.rss.channel.title,
url: data.rss.channel.link,
}
],
date: this.toIsoDate(entry.pubDate),
content: entry.description,
contentType: "text",
}
let obj = super.cleanEntry(entry, data);
obj.type = BlueskyUser.TYPE;
obj.contentType = "text";

return obj;
}
}

Expand Down

0 comments on commit 5954f33

Please sign in to comment.