Skip to content

Commit 15ff130

Browse files
lcaresiamichelle0927coderabbitai[bot]
authored
[Components] akismet #11257 (#17154)
* Added actions * Update components/akismet/actions/submit-spam/submit-spam.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: michelle0927 <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent b3f70c3 commit 15ff130

File tree

7 files changed

+394
-6
lines changed

7 files changed

+394
-6
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import app from "../../akismet.app.mjs";
2+
3+
export default {
4+
key: "akismet-check-comment",
5+
name: "Check Comment",
6+
description: "Check if a comment is spam or not. [See the documentation](https://akismet.com/developers/detailed-docs/submit-spam-missed-spam/)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
blog: {
12+
propDefinition: [
13+
app,
14+
"blog",
15+
],
16+
},
17+
userIp: {
18+
propDefinition: [
19+
app,
20+
"userIp",
21+
],
22+
},
23+
userAgent: {
24+
propDefinition: [
25+
app,
26+
"userAgent",
27+
],
28+
},
29+
referrer: {
30+
propDefinition: [
31+
app,
32+
"referrer",
33+
],
34+
},
35+
permalink: {
36+
propDefinition: [
37+
app,
38+
"permalink",
39+
],
40+
},
41+
commentType: {
42+
propDefinition: [
43+
app,
44+
"commentType",
45+
],
46+
},
47+
commentAuthor: {
48+
propDefinition: [
49+
app,
50+
"commentAuthor",
51+
],
52+
},
53+
commentAuthorEmail: {
54+
propDefinition: [
55+
app,
56+
"commentAuthorEmail",
57+
],
58+
},
59+
commentAuthorUrl: {
60+
propDefinition: [
61+
app,
62+
"commentAuthorUrl",
63+
],
64+
},
65+
commentContent: {
66+
propDefinition: [
67+
app,
68+
"commentContent",
69+
],
70+
},
71+
72+
},
73+
async run({ $ }) {
74+
const response = await this.app.checkComment({
75+
$,
76+
data: {
77+
blog: this.blog,
78+
user_ip: this.userIp,
79+
user_agent: this.userAgent,
80+
referrer: this.referrer,
81+
permalink: this.permalink,
82+
comment_author: this.commentAuthor,
83+
comment_author_email: this.commentAuthorEmail,
84+
comment_author_url: this.commentAuthorUrl,
85+
comment_content: this.commentContent,
86+
comment_type: this.commentType,
87+
},
88+
});
89+
$.export("$summary", "Successfully submited comment to be checked. Akismet spam analysis response: " + response);
90+
return response;
91+
},
92+
};
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import app from "../../akismet.app.mjs";
2+
3+
export default {
4+
key: "akismet-submit-ham",
5+
name: "Submit Ham",
6+
description: "Submit a comment that was incorrectly classified as spam. [See the documentation](https://akismet.com/developers/detailed-docs/submit-ham-false-positives/)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
blog: {
12+
propDefinition: [
13+
app,
14+
"blog",
15+
],
16+
},
17+
userIp: {
18+
propDefinition: [
19+
app,
20+
"userIp",
21+
],
22+
},
23+
permalink: {
24+
propDefinition: [
25+
app,
26+
"permalink",
27+
],
28+
},
29+
userAgent: {
30+
propDefinition: [
31+
app,
32+
"userAgent",
33+
],
34+
},
35+
commentAuthor: {
36+
propDefinition: [
37+
app,
38+
"commentAuthor",
39+
],
40+
},
41+
commentAuthorEmail: {
42+
propDefinition: [
43+
app,
44+
"commentAuthorEmail",
45+
],
46+
},
47+
commentAuthorUrl: {
48+
propDefinition: [
49+
app,
50+
"commentAuthorUrl",
51+
],
52+
},
53+
commentContent: {
54+
propDefinition: [
55+
app,
56+
"commentContent",
57+
],
58+
},
59+
commentType: {
60+
propDefinition: [
61+
app,
62+
"commentType",
63+
],
64+
},
65+
},
66+
async run({ $ }) {
67+
const response = await this.app.submitHam({
68+
$,
69+
data: {
70+
blog: this.blog,
71+
user_ip: this.userIp,
72+
user_agent: this.userAgent,
73+
permalink: this.permalink,
74+
comment_author: this.commentAuthor,
75+
comment_author_email: this.commentAuthorEmail,
76+
comment_author_url: this.commentAuthorUrl,
77+
comment_content: this.commentContent,
78+
comment_type: this.commentType,
79+
},
80+
});
81+
$.export("$summary", "Successfully submited comment as a false positive");
82+
return response;
83+
},
84+
};
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import app from "../../akismet.app.mjs";
2+
3+
export default {
4+
key: "akismet-submit-spam",
5+
name: "Submit Spam",
6+
description: "Submit comment that was not marked as spam but should have been. [See the documentation](https://akismet.com/developers/detailed-docs/submit-spam-missed-spam/)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
blog: {
12+
propDefinition: [
13+
app,
14+
"blog",
15+
],
16+
},
17+
userIp: {
18+
propDefinition: [
19+
app,
20+
"userIp",
21+
],
22+
},
23+
permalink: {
24+
propDefinition: [
25+
app,
26+
"permalink",
27+
],
28+
},
29+
userAgent: {
30+
propDefinition: [
31+
app,
32+
"userAgent",
33+
],
34+
},
35+
referrer: {
36+
propDefinition: [
37+
app,
38+
"referrer",
39+
],
40+
},
41+
commentAuthor: {
42+
propDefinition: [
43+
app,
44+
"commentAuthor",
45+
],
46+
},
47+
commentAuthorEmail: {
48+
propDefinition: [
49+
app,
50+
"commentAuthorEmail",
51+
],
52+
},
53+
commentAuthorUrl: {
54+
propDefinition: [
55+
app,
56+
"commentAuthorUrl",
57+
],
58+
},
59+
commentContent: {
60+
propDefinition: [
61+
app,
62+
"commentContent",
63+
],
64+
},
65+
commentType: {
66+
propDefinition: [
67+
app,
68+
"commentType",
69+
],
70+
},
71+
},
72+
async run({ $ }) {
73+
74+
const response = await this.app.submitSpam({
75+
$,
76+
data: {
77+
blog: this.blog,
78+
user_ip: this.userIp,
79+
permalink: this.permalink,
80+
user_agent: this.userAgent,
81+
referrer: this.referrer,
82+
comment_author: this.commentAuthor,
83+
comment_author_email: this.commentAuthorEmail,
84+
comment_author_url: this.commentAuthorUrl,
85+
comment_content: this.commentContent,
86+
comment_type: this.commentType,
87+
},
88+
});
89+
90+
$.export("$summary", "Successfully submited comment as spam");
91+
return response;
92+
},
93+
};

components/akismet/akismet.app.mjs

Lines changed: 109 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,116 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "akismet",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
blog: {
9+
type: "string",
10+
label: "Blog URL",
11+
description: "The URL of the blog where the comment was posted",
12+
},
13+
userIp: {
14+
type: "string",
15+
label: "User IP",
16+
description: "The IP address of the comment author",
17+
},
18+
permalink: {
19+
type: "string",
20+
label: "Permalink",
21+
description: "The full permanent URL of the entry the comment was submitted to",
22+
},
23+
userAgent: {
24+
type: "string",
25+
label: "User Agent",
26+
description: "The user agent string of the web browser used to submit the comment",
27+
optional: true,
28+
},
29+
referrer: {
30+
type: "string",
31+
label: "Referrer URL",
32+
description: "The URL of the page that submitted the comment",
33+
optional: true,
34+
},
35+
commentAuthor: {
36+
type: "string",
37+
label: "Comment Author Name",
38+
description: "The name submitted with the comment",
39+
optional: true,
40+
},
41+
commentAuthorEmail: {
42+
type: "string",
43+
label: "Comment Author Email",
44+
description: "The email address submitted with the comment",
45+
optional: true,
46+
},
47+
commentAuthorUrl: {
48+
type: "string",
49+
label: "Comment Author URL",
50+
description: "The URL submitted with the comment",
51+
optional: true,
52+
},
53+
commentContent: {
54+
type: "string",
55+
label: "Comment Content",
56+
description: "The content of the comment itself",
57+
optional: true,
58+
},
59+
commentType: {
60+
type: "string",
61+
label: "Comment Type",
62+
description: "The type of comment",
63+
optional: true,
64+
options: constants.COMMENT_TYPES,
65+
},
66+
},
567
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
68+
_baseUrl() {
69+
return "https://rest.akismet.com/1.1";
70+
},
71+
async _makeRequest(opts = {}) {
72+
const {
73+
$ = this,
74+
path,
75+
headers,
76+
data,
77+
...otherOpts
78+
} = opts;
79+
80+
return axios($, {
81+
...otherOpts,
82+
url: this._baseUrl() + path,
83+
headers: {
84+
...headers,
85+
"Content-Type": "application/x-www-form-urlencoded",
86+
"Accept": "application/json",
87+
},
88+
data: {
89+
api_key: `${this.$auth.api_key}`,
90+
...data,
91+
},
92+
});
93+
},
94+
async submitSpam(args = {}) {
95+
return this._makeRequest({
96+
path: "/submit-spam",
97+
method: "post",
98+
...args,
99+
});
100+
},
101+
async submitHam(args = {}) {
102+
return this._makeRequest({
103+
path: "/submit-ham",
104+
method: "post",
105+
...args,
106+
});
107+
},
108+
async checkComment(args = {}) {
109+
return this._makeRequest({
110+
path: "/comment-check",
111+
method: "post",
112+
...args,
113+
});
9114
},
10115
},
11116
};

0 commit comments

Comments
 (0)