@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
|
@@ -1,174 +1,173 @@
|
|
|
1
1
|
import { RegisterClass } from '@memberjunction/global';
|
|
2
2
|
import { HootSuiteBaseAction } from '../hootsuite-base.action';
|
|
3
3
|
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
|
-
import { LogStatus, LogError } from '@memberjunction/
|
|
4
|
+
import { LogStatus, LogError } from '@memberjunction/global';
|
|
5
5
|
import { BaseAction } from '@memberjunction/actions';
|
|
6
6
|
/**
|
|
7
7
|
* Action to delete a scheduled post from HootSuite
|
|
8
8
|
*/
|
|
9
9
|
@RegisterClass(BaseAction, 'HootSuiteDeleteScheduledPostAction')
|
|
10
10
|
export class HootSuiteDeleteScheduledPostAction extends HootSuiteBaseAction {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Check if post can be deleted
|
|
63
|
-
if (postDetails.state === 'PUBLISHED') {
|
|
64
|
-
return {
|
|
65
|
-
Success: false,
|
|
66
|
-
ResultCode: 'CANNOT_DELETE_PUBLISHED',
|
|
67
|
-
Message: 'Cannot delete published posts. Only scheduled, draft, or failed posts can be deleted.',
|
|
68
|
-
Params
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Store post details before deletion
|
|
73
|
-
const deletedPostInfo = {
|
|
74
|
-
id: postDetails.id,
|
|
75
|
-
content: postDetails.text,
|
|
76
|
-
state: postDetails.state,
|
|
77
|
-
scheduledTime: postDetails.scheduledTime,
|
|
78
|
-
profiles: postDetails.socialProfileIds,
|
|
79
|
-
mediaCount: postDetails.mediaIds?.length || 0,
|
|
80
|
-
tags: postDetails.tags || [],
|
|
81
|
-
deletedAt: new Date().toISOString()
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// Delete the post
|
|
85
|
-
LogStatus(`Deleting post ${postId}...`);
|
|
86
|
-
await this.axiosInstance.delete(`/messages/${postId}`);
|
|
87
|
-
|
|
88
|
-
// Verify deletion by trying to fetch the post again
|
|
89
|
-
let verificationFailed = false;
|
|
90
|
-
try {
|
|
91
|
-
await this.axiosInstance.get(`/messages/${postId}`);
|
|
92
|
-
verificationFailed = true;
|
|
93
|
-
} catch (error: any) {
|
|
94
|
-
if (error.response?.status !== 404) {
|
|
95
|
-
verificationFailed = true;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (verificationFailed) {
|
|
100
|
-
LogStatus('Warning: Post deletion could not be verified');
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Update output parameters
|
|
104
|
-
const outputParams = [...Params];
|
|
105
|
-
const deletedPostParam = outputParams.find(p => p.Name === 'DeletedPostInfo');
|
|
106
|
-
if (deletedPostParam) deletedPostParam.Value = deletedPostInfo;
|
|
107
|
-
const deletionVerifiedParam = outputParams.find(p => p.Name === 'DeletionVerified');
|
|
108
|
-
if (deletionVerifiedParam) deletionVerifiedParam.Value = !verificationFailed;
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
Success: true,
|
|
112
|
-
ResultCode: 'SUCCESS',
|
|
113
|
-
Message: `Successfully deleted post ${postId}`,
|
|
114
|
-
Params: outputParams
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
} catch (error) {
|
|
118
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
119
|
-
|
|
120
|
-
// Handle specific error cases
|
|
121
|
-
if (error instanceof Error && error.message.includes('404')) {
|
|
122
|
-
return {
|
|
123
|
-
Success: false,
|
|
124
|
-
ResultCode: 'POST_NOT_FOUND',
|
|
125
|
-
Message: `Post ${this.getParamValue(Params, 'PostID')} not found or already deleted`,
|
|
126
|
-
Params
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
Success: false,
|
|
132
|
-
ResultCode: 'ERROR',
|
|
133
|
-
Message: `Failed to delete scheduled post: ${errorMessage}`,
|
|
134
|
-
Params
|
|
135
|
-
};
|
|
11
|
+
/**
|
|
12
|
+
* Delete a scheduled post from HootSuite
|
|
13
|
+
*/
|
|
14
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
15
|
+
const { Params, ContextUser } = params;
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
// Initialize OAuth
|
|
19
|
+
const companyIntegrationId = this.getParamValue(Params, 'CompanyIntegrationID');
|
|
20
|
+
if (!(await this.initializeOAuth(companyIntegrationId))) {
|
|
21
|
+
throw new Error('Failed to initialize OAuth connection');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Extract parameters
|
|
25
|
+
const postId = this.getParamValue(Params, 'PostID');
|
|
26
|
+
const confirmDeletion = this.getParamValue(Params, 'ConfirmDeletion') || false;
|
|
27
|
+
|
|
28
|
+
// Validate required parameters
|
|
29
|
+
if (!postId) {
|
|
30
|
+
throw new Error('PostID is required');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Safety check - require confirmation
|
|
34
|
+
if (!confirmDeletion) {
|
|
35
|
+
return {
|
|
36
|
+
Success: false,
|
|
37
|
+
ResultCode: 'CONFIRMATION_REQUIRED',
|
|
38
|
+
Message: 'Deletion not confirmed. Set ConfirmDeletion to true to proceed.',
|
|
39
|
+
Params,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// First, get the post details to verify it exists and can be deleted
|
|
44
|
+
LogStatus(`Fetching post ${postId} details...`);
|
|
45
|
+
let postDetails: any;
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const response = await this.axiosInstance.get(`/messages/${postId}`);
|
|
49
|
+
postDetails = response.data;
|
|
50
|
+
} catch (error: any) {
|
|
51
|
+
if (error.response?.status === 404) {
|
|
52
|
+
return {
|
|
53
|
+
Success: false,
|
|
54
|
+
ResultCode: 'POST_NOT_FOUND',
|
|
55
|
+
Message: `Post with ID ${postId} not found`,
|
|
56
|
+
Params,
|
|
57
|
+
};
|
|
136
58
|
}
|
|
137
|
-
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
138
61
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
{
|
|
161
|
-
Name: 'DeletionVerified',
|
|
162
|
-
Type: 'Output',
|
|
163
|
-
Value: null
|
|
164
|
-
}
|
|
165
|
-
];
|
|
166
|
-
}
|
|
62
|
+
// Check if post can be deleted
|
|
63
|
+
if (postDetails.state === 'PUBLISHED') {
|
|
64
|
+
return {
|
|
65
|
+
Success: false,
|
|
66
|
+
ResultCode: 'CANNOT_DELETE_PUBLISHED',
|
|
67
|
+
Message: 'Cannot delete published posts. Only scheduled, draft, or failed posts can be deleted.',
|
|
68
|
+
Params,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Store post details before deletion
|
|
73
|
+
const deletedPostInfo = {
|
|
74
|
+
id: postDetails.id,
|
|
75
|
+
content: postDetails.text,
|
|
76
|
+
state: postDetails.state,
|
|
77
|
+
scheduledTime: postDetails.scheduledTime,
|
|
78
|
+
profiles: postDetails.socialProfileIds,
|
|
79
|
+
mediaCount: postDetails.mediaIds?.length || 0,
|
|
80
|
+
tags: postDetails.tags || [],
|
|
81
|
+
deletedAt: new Date().toISOString(),
|
|
82
|
+
};
|
|
167
83
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
84
|
+
// Delete the post
|
|
85
|
+
LogStatus(`Deleting post ${postId}...`);
|
|
86
|
+
await this.axiosInstance.delete(`/messages/${postId}`);
|
|
87
|
+
|
|
88
|
+
// Verify deletion by trying to fetch the post again
|
|
89
|
+
let verificationFailed = false;
|
|
90
|
+
try {
|
|
91
|
+
await this.axiosInstance.get(`/messages/${postId}`);
|
|
92
|
+
verificationFailed = true;
|
|
93
|
+
} catch (error: any) {
|
|
94
|
+
if (error.response?.status !== 404) {
|
|
95
|
+
verificationFailed = true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (verificationFailed) {
|
|
100
|
+
LogStatus('Warning: Post deletion could not be verified');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Update output parameters
|
|
104
|
+
const outputParams = [...Params];
|
|
105
|
+
const deletedPostParam = outputParams.find((p) => p.Name === 'DeletedPostInfo');
|
|
106
|
+
if (deletedPostParam) deletedPostParam.Value = deletedPostInfo;
|
|
107
|
+
const deletionVerifiedParam = outputParams.find((p) => p.Name === 'DeletionVerified');
|
|
108
|
+
if (deletionVerifiedParam) deletionVerifiedParam.Value = !verificationFailed;
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
Success: true,
|
|
112
|
+
ResultCode: 'SUCCESS',
|
|
113
|
+
Message: `Successfully deleted post ${postId}`,
|
|
114
|
+
Params: outputParams,
|
|
115
|
+
};
|
|
116
|
+
} catch (error) {
|
|
117
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
118
|
+
|
|
119
|
+
// Handle specific error cases
|
|
120
|
+
if (error instanceof Error && error.message.includes('404')) {
|
|
121
|
+
return {
|
|
122
|
+
Success: false,
|
|
123
|
+
ResultCode: 'POST_NOT_FOUND',
|
|
124
|
+
Message: `Post ${this.getParamValue(Params, 'PostID')} not found or already deleted`,
|
|
125
|
+
Params,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
Success: false,
|
|
131
|
+
ResultCode: 'ERROR',
|
|
132
|
+
Message: `Failed to delete scheduled post: ${errorMessage}`,
|
|
133
|
+
Params,
|
|
134
|
+
};
|
|
173
135
|
}
|
|
174
|
-
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Define the parameters this action expects
|
|
140
|
+
*/
|
|
141
|
+
public get Params(): ActionParam[] {
|
|
142
|
+
return [
|
|
143
|
+
...this.oauthParams,
|
|
144
|
+
{
|
|
145
|
+
Name: 'PostID',
|
|
146
|
+
Type: 'Input',
|
|
147
|
+
Value: null,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
Name: 'ConfirmDeletion',
|
|
151
|
+
Type: 'Input',
|
|
152
|
+
Value: null,
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
Name: 'DeletedPostInfo',
|
|
156
|
+
Type: 'Output',
|
|
157
|
+
Value: null,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
Name: 'DeletionVerified',
|
|
161
|
+
Type: 'Output',
|
|
162
|
+
Value: null,
|
|
163
|
+
},
|
|
164
|
+
];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Get action description
|
|
169
|
+
*/
|
|
170
|
+
public get Description(): string {
|
|
171
|
+
return 'Deletes a scheduled post from HootSuite. Only SCHEDULED, DRAFT, or FAILED posts can be deleted. Published posts cannot be deleted.';
|
|
172
|
+
}
|
|
173
|
+
}
|