-
Notifications
You must be signed in to change notification settings - Fork 5.7k
feat(social_fetch): add 4 reddit actions #21312
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
Open
michelle0927
wants to merge
3
commits into
master
Choose a base branch
from
issue-21276-social-fetch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
38 changes: 38 additions & 0 deletions
38
components/social_fetch/actions/get-reddit-post-transcript/get-reddit-post-transcript.mjs
This file contains hidden or 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 app from "../../social_fetch.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "social_fetch-get-reddit-post-transcript", | ||
| name: "Get Reddit Post Transcript", | ||
| description: "Get the captions transcript for a Reddit video post. Use this when you need the spoken text of a Reddit-hosted video; for the post's comment thread use **List Reddit Post Comments** instead. Provide the post URL or a direct hosted video URL, and optionally a two-letter ISO 639-1 language code (e.g. `en`) to prefer a caption track when several exist. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/posts/transcript&method=GET)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| app, | ||
| url: { | ||
| propDefinition: [ | ||
| app, | ||
| "redditPostUrl", | ||
| ], | ||
| }, | ||
| language: { | ||
| propDefinition: [ | ||
| app, | ||
| "language", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.getPostTranscript({ | ||
| $, | ||
| url: this.url, | ||
| language: this.language, | ||
| }); | ||
| $.export("$summary", "Successfully fetched post transcript"); | ||
| return response; | ||
| }, | ||
| }; |
38 changes: 38 additions & 0 deletions
38
components/social_fetch/actions/get-subreddit/get-subreddit.mjs
This file contains hidden or 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 app from "../../social_fetch.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "social_fetch-get-subreddit", | ||
| name: "Get Subreddit", | ||
| description: "Get metadata for a single Reddit community — title, description, subscriber counts, and icon/banner images when available. Use this to look up details about one subreddit; to fetch its posts use **List Subreddit Posts** instead. Provide the community as a bare name (`pics`), an `r/`-prefixed name (`r/pics`), or a full subreddit URL (`https://www.reddit.com/r/pics`); casing must match Reddit exactly. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/subreddits&method=GET)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| app, | ||
| subreddit: { | ||
| propDefinition: [ | ||
| app, | ||
| "subreddit", | ||
| ], | ||
| }, | ||
| url: { | ||
| propDefinition: [ | ||
| app, | ||
| "subredditUrl", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.getSubreddit({ | ||
| $, | ||
| subreddit: this.subreddit, | ||
| url: this.url, | ||
| }); | ||
| $.export("$summary", "Successfully fetched subreddit details"); | ||
| return response; | ||
| }, | ||
| }; |
This file contains hidden or 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
This file contains hidden or 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
48 changes: 48 additions & 0 deletions
48
components/social_fetch/actions/list-reddit-post-comments/list-reddit-post-comments.mjs
This file contains hidden or 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,48 @@ | ||
| import app from "../../social_fetch.app.mjs"; | ||
| import { truncateArrays } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "social_fetch-list-reddit-post-comments", | ||
| name: "List Reddit Post Comments", | ||
| description: "List the comments and nested replies on a specific Reddit post. Use this after locating a post via **List Subreddit Posts** when you need its discussion thread. Provide the full post URL (e.g. `https://www.reddit.com/r/pics/comments/abc123/title/`). Enable **Trim** for a lighter response shape, and page through long threads with the cursor. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/posts/comments&method=GET)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| app, | ||
| url: { | ||
| propDefinition: [ | ||
| app, | ||
| "redditPostUrl", | ||
| ], | ||
| }, | ||
| trim: { | ||
| propDefinition: [ | ||
| app, | ||
| "trim", | ||
| ], | ||
| }, | ||
| cursor: { | ||
| propDefinition: [ | ||
| app, | ||
| "cursor", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const MAX_COMMENTS = 10; | ||
| const response = await this.app.listPostComments({ | ||
| $, | ||
| url: this.url, | ||
| trim: this.trim, | ||
| cursor: this.cursor, | ||
| }); | ||
| truncateArrays(response?.data, MAX_COMMENTS); | ||
| $.export("$summary", "Successfully listed post comments"); | ||
| return response; | ||
| }, | ||
| }; |
55 changes: 55 additions & 0 deletions
55
components/social_fetch/actions/list-subreddit-posts/list-subreddit-posts.mjs
This file contains hidden or 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,55 @@ | ||
| import app from "../../social_fetch.app.mjs"; | ||
| import { truncateArrays } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "social_fetch-list-subreddit-posts", | ||
| name: "List Subreddit Posts", | ||
| description: "List posts from a single subreddit, with optional sorting (`best`, `hot`, `new`, `top`, `rising`) and a timeframe for time-based sorts (`all`, `day`, `week`, `month`, `year`). Use this to browse or page through a community's feed; for details about the community itself use **Get Subreddit**, and to read a specific post's replies use **List Reddit Post Comments**. Accepts the subreddit as a bare name (`pics`), an `r/`-prefixed name (`r/pics`), or a subreddit URL. Page through results with the cursor. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/subreddits/%7Bsubreddit%7D/posts&method=GET)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| app, | ||
| subreddit: { | ||
| propDefinition: [ | ||
| app, | ||
| "subreddit", | ||
| ], | ||
| }, | ||
| sort: { | ||
| propDefinition: [ | ||
| app, | ||
| "sort", | ||
| ], | ||
| }, | ||
| timeframe: { | ||
| propDefinition: [ | ||
| app, | ||
| "timeframe", | ||
| ], | ||
| }, | ||
| cursor: { | ||
| propDefinition: [ | ||
| app, | ||
| "cursor", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const MAX_POSTS = 10; | ||
| const response = await this.app.listSubredditPosts({ | ||
| $, | ||
| subreddit: this.subreddit, | ||
| sort: this.sort, | ||
| timeframe: this.timeframe, | ||
| cursor: this.cursor, | ||
| }); | ||
| truncateArrays(response?.data, MAX_POSTS); | ||
| $.export("$summary", "Successfully listed subreddit posts"); | ||
| return response; | ||
| }, | ||
| }; |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.