Skip to content

Commit

Permalink
fix(route): filter out invalid subscriptions (#17861)
Browse files Browse the repository at this point in the history
  • Loading branch information
KarasuShin authored Dec 11, 2024
1 parent ab760e9 commit a49355b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/routes/follow/profile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ViewType, type Data, type Route } from '@/types';
import type { Context } from 'hono';
import ofetch from '@/utils/ofetch';
import type { FollowResponse, InboxSubscription, ListSubscription, Profile, Subscription } from './types';
import type { FeedSubscription, FollowResponse, InboxSubscription, ListSubscription, Profile, Subscription } from './types';
import { parse } from 'tldts';

export const route: Route = {
Expand Down Expand Up @@ -30,6 +30,8 @@ const isList = (subscription: Subscription): subscription is ListSubscription =>

const isInbox = (subscription: Subscription): subscription is InboxSubscription => 'inboxId' in subscription;

const isFeed = (subscription: Subscription): subscription is FeedSubscription => 'feeds' in subscription;

async function handler(ctx: Context): Promise<Data> {
const handleOrId = ctx.req.param('uid');
const host = 'https://api.follow.is';
Expand All @@ -47,7 +49,7 @@ async function handler(ctx: Context): Promise<Data> {

return {
title: `${profile.data.name}'s subscriptions`,
item: (<Exclude<Subscription, InboxSubscription>[]>subscriptions.data.filter((i) => !isInbox(i))).map((subscription) => {
item: (<Exclude<Subscription, InboxSubscription>[]>subscriptions.data.filter((i) => !isInbox(i) && !(isFeed(i) && !!i.feeds.errorAt))).map((subscription) => {
if (isList(subscription)) {
return {
title: subscription.lists.title,
Expand Down

0 comments on commit a49355b

Please sign in to comment.