Merge pull request #1428 from automatisch/AUT-398
feat(reddit): add create link post action
This commit is contained in:
@@ -0,0 +1,53 @@
|
|||||||
|
import defineAction from '../../../../helpers/define-action';
|
||||||
|
import { URLSearchParams } from 'url';
|
||||||
|
|
||||||
|
export default defineAction({
|
||||||
|
name: 'Create link post',
|
||||||
|
key: 'createLinkPost',
|
||||||
|
description: 'Create a new link post within a subreddit.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Title',
|
||||||
|
key: 'title',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
description:
|
||||||
|
'Heading for the recent post. Limited to 300 characters or less.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Subreddit',
|
||||||
|
key: 'subreddit',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
description: 'The subreddit for posting. Note: Exclude /r/.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Url',
|
||||||
|
key: 'url',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const { title, subreddit, url } = $.step.parameters;
|
||||||
|
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
kind: 'link',
|
||||||
|
api_type: 'json',
|
||||||
|
title: title as string,
|
||||||
|
sr: subreddit as string,
|
||||||
|
url: url as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { data } = await $.http.post('/api/submit', params.toString());
|
||||||
|
|
||||||
|
$.setActionItem({
|
||||||
|
raw: data,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
3
packages/backend/src/apps/reddit/actions/index.ts
Normal file
3
packages/backend/src/apps/reddit/actions/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import createLinkPost from './create-link-post';
|
||||||
|
|
||||||
|
export default [createLinkPost];
|
@@ -2,6 +2,7 @@ import defineApp from '../../helpers/define-app';
|
|||||||
import addAuthHeader from './common/add-auth-header';
|
import addAuthHeader from './common/add-auth-header';
|
||||||
import auth from './auth';
|
import auth from './auth';
|
||||||
import triggers from './triggers';
|
import triggers from './triggers';
|
||||||
|
import actions from './actions';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'Reddit',
|
name: 'Reddit',
|
||||||
@@ -15,4 +16,5 @@ export default defineApp({
|
|||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
triggers,
|
triggers,
|
||||||
|
actions,
|
||||||
});
|
});
|
||||||
|
@@ -295,6 +295,7 @@ export default defineConfig({
|
|||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [
|
items: [
|
||||||
{ text: 'Triggers', link: '/apps/reddit/triggers' },
|
{ text: 'Triggers', link: '/apps/reddit/triggers' },
|
||||||
|
{ text: 'Actions', link: '/apps/reddit/actions' },
|
||||||
{ text: 'Connection', link: '/apps/reddit/connection' },
|
{ text: 'Connection', link: '/apps/reddit/connection' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
12
packages/docs/pages/apps/reddit/actions.md
Normal file
12
packages/docs/pages/apps/reddit/actions.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/reddit.svg
|
||||||
|
items:
|
||||||
|
- name: Create link post
|
||||||
|
desc: Create a new link post within a subreddit.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
Reference in New Issue
Block a user