feat(disqus): add new flagged comments trigger

This commit is contained in:
Rıdvan Akca
2024-01-16 13:49:05 +03:00
parent 033b15a158
commit 6b712c9a90
4 changed files with 64 additions and 2 deletions

View File

@@ -10,7 +10,7 @@ export default defineApp({
baseUrl: 'https://disqus.com',
apiBaseUrl: 'https://disqus.com/api',
iconUrl: '{BASE_URL}/apps/disqus/assets/favicon.svg',
authDocUrl: 'https://automatisch.io/docs/apps/disqus/connection',
authDocUrl: '{DOCS_URL}/apps/disqus/connection',
primaryColor: '2E9FFF',
supportsConnections: true,
beforeRequest: [addAuthHeader],

View File

@@ -1,3 +1,4 @@
import newComments from './new-comments/index.js';
import newFlaggedComments from './new-flagged-comments/index.js';
export default [newComments];
export default [newComments, newFlaggedComments];

View File

@@ -0,0 +1,59 @@
import defineTrigger from '../../../../helpers/define-trigger.js';
import { URLSearchParams } from 'url';
export default defineTrigger({
name: 'New flagged comments',
key: 'newFlaggedComments',
pollInterval: 15,
description: 'Triggers when a Disqus comment is marked with a flag',
arguments: [
{
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 params = new URLSearchParams({
limit: '100',
forum: forumId,
filters: [5], // Is_Flagged
});
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);
},
});

View File

@@ -3,6 +3,8 @@ favicon: /favicons/disqus.svg
items:
- name: New comments
desc: Triggers when a new comment is posted in a forum using Disqus.
- name: New flagged comments
desc: Triggers when a Disqus comment is marked with a flag.
---
<script setup>