@memberjunction/actions-bizapps-social 2.111.1 → 2.112.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -6
- package/dist/base/base-social.action.d.ts.map +1 -1
- package/dist/base/base-social.action.js +18 -24
- package/dist/base/base-social.action.js.map +1 -1
- package/dist/providers/buffer/buffer-base.action.d.ts.map +1 -1
- package/dist/providers/buffer/buffer-base.action.js +35 -34
- package/dist/providers/buffer/buffer-base.action.js.map +1 -1
- package/dist/providers/facebook/actions/boost-post.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/boost-post.action.js +33 -33
- package/dist/providers/facebook/actions/boost-post.action.js.map +1 -1
- package/dist/providers/facebook/actions/create-album.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/create-album.action.js +34 -36
- package/dist/providers/facebook/actions/create-album.action.js.map +1 -1
- package/dist/providers/facebook/actions/create-post.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/create-post.action.js +20 -20
- package/dist/providers/facebook/actions/create-post.action.js.map +1 -1
- package/dist/providers/facebook/actions/get-page-insights.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/get-page-insights.action.js +25 -27
- package/dist/providers/facebook/actions/get-page-insights.action.js.map +1 -1
- package/dist/providers/facebook/actions/get-page-posts.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/get-page-posts.action.js +19 -23
- package/dist/providers/facebook/actions/get-page-posts.action.js.map +1 -1
- package/dist/providers/facebook/actions/get-post-insights.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/get-post-insights.action.js +28 -32
- package/dist/providers/facebook/actions/get-post-insights.action.js.map +1 -1
- package/dist/providers/facebook/actions/respond-to-comments.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/respond-to-comments.action.js +42 -44
- package/dist/providers/facebook/actions/respond-to-comments.action.js.map +1 -1
- package/dist/providers/facebook/actions/schedule-post.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/schedule-post.action.js +29 -29
- package/dist/providers/facebook/actions/schedule-post.action.js.map +1 -1
- package/dist/providers/facebook/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/search-posts.action.js +37 -39
- package/dist/providers/facebook/actions/search-posts.action.js.map +1 -1
- package/dist/providers/facebook/facebook-base.action.d.ts.map +1 -1
- package/dist/providers/facebook/facebook-base.action.js +44 -59
- package/dist/providers/facebook/facebook-base.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.js +33 -31
- package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/create-scheduled-post.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/create-scheduled-post.action.js +28 -32
- package/dist/providers/hootsuite/actions/create-scheduled-post.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/delete-scheduled-post.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/delete-scheduled-post.action.js +19 -19
- package/dist/providers/hootsuite/actions/delete-scheduled-post.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/get-analytics.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/get-analytics.action.js +24 -26
- package/dist/providers/hootsuite/actions/get-analytics.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/get-scheduled-posts.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/get-scheduled-posts.action.js +22 -22
- package/dist/providers/hootsuite/actions/get-scheduled-posts.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/get-social-profiles.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/get-social-profiles.action.js +32 -34
- package/dist/providers/hootsuite/actions/get-social-profiles.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/search-posts.action.js +43 -52
- package/dist/providers/hootsuite/actions/search-posts.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/update-scheduled-post.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/update-scheduled-post.action.js +30 -28
- package/dist/providers/hootsuite/actions/update-scheduled-post.action.js.map +1 -1
- package/dist/providers/hootsuite/hootsuite-base.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/hootsuite-base.action.js +18 -20
- package/dist/providers/hootsuite/hootsuite-base.action.js.map +1 -1
- package/dist/providers/instagram/actions/create-post.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/create-post.action.js +27 -26
- package/dist/providers/instagram/actions/create-post.action.js.map +1 -1
- package/dist/providers/instagram/actions/create-story.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/create-story.action.js +35 -35
- package/dist/providers/instagram/actions/create-story.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-account-insights.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-account-insights.action.js +38 -59
- package/dist/providers/instagram/actions/get-account-insights.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-business-posts.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-business-posts.action.js +29 -29
- package/dist/providers/instagram/actions/get-business-posts.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-comments.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-comments.action.js +36 -36
- package/dist/providers/instagram/actions/get-comments.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-post-insights.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-post-insights.action.js +23 -25
- package/dist/providers/instagram/actions/get-post-insights.action.js.map +1 -1
- package/dist/providers/instagram/actions/schedule-post.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/schedule-post.action.js +25 -25
- package/dist/providers/instagram/actions/schedule-post.action.js.map +1 -1
- package/dist/providers/instagram/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/search-posts.action.js +56 -60
- package/dist/providers/instagram/actions/search-posts.action.js.map +1 -1
- package/dist/providers/instagram/instagram-base.action.d.ts.map +1 -1
- package/dist/providers/instagram/instagram-base.action.js +25 -27
- package/dist/providers/instagram/instagram-base.action.js.map +1 -1
- package/dist/providers/linkedin/actions/create-article.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/create-article.action.js +55 -45
- package/dist/providers/linkedin/actions/create-article.action.js.map +1 -1
- package/dist/providers/linkedin/actions/create-post.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/create-post.action.js +31 -29
- package/dist/providers/linkedin/actions/create-post.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-followers.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-followers.action.js +28 -28
- package/dist/providers/linkedin/actions/get-followers.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-organization-posts.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-organization-posts.action.js +20 -20
- package/dist/providers/linkedin/actions/get-organization-posts.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-personal-posts.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-personal-posts.action.js +19 -19
- package/dist/providers/linkedin/actions/get-personal-posts.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-post-analytics.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-post-analytics.action.js +25 -23
- package/dist/providers/linkedin/actions/get-post-analytics.action.js.map +1 -1
- package/dist/providers/linkedin/actions/schedule-post.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/schedule-post.action.js +32 -30
- package/dist/providers/linkedin/actions/schedule-post.action.js.map +1 -1
- package/dist/providers/linkedin/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/search-posts.action.js +28 -30
- package/dist/providers/linkedin/actions/search-posts.action.js.map +1 -1
- package/dist/providers/linkedin/linkedin-base.action.d.ts.map +1 -1
- package/dist/providers/linkedin/linkedin-base.action.js +33 -38
- package/dist/providers/linkedin/linkedin-base.action.js.map +1 -1
- package/dist/providers/tiktok/tiktok-base.action.d.ts.map +1 -1
- package/dist/providers/tiktok/tiktok-base.action.js +25 -26
- package/dist/providers/tiktok/tiktok-base.action.js.map +1 -1
- package/dist/providers/twitter/actions/create-thread.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/create-thread.action.js +25 -29
- package/dist/providers/twitter/actions/create-thread.action.js.map +1 -1
- package/dist/providers/twitter/actions/create-tweet.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/create-tweet.action.js +23 -23
- package/dist/providers/twitter/actions/create-tweet.action.js.map +1 -1
- package/dist/providers/twitter/actions/delete-tweet.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/delete-tweet.action.js +19 -19
- package/dist/providers/twitter/actions/delete-tweet.action.js.map +1 -1
- package/dist/providers/twitter/actions/get-analytics.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/get-analytics.action.js +40 -47
- package/dist/providers/twitter/actions/get-analytics.action.js.map +1 -1
- package/dist/providers/twitter/actions/get-mentions.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/get-mentions.action.js +30 -31
- package/dist/providers/twitter/actions/get-mentions.action.js.map +1 -1
- package/dist/providers/twitter/actions/get-timeline.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/get-timeline.action.js +29 -29
- package/dist/providers/twitter/actions/get-timeline.action.js.map +1 -1
- package/dist/providers/twitter/actions/schedule-tweet.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/schedule-tweet.action.js +26 -26
- package/dist/providers/twitter/actions/schedule-tweet.action.js.map +1 -1
- package/dist/providers/twitter/actions/search-tweets.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/search-tweets.action.js +56 -58
- package/dist/providers/twitter/actions/search-tweets.action.js.map +1 -1
- package/dist/providers/twitter/twitter-base.action.d.ts.map +1 -1
- package/dist/providers/twitter/twitter-base.action.js +58 -68
- package/dist/providers/twitter/twitter-base.action.js.map +1 -1
- package/dist/providers/youtube/youtube-base.action.d.ts +1 -1
- package/dist/providers/youtube/youtube-base.action.d.ts.map +1 -1
- package/dist/providers/youtube/youtube-base.action.js +22 -25
- package/dist/providers/youtube/youtube-base.action.js.map +1 -1
- package/package.json +5 -6
- package/src/base/base-social.action.ts +217 -224
- package/src/providers/buffer/buffer-base.action.ts +435 -441
- package/src/providers/facebook/actions/boost-post.action.ts +350 -386
- package/src/providers/facebook/actions/create-album.action.ts +291 -307
- package/src/providers/facebook/actions/create-post.action.ts +224 -227
- package/src/providers/facebook/actions/get-page-insights.action.ts +383 -403
- package/src/providers/facebook/actions/get-page-posts.action.ts +214 -225
- package/src/providers/facebook/actions/get-post-insights.action.ts +300 -316
- package/src/providers/facebook/actions/respond-to-comments.action.ts +319 -336
- package/src/providers/facebook/actions/schedule-post.action.ts +289 -292
- package/src/providers/facebook/actions/search-posts.action.ts +399 -413
- package/src/providers/facebook/facebook-base.action.ts +653 -670
- package/src/providers/hootsuite/actions/bulk-schedule-posts.action.ts +257 -257
- package/src/providers/hootsuite/actions/create-scheduled-post.action.ts +184 -189
- package/src/providers/hootsuite/actions/delete-scheduled-post.action.ts +160 -161
- package/src/providers/hootsuite/actions/get-analytics.action.ts +249 -254
- package/src/providers/hootsuite/actions/get-scheduled-posts.action.ts +206 -207
- package/src/providers/hootsuite/actions/get-social-profiles.action.ts +206 -205
- package/src/providers/hootsuite/actions/search-posts.action.ts +351 -369
- package/src/providers/hootsuite/actions/update-scheduled-post.action.ts +211 -209
- package/src/providers/hootsuite/hootsuite-base.action.ts +301 -307
- package/src/providers/instagram/actions/create-post.action.ts +276 -296
- package/src/providers/instagram/actions/create-story.action.ts +378 -394
- package/src/providers/instagram/actions/get-account-insights.action.ts +384 -420
- package/src/providers/instagram/actions/get-business-posts.action.ts +233 -242
- package/src/providers/instagram/actions/get-comments.action.ts +365 -377
- package/src/providers/instagram/actions/get-post-insights.action.ts +265 -273
- package/src/providers/instagram/actions/schedule-post.action.ts +233 -235
- package/src/providers/instagram/actions/search-posts.action.ts +512 -538
- package/src/providers/instagram/instagram-base.action.ts +368 -393
- package/src/providers/linkedin/actions/create-article.action.ts +275 -266
- package/src/providers/linkedin/actions/create-post.action.ts +179 -177
- package/src/providers/linkedin/actions/get-followers.action.ts +211 -211
- package/src/providers/linkedin/actions/get-organization-posts.action.ts +146 -147
- package/src/providers/linkedin/actions/get-personal-posts.action.ts +138 -139
- package/src/providers/linkedin/actions/get-post-analytics.action.ts +190 -189
- package/src/providers/linkedin/actions/schedule-post.action.ts +191 -189
- package/src/providers/linkedin/actions/search-posts.action.ts +275 -283
- package/src/providers/linkedin/linkedin-base.action.ts +407 -421
- package/src/providers/tiktok/tiktok-base.action.ts +305 -320
- package/src/providers/twitter/actions/create-thread.action.ts +203 -207
- package/src/providers/twitter/actions/create-tweet.action.ts +187 -188
- package/src/providers/twitter/actions/delete-tweet.action.ts +128 -129
- package/src/providers/twitter/actions/get-analytics.action.ts +402 -411
- package/src/providers/twitter/actions/get-mentions.action.ts +218 -219
- package/src/providers/twitter/actions/get-timeline.action.ts +232 -233
- package/src/providers/twitter/actions/schedule-tweet.action.ts +221 -222
- package/src/providers/twitter/actions/search-tweets.action.ts +540 -543
- package/src/providers/twitter/twitter-base.action.ts +541 -560
- package/src/providers/youtube/youtube-base.action.ts +320 -333
|
@@ -2,7 +2,7 @@ import { RegisterClass } from '@memberjunction/global';
|
|
|
2
2
|
import { FacebookBaseAction, FacebookComment } from '../facebook-base.action';
|
|
3
3
|
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
4
|
import { SocialMediaErrorCode } from '../../../base/base-social.action';
|
|
5
|
-
import { LogStatus, LogError } from '@memberjunction/
|
|
5
|
+
import { LogStatus, LogError } from '@memberjunction/global';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import { BaseAction } from '@memberjunction/actions';
|
|
8
8
|
|
|
@@ -12,362 +12,345 @@ import { BaseAction } from '@memberjunction/actions';
|
|
|
12
12
|
*/
|
|
13
13
|
@RegisterClass(BaseAction, 'FacebookRespondToCommentsAction')
|
|
14
14
|
export class FacebookRespondToCommentsAction extends FacebookBaseAction {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Get action description
|
|
17
|
+
*/
|
|
18
|
+
public get Description(): string {
|
|
19
|
+
return 'Responds to comments on Facebook posts, pages, or other comments with text replies or reactions';
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Define the parameters for this action
|
|
24
|
+
*/
|
|
25
|
+
public get Params(): ActionParam[] {
|
|
26
|
+
return [
|
|
27
|
+
...this.commonSocialParams,
|
|
28
|
+
{
|
|
29
|
+
Name: 'CommentID',
|
|
30
|
+
Type: 'Input',
|
|
31
|
+
Value: null,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
Name: 'ResponseText',
|
|
35
|
+
Type: 'Input',
|
|
36
|
+
Value: null,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
Name: 'AttachmentURL',
|
|
40
|
+
Type: 'Input',
|
|
41
|
+
Value: null,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
Name: 'LikeComment',
|
|
45
|
+
Type: 'Input',
|
|
46
|
+
Value: false,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
Name: 'HideComment',
|
|
50
|
+
Type: 'Input',
|
|
51
|
+
Value: false,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
Name: 'DeleteComment',
|
|
55
|
+
Type: 'Input',
|
|
56
|
+
Value: false,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
Name: 'PrivateReply',
|
|
60
|
+
Type: 'Input',
|
|
61
|
+
Value: false,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
Name: 'PageID',
|
|
65
|
+
Type: 'Input',
|
|
66
|
+
Value: null,
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Execute the action
|
|
73
|
+
*/
|
|
74
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
75
|
+
const { Params, ContextUser } = params;
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
// Validate required parameters
|
|
79
|
+
const companyIntegrationId = this.getParamValue(Params, 'CompanyIntegrationID');
|
|
80
|
+
const commentId = this.getParamValue(Params, 'CommentID');
|
|
81
|
+
|
|
82
|
+
if (!companyIntegrationId) {
|
|
83
|
+
return {
|
|
84
|
+
Success: false,
|
|
85
|
+
Message: 'CompanyIntegrationID is required',
|
|
86
|
+
ResultCode: 'INVALID_TOKEN',
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!commentId) {
|
|
91
|
+
return {
|
|
92
|
+
Success: false,
|
|
93
|
+
Message: 'CommentID is required',
|
|
94
|
+
ResultCode: 'MISSING_REQUIRED_PARAM',
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Initialize OAuth
|
|
99
|
+
if (!(await this.initializeOAuth(companyIntegrationId))) {
|
|
100
|
+
return {
|
|
101
|
+
Success: false,
|
|
102
|
+
Message: 'Failed to initialize Facebook OAuth connection',
|
|
103
|
+
ResultCode: 'INVALID_TOKEN',
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Get parameters
|
|
108
|
+
const responseText = this.getParamValue(Params, 'ResponseText') as string;
|
|
109
|
+
const attachmentUrl = this.getParamValue(Params, 'AttachmentURL') as string;
|
|
110
|
+
const likeComment = this.getParamValue(Params, 'LikeComment') as boolean;
|
|
111
|
+
const hideComment = this.getParamValue(Params, 'HideComment') as boolean;
|
|
112
|
+
const deleteComment = this.getParamValue(Params, 'DeleteComment') as boolean;
|
|
113
|
+
const privateReply = this.getParamValue(Params, 'PrivateReply') as boolean;
|
|
114
|
+
const pageId = this.getParamValue(Params, 'PageID') as string;
|
|
70
115
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
116
|
+
// Validate that at least one action is specified
|
|
117
|
+
if (!responseText && !attachmentUrl && !likeComment && !hideComment && !deleteComment) {
|
|
118
|
+
return {
|
|
119
|
+
Success: false,
|
|
120
|
+
Message: 'At least one action (ResponseText, AttachmentURL, LikeComment, HideComment, or DeleteComment) is required',
|
|
121
|
+
ResultCode: 'MISSING_ACTION',
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Get appropriate access token
|
|
126
|
+
let accessToken = this.getAccessToken();
|
|
127
|
+
if (pageId) {
|
|
128
|
+
// Use page access token for page actions
|
|
129
|
+
accessToken = await this.getPageAccessToken(pageId);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
LogStatus(`Processing comment ${commentId}...`);
|
|
133
|
+
|
|
134
|
+
// Get comment details first
|
|
135
|
+
const commentDetails = await this.getCommentDetails(commentId, accessToken!);
|
|
136
|
+
if (!commentDetails) {
|
|
137
|
+
return {
|
|
138
|
+
Success: false,
|
|
139
|
+
Message: 'Comment not found or access denied',
|
|
140
|
+
ResultCode: 'NOT_FOUND',
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const results: any = {
|
|
145
|
+
commentId,
|
|
146
|
+
originalComment: {
|
|
147
|
+
message: commentDetails.message,
|
|
148
|
+
from: commentDetails.from,
|
|
149
|
+
createdTime: commentDetails.created_time,
|
|
150
|
+
},
|
|
151
|
+
actions: [],
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// Handle delete action first (if specified)
|
|
155
|
+
if (deleteComment) {
|
|
77
156
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (!companyIntegrationId) {
|
|
83
|
-
return {
|
|
84
|
-
Success: false,
|
|
85
|
-
Message: 'CompanyIntegrationID is required',
|
|
86
|
-
ResultCode: 'INVALID_TOKEN'
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (!commentId) {
|
|
91
|
-
return {
|
|
92
|
-
Success: false,
|
|
93
|
-
Message: 'CommentID is required',
|
|
94
|
-
ResultCode: 'MISSING_REQUIRED_PARAM'
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Initialize OAuth
|
|
99
|
-
if (!await this.initializeOAuth(companyIntegrationId)) {
|
|
100
|
-
return {
|
|
101
|
-
Success: false,
|
|
102
|
-
Message: 'Failed to initialize Facebook OAuth connection',
|
|
103
|
-
ResultCode: 'INVALID_TOKEN'
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Get parameters
|
|
108
|
-
const responseText = this.getParamValue(Params, 'ResponseText') as string;
|
|
109
|
-
const attachmentUrl = this.getParamValue(Params, 'AttachmentURL') as string;
|
|
110
|
-
const likeComment = this.getParamValue(Params, 'LikeComment') as boolean;
|
|
111
|
-
const hideComment = this.getParamValue(Params, 'HideComment') as boolean;
|
|
112
|
-
const deleteComment = this.getParamValue(Params, 'DeleteComment') as boolean;
|
|
113
|
-
const privateReply = this.getParamValue(Params, 'PrivateReply') as boolean;
|
|
114
|
-
const pageId = this.getParamValue(Params, 'PageID') as string;
|
|
115
|
-
|
|
116
|
-
// Validate that at least one action is specified
|
|
117
|
-
if (!responseText && !attachmentUrl && !likeComment && !hideComment && !deleteComment) {
|
|
118
|
-
return {
|
|
119
|
-
Success: false,
|
|
120
|
-
Message: 'At least one action (ResponseText, AttachmentURL, LikeComment, HideComment, or DeleteComment) is required',
|
|
121
|
-
ResultCode: 'MISSING_ACTION'
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Get appropriate access token
|
|
126
|
-
let accessToken = this.getAccessToken();
|
|
127
|
-
if (pageId) {
|
|
128
|
-
// Use page access token for page actions
|
|
129
|
-
accessToken = await this.getPageAccessToken(pageId);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
LogStatus(`Processing comment ${commentId}...`);
|
|
133
|
-
|
|
134
|
-
// Get comment details first
|
|
135
|
-
const commentDetails = await this.getCommentDetails(commentId, accessToken!);
|
|
136
|
-
if (!commentDetails) {
|
|
137
|
-
return {
|
|
138
|
-
Success: false,
|
|
139
|
-
Message: 'Comment not found or access denied',
|
|
140
|
-
ResultCode: 'NOT_FOUND'
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const results: any = {
|
|
145
|
-
commentId,
|
|
146
|
-
originalComment: {
|
|
147
|
-
message: commentDetails.message,
|
|
148
|
-
from: commentDetails.from,
|
|
149
|
-
createdTime: commentDetails.created_time
|
|
150
|
-
},
|
|
151
|
-
actions: []
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// Handle delete action first (if specified)
|
|
155
|
-
if (deleteComment) {
|
|
156
|
-
try {
|
|
157
|
-
await this.deleteCommentAction(commentId, accessToken!);
|
|
158
|
-
results.actions.push({ action: 'delete', success: true });
|
|
159
|
-
LogStatus(`Deleted comment ${commentId}`);
|
|
160
|
-
|
|
161
|
-
// If deleted, no other actions can be performed
|
|
162
|
-
return {
|
|
163
|
-
Success: true,
|
|
164
|
-
Message: 'Comment deleted successfully',
|
|
165
|
-
ResultCode: 'SUCCESS',
|
|
166
|
-
Params
|
|
167
|
-
};
|
|
168
|
-
} catch (error) {
|
|
169
|
-
LogError(`Failed to delete comment: ${error}`);
|
|
170
|
-
results.actions.push({
|
|
171
|
-
action: 'delete',
|
|
172
|
-
success: false,
|
|
173
|
-
error: error instanceof Error ? error.message : 'Unknown error'
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Handle hide action
|
|
179
|
-
if (hideComment) {
|
|
180
|
-
try {
|
|
181
|
-
await this.hideCommentAction(commentId, accessToken!, true);
|
|
182
|
-
results.actions.push({ action: 'hide', success: true });
|
|
183
|
-
LogStatus(`Hidden comment ${commentId}`);
|
|
184
|
-
} catch (error) {
|
|
185
|
-
LogError(`Failed to hide comment: ${error}`);
|
|
186
|
-
results.actions.push({
|
|
187
|
-
action: 'hide',
|
|
188
|
-
success: false,
|
|
189
|
-
error: error instanceof Error ? error.message : 'Unknown error'
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Handle like action
|
|
195
|
-
if (likeComment) {
|
|
196
|
-
try {
|
|
197
|
-
await this.likeCommentAction(commentId, accessToken!);
|
|
198
|
-
results.actions.push({ action: 'like', success: true });
|
|
199
|
-
LogStatus(`Liked comment ${commentId}`);
|
|
200
|
-
} catch (error) {
|
|
201
|
-
LogError(`Failed to like comment: ${error}`);
|
|
202
|
-
results.actions.push({
|
|
203
|
-
action: 'like',
|
|
204
|
-
success: false,
|
|
205
|
-
error: error instanceof Error ? error.message : 'Unknown error'
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Handle reply action
|
|
211
|
-
if (responseText || attachmentUrl) {
|
|
212
|
-
try {
|
|
213
|
-
const replyResult = await this.replyToComment(
|
|
214
|
-
commentId,
|
|
215
|
-
responseText,
|
|
216
|
-
attachmentUrl,
|
|
217
|
-
privateReply,
|
|
218
|
-
accessToken!
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
results.actions.push({
|
|
222
|
-
action: privateReply ? 'private_reply' : 'reply',
|
|
223
|
-
success: true,
|
|
224
|
-
replyId: replyResult.id,
|
|
225
|
-
message: responseText
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
LogStatus(`Replied to comment ${commentId}`);
|
|
229
|
-
} catch (error) {
|
|
230
|
-
LogError(`Failed to reply to comment: ${error}`);
|
|
231
|
-
results.actions.push({
|
|
232
|
-
action: privateReply ? 'private_reply' : 'reply',
|
|
233
|
-
success: false,
|
|
234
|
-
error: error instanceof Error ? error.message : 'Unknown error'
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// Check if any actions succeeded
|
|
240
|
-
const successfulActions = results.actions.filter((a: any) => a.success);
|
|
241
|
-
if (successfulActions.length === 0) {
|
|
242
|
-
return {
|
|
243
|
-
Success: false,
|
|
244
|
-
Message: 'All requested actions failed',
|
|
245
|
-
ResultCode: 'ERROR'
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return {
|
|
250
|
-
Success: true,
|
|
251
|
-
Message: `Successfully completed ${successfulActions.length} of ${results.actions.length} actions`,
|
|
252
|
-
ResultCode: 'SUCCESS',
|
|
253
|
-
Params
|
|
254
|
-
};
|
|
157
|
+
await this.deleteCommentAction(commentId, accessToken!);
|
|
158
|
+
results.actions.push({ action: 'delete', success: true });
|
|
159
|
+
LogStatus(`Deleted comment ${commentId}`);
|
|
255
160
|
|
|
161
|
+
// If deleted, no other actions can be performed
|
|
162
|
+
return {
|
|
163
|
+
Success: true,
|
|
164
|
+
Message: 'Comment deleted successfully',
|
|
165
|
+
ResultCode: 'SUCCESS',
|
|
166
|
+
Params,
|
|
167
|
+
};
|
|
256
168
|
} catch (error) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return {
|
|
264
|
-
Success: false,
|
|
265
|
-
Message: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
266
|
-
ResultCode: 'ERROR'
|
|
267
|
-
};
|
|
169
|
+
LogError(`Failed to delete comment: ${error}`);
|
|
170
|
+
results.actions.push({
|
|
171
|
+
action: 'delete',
|
|
172
|
+
success: false,
|
|
173
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
174
|
+
});
|
|
268
175
|
}
|
|
269
|
-
|
|
176
|
+
}
|
|
270
177
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
*/
|
|
274
|
-
private async getCommentDetails(commentId: string, accessToken: string): Promise<FacebookComment | null> {
|
|
178
|
+
// Handle hide action
|
|
179
|
+
if (hideComment) {
|
|
275
180
|
try {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
params: {
|
|
280
|
-
access_token: accessToken,
|
|
281
|
-
fields: 'id,message,created_time,from,like_count,comment_count,parent'
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
);
|
|
285
|
-
|
|
286
|
-
return response.data;
|
|
181
|
+
await this.hideCommentAction(commentId, accessToken!, true);
|
|
182
|
+
results.actions.push({ action: 'hide', success: true });
|
|
183
|
+
LogStatus(`Hidden comment ${commentId}`);
|
|
287
184
|
} catch (error) {
|
|
288
|
-
|
|
289
|
-
|
|
185
|
+
LogError(`Failed to hide comment: ${error}`);
|
|
186
|
+
results.actions.push({
|
|
187
|
+
action: 'hide',
|
|
188
|
+
success: false,
|
|
189
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
190
|
+
});
|
|
290
191
|
}
|
|
291
|
-
|
|
192
|
+
}
|
|
292
193
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
?
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
const data: any = {};
|
|
308
|
-
|
|
309
|
-
if (message) {
|
|
310
|
-
data.message = message;
|
|
194
|
+
// Handle like action
|
|
195
|
+
if (likeComment) {
|
|
196
|
+
try {
|
|
197
|
+
await this.likeCommentAction(commentId, accessToken!);
|
|
198
|
+
results.actions.push({ action: 'like', success: true });
|
|
199
|
+
LogStatus(`Liked comment ${commentId}`);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
LogError(`Failed to like comment: ${error}`);
|
|
202
|
+
results.actions.push({
|
|
203
|
+
action: 'like',
|
|
204
|
+
success: false,
|
|
205
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
206
|
+
});
|
|
311
207
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Handle reply action
|
|
211
|
+
if (responseText || attachmentUrl) {
|
|
212
|
+
try {
|
|
213
|
+
const replyResult = await this.replyToComment(commentId, responseText, attachmentUrl, privateReply, accessToken!);
|
|
214
|
+
|
|
215
|
+
results.actions.push({
|
|
216
|
+
action: privateReply ? 'private_reply' : 'reply',
|
|
217
|
+
success: true,
|
|
218
|
+
replyId: replyResult.id,
|
|
219
|
+
message: responseText,
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
LogStatus(`Replied to comment ${commentId}`);
|
|
223
|
+
} catch (error) {
|
|
224
|
+
LogError(`Failed to reply to comment: ${error}`);
|
|
225
|
+
results.actions.push({
|
|
226
|
+
action: privateReply ? 'private_reply' : 'reply',
|
|
227
|
+
success: false,
|
|
228
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
229
|
+
});
|
|
315
230
|
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Check if any actions succeeded
|
|
234
|
+
const successfulActions = results.actions.filter((a: any) => a.success);
|
|
235
|
+
if (successfulActions.length === 0) {
|
|
236
|
+
return {
|
|
237
|
+
Success: false,
|
|
238
|
+
Message: 'All requested actions failed',
|
|
239
|
+
ResultCode: 'ERROR',
|
|
240
|
+
};
|
|
241
|
+
}
|
|
316
242
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
243
|
+
return {
|
|
244
|
+
Success: true,
|
|
245
|
+
Message: `Successfully completed ${successfulActions.length} of ${results.actions.length} actions`,
|
|
246
|
+
ResultCode: 'SUCCESS',
|
|
247
|
+
Params,
|
|
248
|
+
};
|
|
249
|
+
} catch (error) {
|
|
250
|
+
LogError(`Failed to respond to Facebook comment: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
322
251
|
|
|
323
|
-
|
|
252
|
+
if (this.isAuthError(error)) {
|
|
253
|
+
return this.handleOAuthError(error);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
Success: false,
|
|
258
|
+
Message: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
259
|
+
ResultCode: 'ERROR',
|
|
260
|
+
};
|
|
324
261
|
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Get comment details
|
|
266
|
+
*/
|
|
267
|
+
private async getCommentDetails(commentId: string, accessToken: string): Promise<FacebookComment | null> {
|
|
268
|
+
try {
|
|
269
|
+
const response = await axios.get(`${this.apiBaseUrl}/${commentId}`, {
|
|
270
|
+
params: {
|
|
271
|
+
access_token: accessToken,
|
|
272
|
+
fields: 'id,message,created_time,from,like_count,comment_count,parent',
|
|
273
|
+
},
|
|
274
|
+
});
|
|
325
275
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
await axios.post(
|
|
331
|
-
`${this.apiBaseUrl}/${commentId}/likes`,
|
|
332
|
-
{},
|
|
333
|
-
{
|
|
334
|
-
params: {
|
|
335
|
-
access_token: accessToken
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
);
|
|
276
|
+
return response.data;
|
|
277
|
+
} catch (error) {
|
|
278
|
+
LogError(`Failed to get comment details: ${error}`);
|
|
279
|
+
return null;
|
|
339
280
|
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Reply to a comment
|
|
285
|
+
*/
|
|
286
|
+
private async replyToComment(
|
|
287
|
+
commentId: string,
|
|
288
|
+
message: string | null,
|
|
289
|
+
attachmentUrl: string | null,
|
|
290
|
+
privateReply: boolean,
|
|
291
|
+
accessToken: string
|
|
292
|
+
): Promise<any> {
|
|
293
|
+
const endpoint = privateReply ? `${this.apiBaseUrl}/${commentId}/private_replies` : `${this.apiBaseUrl}/${commentId}/comments`;
|
|
294
|
+
|
|
295
|
+
const data: any = {};
|
|
340
296
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
*/
|
|
344
|
-
private async hideCommentAction(commentId: string, accessToken: string, hide: boolean): Promise<void> {
|
|
345
|
-
await axios.post(
|
|
346
|
-
`${this.apiBaseUrl}/${commentId}`,
|
|
347
|
-
{
|
|
348
|
-
is_hidden: hide
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
params: {
|
|
352
|
-
access_token: accessToken
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
);
|
|
297
|
+
if (message) {
|
|
298
|
+
data.message = message;
|
|
356
299
|
}
|
|
357
300
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
*/
|
|
361
|
-
private async deleteCommentAction(commentId: string, accessToken: string): Promise<void> {
|
|
362
|
-
await axios.delete(
|
|
363
|
-
`${this.apiBaseUrl}/${commentId}`,
|
|
364
|
-
{
|
|
365
|
-
params: {
|
|
366
|
-
access_token: accessToken
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
);
|
|
301
|
+
if (attachmentUrl) {
|
|
302
|
+
data.attachment_url = attachmentUrl;
|
|
370
303
|
}
|
|
371
304
|
|
|
305
|
+
const response = await axios.post(endpoint, data, {
|
|
306
|
+
params: {
|
|
307
|
+
access_token: accessToken,
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
return response.data;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Like a comment
|
|
316
|
+
*/
|
|
317
|
+
private async likeCommentAction(commentId: string, accessToken: string): Promise<void> {
|
|
318
|
+
await axios.post(
|
|
319
|
+
`${this.apiBaseUrl}/${commentId}/likes`,
|
|
320
|
+
{},
|
|
321
|
+
{
|
|
322
|
+
params: {
|
|
323
|
+
access_token: accessToken,
|
|
324
|
+
},
|
|
325
|
+
}
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Hide or unhide a comment
|
|
331
|
+
*/
|
|
332
|
+
private async hideCommentAction(commentId: string, accessToken: string, hide: boolean): Promise<void> {
|
|
333
|
+
await axios.post(
|
|
334
|
+
`${this.apiBaseUrl}/${commentId}`,
|
|
335
|
+
{
|
|
336
|
+
is_hidden: hide,
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
params: {
|
|
340
|
+
access_token: accessToken,
|
|
341
|
+
},
|
|
342
|
+
}
|
|
343
|
+
);
|
|
344
|
+
}
|
|
372
345
|
|
|
373
|
-
|
|
346
|
+
/**
|
|
347
|
+
* Delete a comment
|
|
348
|
+
*/
|
|
349
|
+
private async deleteCommentAction(commentId: string, accessToken: string): Promise<void> {
|
|
350
|
+
await axios.delete(`${this.apiBaseUrl}/${commentId}`, {
|
|
351
|
+
params: {
|
|
352
|
+
access_token: accessToken,
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}
|