diff --git a/components/reddit/actions/list-comments-in-a-post/list-comments-in-a-post.mjs b/components/reddit/actions/list-comments-in-a-post/list-comments-in-a-post.mjs index 82a112387a7e1..7443cd2f61eb0 100644 --- a/components/reddit/actions/list-comments-in-a-post/list-comments-in-a-post.mjs +++ b/components/reddit/actions/list-comments-in-a-post/list-comments-in-a-post.mjs @@ -1,10 +1,10 @@ -import reddit from "../../reddit.app.mjs"; import { axios } from "@pipedream/platform"; +import reddit from "../../reddit.app.mjs"; export default { type: "action", key: "reddit-list-comments-in-a-post", - version: "0.1.1", + version: "0.1.2", name: "List Comments in a Post", description: "List comments for a specific post. [See the docs here](https://www.reddit.com/dev/api/#GET_comments_{article})", props: { diff --git a/components/reddit/actions/list-subreddits-by-query/list-subreddits-by-query.mjs b/components/reddit/actions/list-subreddits-by-query/list-subreddits-by-query.mjs index 8a741749a595b..3321da3d814d2 100644 --- a/components/reddit/actions/list-subreddits-by-query/list-subreddits-by-query.mjs +++ b/components/reddit/actions/list-subreddits-by-query/list-subreddits-by-query.mjs @@ -1,10 +1,10 @@ -import reddit from "../../reddit.app.mjs"; import { axios } from "@pipedream/platform"; +import reddit from "../../reddit.app.mjs"; export default { type: "action", key: "reddit-list-subreddits-by-query", - version: "0.1.1", + version: "0.1.2", name: "List Subreddits by Query", description: "List subreddits based on a search criteria. [See the docs here](https://www.reddit.com/dev/api/#GET_subreddits_search)", props: { diff --git a/components/reddit/actions/search-post/search-post.mjs b/components/reddit/actions/search-post/search-post.mjs index 188f6cf11bef4..d533e322b1eed 100644 --- a/components/reddit/actions/search-post/search-post.mjs +++ b/components/reddit/actions/search-post/search-post.mjs @@ -3,7 +3,7 @@ import reddit from "../../reddit.app.mjs"; export default { type: "action", key: "reddit-search-post", - version: "0.1.1", + version: "0.1.2", name: "Search Post", description: "Search posts by title. [See the docs here](https://www.reddit.com/dev/api/#GET_search)", props: { diff --git a/components/reddit/actions/submit-a-comment/submit-a-comment.mjs b/components/reddit/actions/submit-a-comment/submit-a-comment.mjs index f225b582f7c32..bd5f391600a73 100644 --- a/components/reddit/actions/submit-a-comment/submit-a-comment.mjs +++ b/components/reddit/actions/submit-a-comment/submit-a-comment.mjs @@ -4,7 +4,7 @@ import reddit from "../../reddit.app.mjs"; export default { type: "action", key: "reddit-submit-a-comment", - version: "0.1.1", + version: "0.1.2", name: "Submit a Comment", description: "Submit a new comment or reply to a message. [See the docs here](https://www.reddit.com/dev/api/#POST_api_comment)", props: { diff --git a/components/reddit/actions/submit-a-post/submit-a-post.mjs b/components/reddit/actions/submit-a-post/submit-a-post.mjs index 71ff0f1eccf38..a697f0e1f3aea 100644 --- a/components/reddit/actions/submit-a-post/submit-a-post.mjs +++ b/components/reddit/actions/submit-a-post/submit-a-post.mjs @@ -1,11 +1,11 @@ import { axios } from "@pipedream/platform"; -import reddit from "../../reddit.app.mjs"; import tzs from "../../pytz-timezones.mjs"; +import reddit from "../../reddit.app.mjs"; export default { type: "action", key: "reddit-submit-a-post", - version: "0.1.1", + version: "0.1.2", name: "Submit a Post", description: "Create a post to a subreddit. [See the docs here](https://www.reddit.com/dev/api/#POST_api_submit)", props: { diff --git a/components/reddit/package.json b/components/reddit/package.json index 47c6810321ad0..b56a06d0fee08 100644 --- a/components/reddit/package.json +++ b/components/reddit/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/reddit", - "version": "1.1.3", + "version": "1.2.0", "description": "Pipedream Reddit Components", "main": "reddit.app.mjs", "keywords": [ @@ -13,7 +13,7 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^1.4.0", + "@pipedream/platform": "^3.1.0", "async-retry": "^1.3.3", "axios": "^0.27.2", "lodash": "^4.17.21", diff --git a/components/reddit/reddit.app.mjs b/components/reddit/reddit.app.mjs index fa40b50630fd1..f830f1f1f34a5 100644 --- a/components/reddit/reddit.app.mjs +++ b/components/reddit/reddit.app.mjs @@ -1,8 +1,8 @@ import { axios } from "@pipedream/platform"; -import qs from "qs"; -import isNil from "lodash/isNil.js"; import retry from "async-retry"; import get from "lodash/get.js"; +import isNil from "lodash/isNil.js"; +import qs from "qs"; export default { type: "app", @@ -490,5 +490,12 @@ export default { }, })); }, + getPrivateMessages(opts = { }) { + return this._withRetries(() => + this._makeRequest({ + path: "/message/inbox", + ...opts, + })); + }, }, }; diff --git a/components/reddit/sources/new-comments-by-user/new-comments-by-user.mjs b/components/reddit/sources/new-comments-by-user/new-comments-by-user.mjs index f4c0fb4012f38..41c69feb3b77b 100644 --- a/components/reddit/sources/new-comments-by-user/new-comments-by-user.mjs +++ b/components/reddit/sources/new-comments-by-user/new-comments-by-user.mjs @@ -7,7 +7,7 @@ export default { key: "reddit-new-comments-by-user", name: "New Comments by User", description: "Emit new event each time a user posts a new comment.", - version: "0.1.1", + version: "0.1.2", dedupe: "unique", props: { ...common.props, diff --git a/components/reddit/sources/new-comments-on-a-post/new-comments-on-a-post.mjs b/components/reddit/sources/new-comments-on-a-post/new-comments-on-a-post.mjs index 0eae1a98c9f97..141d4441b1b82 100644 --- a/components/reddit/sources/new-comments-on-a-post/new-comments-on-a-post.mjs +++ b/components/reddit/sources/new-comments-on-a-post/new-comments-on-a-post.mjs @@ -1,5 +1,5 @@ -import common from "../common.mjs"; import get from "lodash/get.js"; +import common from "../common.mjs"; const { reddit } = common.props; export default { @@ -9,7 +9,7 @@ export default { name: "New comments on a post", description: "Emit new event each time a new comment is added to a subreddit.", - version: "0.1.1", + version: "0.1.2", dedupe: "unique", props: { ...common.props, diff --git a/components/reddit/sources/new-hot-posts-on-a-subreddit/new-hot-posts-on-a-subreddit.mjs b/components/reddit/sources/new-hot-posts-on-a-subreddit/new-hot-posts-on-a-subreddit.mjs index 3ef6d77c221d3..eb621670cd050 100644 --- a/components/reddit/sources/new-hot-posts-on-a-subreddit/new-hot-posts-on-a-subreddit.mjs +++ b/components/reddit/sources/new-hot-posts-on-a-subreddit/new-hot-posts-on-a-subreddit.mjs @@ -1,7 +1,7 @@ +import get from "lodash/get.js"; import common from "../common.mjs"; -import sampleEmit from "./test-event.mjs"; import regionData from "./region-data.mjs"; -import get from "lodash/get.js"; +import sampleEmit from "./test-event.mjs"; const { reddit } = common.props; export default { @@ -11,7 +11,7 @@ export default { name: "New hot posts on a subreddit", description: "Emit new event each time a new hot post is added to the top 10 items in a subreddit.", - version: "0.2.2", + version: "0.2.3", dedupe: "unique", props: { ...common.props, diff --git a/components/reddit/sources/new-links-by-user/new-links-by-user.mjs b/components/reddit/sources/new-links-by-user/new-links-by-user.mjs index 6c6a8423c0d3a..80dc985f30587 100644 --- a/components/reddit/sources/new-links-by-user/new-links-by-user.mjs +++ b/components/reddit/sources/new-links-by-user/new-links-by-user.mjs @@ -7,7 +7,7 @@ export default { key: "reddit-new-links-by-user", name: "New Links by User", description: "Emit new event each time a user posts a new link.", - version: "0.1.1", + version: "0.1.2", dedupe: "unique", props: { ...common.props, diff --git a/components/reddit/sources/new-links-on-a-subreddit/new-links-on-a-subreddit.mjs b/components/reddit/sources/new-links-on-a-subreddit/new-links-on-a-subreddit.mjs index 8f426fed06631..eb2027e1b53d6 100644 --- a/components/reddit/sources/new-links-on-a-subreddit/new-links-on-a-subreddit.mjs +++ b/components/reddit/sources/new-links-on-a-subreddit/new-links-on-a-subreddit.mjs @@ -1,5 +1,5 @@ -import common from "../common.mjs"; import get from "lodash/get.js"; +import common from "../common.mjs"; const { reddit } = common.props; export default { @@ -8,7 +8,7 @@ export default { key: "reddit-new-links-on-a-subreddit", name: "New Links on a Subreddit", description: "Emit new event each time a new link is added to a subreddit", - version: "0.1.1", + version: "0.1.2", dedupe: "unique", props: { ...common.props, diff --git a/components/reddit/sources/new-private-message/new-private-message.mjs b/components/reddit/sources/new-private-message/new-private-message.mjs new file mode 100644 index 0000000000000..2de054f424eea --- /dev/null +++ b/components/reddit/sources/new-private-message/new-private-message.mjs @@ -0,0 +1,64 @@ +import common from "../common.mjs"; + +export default { + ...common, + type: "source", + key: "reddit-new-private-message", + name: "New Private Message", + description: "Emit new event each time you receive a new private message.", + version: "0.0.1", + dedupe: "unique", + hooks: { + async deploy() { + // Emits sample events on the first run during deploy. + var privateMessages = await this.reddit.getPrivateMessages({ + params: { + limit: 20, + }, + }); + + let { children: messages = [] } = privateMessages.data; + if (messages.length === 0) { + console.log("No data available, skipping iteration"); + return; + } + + const { id = this._getBefore() } = messages[0].data; + this._setBefore(id); + messages.reverse().forEach(this.emitRedditEvent); + }, + }, + methods: { + ...common.methods, + generateEventMetadata(redditEvent) { + return { + id: redditEvent.data.id, + summary: redditEvent.data.body, + ts: redditEvent.data.created, + }; + }, + }, + async run() { + let privateMessages; + do { + privateMessages = await this.reddit.getPrivateMessages({ + params: { + before: `t4_${this._getBefore()}`, + limit: 2, + }, + }); + + const { children: messages = [] } = privateMessages.data; + if (messages.length === 0) { + console.log("No data available, skipping iteration"); + break; + } + const { id } = messages[0].data; + this._setBefore(id); + + messages.reverse().forEach((message) => { + this.emitRedditEvent(message); + }); + } while (privateMessages); + }, +}; diff --git a/components/reddit/sources/new-saved-post-by-user/new-saved-post-by-user.mjs b/components/reddit/sources/new-saved-post-by-user/new-saved-post-by-user.mjs index dc8111d88afa7..1cb5eb18020c1 100644 --- a/components/reddit/sources/new-saved-post-by-user/new-saved-post-by-user.mjs +++ b/components/reddit/sources/new-saved-post-by-user/new-saved-post-by-user.mjs @@ -7,7 +7,7 @@ export default { key: "reddit-new-saved-post-by-user", name: "New Saved Post by User", description: "Emit new event each time a user saves a post.", - version: "0.1.2", + version: "0.1.3", dedupe: "unique", props: { ...common.props, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fc97dde92332f..b9df63de43d68 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1575,8 +1575,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/bitget: - specifiers: {} + components/bitget: {} components/bitly: dependencies: @@ -6905,8 +6904,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/joggai: - specifiers: {} + components/joggai: {} components/join: {} @@ -11037,8 +11035,8 @@ importers: components/reddit: dependencies: '@pipedream/platform': - specifier: ^1.4.0 - version: 1.6.6 + specifier: ^3.1.0 + version: 3.1.0 async-retry: specifier: ^1.3.3 version: 1.3.3