8000 fix(columns): validate required inputs in linkedin, bluesky, mastodon, youtube by aaronjmars · Pull Request #79 · aeonfun/minitor · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/columns/plugins/bluesky/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ const fetch: ServerFetcher<BlueskyConfig, BlueskyMeta> = async (
config,
cursor,
) => {
if (config.mode === "author") {
if (!config.handle.trim()) throw new Error("Author handle is required.");
} else if (!config.query.trim()) {
throw new Error("Search query is required.");
}

const r = await fetchBlueskyPage(
config.mode,
config.query,
Expand Down
5 changes: 4 additions & 1 deletion lib/columns/plugins/linkedin/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ const fetch: ServerFetcher<LinkedinConfig, LinkedinMeta> = async (
config,
cursor,
) => {
const q = config.query.trim();
if (!q) throw new Error("Search query is required.");

const items = (await searchLinkedinPosts(
config.query,
q,
30,
)) as FeedItem<LinkedinMeta>[];
return sliceForPage(items, cursor);
Expand Down
6 changes: 6 additions & 0 deletions lib/columns/plugins/mastodon/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const fetch: ServerFetcher<MastodonConfig, MastodonMeta> = async (
config,
cursor,
) => {
if (config.mode === "author") {
if (!config.handle.trim()) throw new Error("Author handle is required.");
} else if (!config.query.trim()) {
throw new Error("Hashtag is required.");
}

const items =
config.mode === "author"
? await fetchMastodonAuthor(config.instance, config.handle, 30)
Expand Down
5 changes: 5 additions & 0 deletions lib/columns/plugins/youtube/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { meta, type YTConfig, type YTMeta } from "./plugin";

const fetch: ServerFetcher<YTConfig, YTMeta> = async (config, cursor) => {
if (config.mode === "search") {
if (!config.query.trim()) throw new Error("Search query is required.");
const r = await fetchYouTubeSearchPage(
config.query,
config.order,
Expand All @@ -25,6 +26,10 @@ const fetch: ServerFetcher<YTConfig, YTMeta> = async (config, cursor) => {
nextCursor: r.nextPageToken,
};
}
if (config.mode === "channel" && !config.channel.trim())
throw new Error("Channel handle or ID is required.");
if (config.mode === "playlist" && !config.playlist.trim())
throw new Error("Playlist ID is required.");
const items = (await fetchYouTube(config.mode, {
query: config.query,
order: config.order,
Expand Down
0