-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(route): follow * add link * use profile instead of subscriptions * change the feed title
- Loading branch information
1 parent
69745ad
commit 7a18fb2
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'Follow', | ||
url: 'app.follow.is', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { Data, Route } from '@/types'; | ||
import { Context } from 'hono'; | ||
import ofetch from '@/utils/ofetch'; | ||
import type { FollowResponse, Profile, Subscription } from './types'; | ||
|
||
export const route: Route = { | ||
name: 'User subscriptions', | ||
path: '/profile/:uid', | ||
example: '/profile/41279032429549568', | ||
radar: [ | ||
{ | ||
source: ['app.follow.is/profile/:uid'], | ||
target: '/follow/profile/:uid', | ||
}, | ||
], | ||
handler, | ||
maintainers: ['KarasuShin'], | ||
features: { | ||
supportRadar: true, | ||
}, | ||
}; | ||
|
||
async function handler(ctx: Context): Promise<Data> { | ||
const uid = ctx.req.param('uid'); | ||
const host = 'https://api.follow.is'; | ||
|
||
const [profile, subscriptions] = await Promise.all([ofetch<FollowResponse<Profile>>(`${host}/profiles?id=${uid}`), ofetch<FollowResponse<Subscription[]>>(`${host}/subscriptions?userId=${uid}`)]); | ||
|
||
return { | ||
title: `${profile.data.name} - User subscriptions`, | ||
item: subscriptions.data.map((subscription) => ({ | ||
title: subscription.feeds.title, | ||
description: subscription.feeds.description, | ||
link: `https://app.follow.is/feed/${subscription.feedId}`, | ||
})), | ||
link: `https://app.follow.is/profile/${uid}`, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export interface FollowResponse<T> { | ||
code: number; | ||
data: T; | ||
} | ||
|
||
export interface Subscription { | ||
category: string; | ||
feedId: string; | ||
feeds: { | ||
checkAt: string; | ||
description: string; | ||
errorAt: unknown; | ||
errorMessage: unknown; | ||
etagHeader: string; | ||
id: string; | ||
image: unknown; | ||
lastModifiedHeader: string; | ||
ownerUserId: string | null; | ||
siteUrl: string; | ||
title: string; | ||
ttl: number; | ||
url: string; | ||
}; | ||
isPrivate: boolean; | ||
title: string | null; | ||
userId: string; | ||
view: number; | ||
} | ||
|
||
export interface Profile { | ||
id: string; | ||
name: string; | ||
email: string; | ||
emailVerified: unknown; | ||
image: string; | ||
handle: unknown; | ||
createdAt: string; | ||
} |