feat(disqus): add new comments trigger
This commit is contained in:
3
packages/backend/src/apps/disqus/dynamic-data/index.js
Normal file
3
packages/backend/src/apps/disqus/dynamic-data/index.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import listForums from './list-forums/index.js';
|
||||||
|
|
||||||
|
export default [listForums];
|
@@ -0,0 +1,36 @@
|
|||||||
|
export default {
|
||||||
|
name: 'List forums',
|
||||||
|
key: 'listForums',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const forums = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
limit: 100,
|
||||||
|
order: 'desc',
|
||||||
|
cursor: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
let more;
|
||||||
|
do {
|
||||||
|
const { data } = await $.http.get('/3.0/users/listForums.json', {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
params.cursor = data.cursor.next;
|
||||||
|
more = data.cursor.hasNext;
|
||||||
|
|
||||||
|
if (data.response?.length) {
|
||||||
|
for (const forum of data.response) {
|
||||||
|
forums.data.push({
|
||||||
|
value: forum.id,
|
||||||
|
name: forum.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (more);
|
||||||
|
|
||||||
|
return forums;
|
||||||
|
},
|
||||||
|
};
|
@@ -1,6 +1,8 @@
|
|||||||
import defineApp from '../../helpers/define-app.js';
|
import defineApp from '../../helpers/define-app.js';
|
||||||
import addAuthHeader from './common/add-auth-header.js';
|
import addAuthHeader from './common/add-auth-header.js';
|
||||||
import auth from './auth/index.js';
|
import auth from './auth/index.js';
|
||||||
|
import dynamicData from './dynamic-data/index.js';
|
||||||
|
import triggers from './triggers/index.js';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'Disqus',
|
name: 'Disqus',
|
||||||
@@ -13,4 +15,6 @@ export default defineApp({
|
|||||||
supportsConnections: true,
|
supportsConnections: true,
|
||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
|
dynamicData,
|
||||||
|
triggers,
|
||||||
});
|
});
|
||||||
|
3
packages/backend/src/apps/disqus/triggers/index.js
Normal file
3
packages/backend/src/apps/disqus/triggers/index.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import newComments from './new-comments/index.js';
|
||||||
|
|
||||||
|
export default [newComments];
|
@@ -0,0 +1,92 @@
|
|||||||
|
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||||
|
import { URLSearchParams } from 'url';
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'New comments',
|
||||||
|
key: 'newComments',
|
||||||
|
pollInterval: 15,
|
||||||
|
description: 'Triggers when a new comment is posted in a forum using Disqus.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Post Types',
|
||||||
|
key: 'postTypes',
|
||||||
|
type: 'dynamic',
|
||||||
|
required: false,
|
||||||
|
description:
|
||||||
|
'Which posts should be considered for inclusion in the trigger?',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
label: 'Type',
|
||||||
|
key: 'type',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
options: [
|
||||||
|
{ label: 'Unapproved Posts', value: 'unapproved' },
|
||||||
|
{ label: 'Approved Posts', value: 'approved' },
|
||||||
|
{ label: 'Spam Posts', value: 'spam' },
|
||||||
|
{ label: 'Deleted Posts', value: 'deleted' },
|
||||||
|
{ label: 'Flagged Posts', value: 'flagged' },
|
||||||
|
{ label: 'Highlighted Posts', value: 'highlighted' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Forum',
|
||||||
|
key: 'forumId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
description: 'Select the forum where you want comments to be triggered.',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listForums',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const forumId = $.step.parameters.forumId;
|
||||||
|
const postTypes = $.step.parameters.postTypes;
|
||||||
|
const formattedCommentTypes = postTypes
|
||||||
|
.filter((type) => type.type !== '')
|
||||||
|
.map((type) => type.type);
|
||||||
|
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
limit: '100',
|
||||||
|
forum: forumId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (formattedCommentTypes.length) {
|
||||||
|
formattedCommentTypes.forEach((type) => params.append('include', type));
|
||||||
|
}
|
||||||
|
|
||||||
|
let more;
|
||||||
|
do {
|
||||||
|
const { data } = await $.http.get(
|
||||||
|
`/3.0/posts/list.json?${params.toString()}`
|
||||||
|
);
|
||||||
|
params.set('cursor', data.cursor.next);
|
||||||
|
more = data.cursor.hasNext;
|
||||||
|
|
||||||
|
if (data.response?.length) {
|
||||||
|
for (const comment of data.response) {
|
||||||
|
$.pushTriggerItem({
|
||||||
|
raw: comment,
|
||||||
|
meta: {
|
||||||
|
internalId: comment.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (more);
|
||||||
|
},
|
||||||
|
});
|
@@ -72,7 +72,10 @@ export default defineConfig({
|
|||||||
text: 'Disqus',
|
text: 'Disqus',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [{ text: 'Connection', link: '/apps/disqus/connection' }],
|
items: [
|
||||||
|
{ text: 'Triggers', link: '/apps/disqus/triggers' },
|
||||||
|
{ text: 'Connection', link: '/apps/disqus/connection' },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'Dropbox',
|
text: 'Dropbox',
|
||||||
|
12
packages/docs/pages/apps/disqus/triggers.md
Normal file
12
packages/docs/pages/apps/disqus/triggers.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/disqus.svg
|
||||||
|
items:
|
||||||
|
- name: New comments
|
||||||
|
desc: Triggers when a new comment is posted in a forum using Disqus.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
@@ -6,6 +6,7 @@ The following integrations are currently supported by Automatisch.
|
|||||||
- [DeepL](/apps/deepl/actions)
|
- [DeepL](/apps/deepl/actions)
|
||||||
- [Delay](/apps/delay/actions)
|
- [Delay](/apps/delay/actions)
|
||||||
- [Discord](/apps/discord/actions)
|
- [Discord](/apps/discord/actions)
|
||||||
|
- [Disqus](/apps/disqus/triggers)
|
||||||
- [Dropbox](/apps/dropbox/actions)
|
- [Dropbox](/apps/dropbox/actions)
|
||||||
- [Filter](/apps/filter/actions)
|
- [Filter](/apps/filter/actions)
|
||||||
- [Flickr](/apps/flickr/triggers)
|
- [Flickr](/apps/flickr/triggers)
|
||||||
|
Reference in New Issue
Block a user