-
Notifications
You must be signed in to change notification settings - Fork 370
Add /feed urls to home, profile, community, and multicommunity. #3767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
1bfc4f4
be08e42
156bf58
c6e2c6e
6b9b0ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- You can now go to any of the above pages, add `/feed` to the url, and it will redirect to the correct back-end lemmy rss feed. - Fixes #3215
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { communityRSSUrlLocal } from "@utils/app"; | ||
| import type { Request, Response } from "express"; | ||
|
|
||
| export default async (req: Request, res: Response) => { | ||
| const name = req.params.name; | ||
| res.redirect(communityRSSUrlLocal(name)); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { localRSSUrl } from "@utils/app"; | ||
| import type { Response } from "express"; | ||
|
|
||
| export default async ({ res }: { res: Response }) => { | ||
| res.redirect(localRSSUrl()); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { multiCommunityRSSUrlLocal } from "@utils/app"; | ||
| import type { Request, Response } from "express"; | ||
|
|
||
| export default async (req: Request, res: Response) => { | ||
| const name = req.params.name; | ||
| res.redirect(multiCommunityRSSUrlLocal(name)); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { profileRSSUrl } from "@utils/app"; | ||
| import type { Request, Response } from "express"; | ||
|
|
||
| export default async (req: Request, res: Response) => { | ||
| const name = req.params.name; | ||
| res.redirect(profileRSSUrl(name)); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ import { | |
| PostListingMode, | ||
| MultiCommunity, | ||
| MultiCommunityView, | ||
| SearchSortType, | ||
| } from "lemmy-js-client"; | ||
| import { | ||
| CommentNodeI, | ||
|
|
@@ -132,7 +133,10 @@ export function commentToFlatNode(cv: CommentView): CommentNodeType { | |
| return { view: { comment_view: cv, children: [], depth: 0 } }; | ||
| } | ||
|
|
||
| export function communityRSSUrl(community: Community, sort: string): string { | ||
| export function communityRSSUrl( | ||
| community: Community, | ||
| sort: PostSortType = "new", | ||
| ): string { | ||
| // Only add the domain for non-local | ||
| const domain = community.local ? "" : `@${hostname(community.ap_id)}`; | ||
|
|
||
|
|
@@ -141,9 +145,14 @@ export function communityRSSUrl(community: Community, sort: string): string { | |
| ); | ||
| } | ||
|
|
||
| /** This is used for the /c/:name/feed endpoint only. **/ | ||
| export function communityRSSUrlLocal(communityName: string) { | ||
| return httpBackendUrl(`/feeds/c/${communityName}.xml`); | ||
| } | ||
|
|
||
| export function multiCommunityRSSUrl( | ||
| multiCommunity: MultiCommunity, | ||
| sort: string, | ||
| sort: PostSortType = "new", | ||
| ): string { | ||
| // Only add the domain for non-local | ||
| const domain = multiCommunity.local | ||
|
|
@@ -153,6 +162,37 @@ export function multiCommunityRSSUrl( | |
| return `/feeds/m/${multiCommunity.name}${domain}.xml${getQueryString({ sort })}`; | ||
| } | ||
|
|
||
| /** This is used for the /m/:name/feed endpoint only. **/ | ||
| export function multiCommunityRSSUrlLocal(multiCommunityName: string) { | ||
| return httpBackendUrl(`/feeds/m/${multiCommunityName}.xml`); | ||
| } | ||
|
|
||
| export function allRSSUrl(queryString: string = ""): string { | ||
| return httpBackendUrl("/feeds/all.xml" + queryString); | ||
| } | ||
|
|
||
| export function localRSSUrl(queryString: string = ""): string { | ||
| return httpBackendUrl("/feeds/local.xml" + queryString); | ||
| } | ||
|
|
||
| export function subscribedRSSUrl( | ||
| auth: string, | ||
| queryString: string = "", | ||
| ): string { | ||
| return httpBackendUrl(`/feeds/front/${auth}.xml${queryString}`); | ||
| } | ||
|
|
||
| export function profileRSSUrl( | ||
| username: string, | ||
| sort: SearchSortType = "new", | ||
| ): string { | ||
| return httpBackendUrl(`/feeds/u/${username}.xml${getQueryString({ sort })}`); | ||
| } | ||
|
|
||
| export function notificationsRSSUrl(auth: string): string { | ||
| return httpBackendUrl(`/feeds/notifications/${auth}.xml`); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to define all this directly in the handler file, then its all in one place, easy to find and its not in the way here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of them are used elsewhere, and not used by the feed handler. So I wanted to keep all the RSS shortcuts together in one place. |
||
|
|
||
| export async function communitySearch( | ||
| text: string, | ||
| ): Promise<CommunityTribute[]> { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to make a separate file for each of these, just use
src/server/handlers/feed-handlers.tsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K, will do shortly.