@memberjunction/actions-bizapps-social 2.112.0 → 2.113.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 +13 -0
- package/dist/base/base-social.action.d.ts.map +1 -1
- package/dist/base/base-social.action.js +24 -18
- 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 +34 -35
- 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 +36 -34
- 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 +27 -25
- 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 +23 -19
- 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 +32 -28
- 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 +44 -42
- 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 +39 -37
- 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 +59 -44
- 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 +31 -33
- 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 +32 -28
- 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 +26 -24
- 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 +34 -32
- 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 +52 -43
- 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 +28 -30
- 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 +20 -18
- 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 +26 -27
- 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 +59 -38
- 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 +25 -23
- 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 +60 -56
- 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 +27 -25
- 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 +45 -55
- 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 +29 -31
- 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 +23 -25
- 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 +30 -32
- 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 +30 -28
- 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 +38 -33
- 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 +26 -25
- 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 +29 -25
- 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 +47 -40
- 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 +31 -30
- 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 +58 -56
- 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 +68 -58
- 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 +25 -22
- package/dist/providers/youtube/youtube-base.action.js.map +1 -1
- package/package.json +6 -5
- package/src/base/base-social.action.ts +224 -217
- package/src/providers/buffer/buffer-base.action.ts +441 -435
- package/src/providers/facebook/actions/boost-post.action.ts +386 -350
- package/src/providers/facebook/actions/create-album.action.ts +307 -291
- package/src/providers/facebook/actions/create-post.action.ts +227 -224
- package/src/providers/facebook/actions/get-page-insights.action.ts +403 -383
- package/src/providers/facebook/actions/get-page-posts.action.ts +225 -214
- package/src/providers/facebook/actions/get-post-insights.action.ts +316 -300
- package/src/providers/facebook/actions/respond-to-comments.action.ts +336 -319
- package/src/providers/facebook/actions/schedule-post.action.ts +292 -289
- package/src/providers/facebook/actions/search-posts.action.ts +413 -399
- package/src/providers/facebook/facebook-base.action.ts +670 -653
- package/src/providers/hootsuite/actions/bulk-schedule-posts.action.ts +257 -257
- package/src/providers/hootsuite/actions/create-scheduled-post.action.ts +189 -184
- package/src/providers/hootsuite/actions/delete-scheduled-post.action.ts +161 -160
- package/src/providers/hootsuite/actions/get-analytics.action.ts +254 -249
- package/src/providers/hootsuite/actions/get-scheduled-posts.action.ts +207 -206
- package/src/providers/hootsuite/actions/get-social-profiles.action.ts +205 -206
- package/src/providers/hootsuite/actions/search-posts.action.ts +369 -351
- package/src/providers/hootsuite/actions/update-scheduled-post.action.ts +209 -211
- package/src/providers/hootsuite/hootsuite-base.action.ts +307 -301
- package/src/providers/instagram/actions/create-post.action.ts +296 -276
- package/src/providers/instagram/actions/create-story.action.ts +394 -378
- package/src/providers/instagram/actions/get-account-insights.action.ts +420 -384
- package/src/providers/instagram/actions/get-business-posts.action.ts +242 -233
- package/src/providers/instagram/actions/get-comments.action.ts +377 -365
- package/src/providers/instagram/actions/get-post-insights.action.ts +273 -265
- package/src/providers/instagram/actions/schedule-post.action.ts +235 -233
- package/src/providers/instagram/actions/search-posts.action.ts +538 -512
- package/src/providers/instagram/instagram-base.action.ts +393 -368
- package/src/providers/linkedin/actions/create-article.action.ts +266 -275
- package/src/providers/linkedin/actions/create-post.action.ts +177 -179
- package/src/providers/linkedin/actions/get-followers.action.ts +211 -211
- package/src/providers/linkedin/actions/get-organization-posts.action.ts +147 -146
- package/src/providers/linkedin/actions/get-personal-posts.action.ts +139 -138
- package/src/providers/linkedin/actions/get-post-analytics.action.ts +189 -190
- package/src/providers/linkedin/actions/schedule-post.action.ts +189 -191
- package/src/providers/linkedin/actions/search-posts.action.ts +283 -275
- package/src/providers/linkedin/linkedin-base.action.ts +421 -407
- package/src/providers/tiktok/tiktok-base.action.ts +320 -305
- package/src/providers/twitter/actions/create-thread.action.ts +207 -203
- package/src/providers/twitter/actions/create-tweet.action.ts +188 -187
- package/src/providers/twitter/actions/delete-tweet.action.ts +129 -128
- package/src/providers/twitter/actions/get-analytics.action.ts +411 -402
- package/src/providers/twitter/actions/get-mentions.action.ts +219 -218
- package/src/providers/twitter/actions/get-timeline.action.ts +233 -232
- package/src/providers/twitter/actions/schedule-tweet.action.ts +222 -221
- package/src/providers/twitter/actions/search-tweets.action.ts +543 -540
- package/src/providers/twitter/twitter-base.action.ts +560 -541
- package/src/providers/youtube/youtube-base.action.ts +333 -320
|
@@ -2,240 +2,243 @@ import { RegisterClass } from '@memberjunction/global';
|
|
|
2
2
|
import { FacebookBaseAction, CreatePostData } from '../facebook-base.action';
|
|
3
3
|
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
4
|
import { MediaFile, SocialMediaErrorCode } from '../../../base/base-social.action';
|
|
5
|
-
import { LogStatus, LogError } from '@memberjunction/
|
|
5
|
+
import { LogStatus, LogError } from '@memberjunction/core';
|
|
6
6
|
import { BaseAction } from '@memberjunction/actions';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Creates a new post on a Facebook page.
|
|
10
10
|
* Supports text, links, images, videos, and scheduling.
|
|
11
11
|
*/
|
|
12
|
-
@RegisterClass(BaseAction, 'FacebookCreatePostAction')
|
|
12
|
+
@RegisterClass(BaseAction, 'FacebookCreatePostAction')
|
|
13
13
|
export class FacebookCreatePostAction extends FacebookBaseAction {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Define the parameters for this action
|
|
23
|
-
*/
|
|
24
|
-
public get Params(): ActionParam[] {
|
|
25
|
-
return [
|
|
26
|
-
...this.commonSocialParams,
|
|
27
|
-
{
|
|
28
|
-
Name: 'PageID',
|
|
29
|
-
Type: 'Input',
|
|
30
|
-
Value: null,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
Name: 'Content',
|
|
34
|
-
Type: 'Input',
|
|
35
|
-
Value: null,
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
Name: 'Link',
|
|
39
|
-
Type: 'Input',
|
|
40
|
-
Value: null,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
Name: 'MediaFiles',
|
|
44
|
-
Type: 'Input',
|
|
45
|
-
Value: null,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
Name: 'ScheduledTime',
|
|
49
|
-
Type: 'Input',
|
|
50
|
-
Value: null,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
Name: 'Tags',
|
|
54
|
-
Type: 'Input',
|
|
55
|
-
Value: null,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
Name: 'PlaceID',
|
|
59
|
-
Type: 'Input',
|
|
60
|
-
Value: null,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
Name: 'Privacy',
|
|
64
|
-
Type: 'Input',
|
|
65
|
-
Value: null,
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
Name: 'Published',
|
|
69
|
-
Type: 'Input',
|
|
70
|
-
Value: true,
|
|
71
|
-
},
|
|
72
|
-
];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Execute the action
|
|
77
|
-
*/
|
|
78
|
-
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
79
|
-
const { Params, ContextUser } = params;
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
// Validate required parameters
|
|
83
|
-
const companyIntegrationId = this.getParamValue(Params, 'CompanyIntegrationID');
|
|
84
|
-
const pageId = this.getParamValue(Params, 'PageID');
|
|
85
|
-
|
|
86
|
-
if (!companyIntegrationId) {
|
|
87
|
-
return {
|
|
88
|
-
Success: false,
|
|
89
|
-
Message: 'CompanyIntegrationID is required',
|
|
90
|
-
ResultCode: 'INVALID_TOKEN',
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (!pageId) {
|
|
95
|
-
return {
|
|
96
|
-
Success: false,
|
|
97
|
-
Message: 'PageID is required',
|
|
98
|
-
ResultCode: 'MISSING_REQUIRED_PARAM',
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Initialize OAuth
|
|
103
|
-
if (!(await this.initializeOAuth(companyIntegrationId))) {
|
|
104
|
-
return {
|
|
105
|
-
Success: false,
|
|
106
|
-
Message: 'Failed to initialize Facebook OAuth connection',
|
|
107
|
-
ResultCode: 'INVALID_TOKEN',
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Get parameters
|
|
112
|
-
const content = this.getParamValue(Params, 'Content') as string;
|
|
113
|
-
const link = this.getParamValue(Params, 'Link') as string;
|
|
114
|
-
const mediaFiles = this.getParamValue(Params, 'MediaFiles') as MediaFile[];
|
|
115
|
-
const scheduledTime = this.getParamValue(Params, 'ScheduledTime') as string;
|
|
116
|
-
const tags = this.getParamValue(Params, 'Tags') as string[];
|
|
117
|
-
const placeId = this.getParamValue(Params, 'PlaceID') as string;
|
|
118
|
-
const privacy = this.getParamValue(Params, 'Privacy') as string;
|
|
119
|
-
const published = this.getParamValue(Params, 'Published') !== false;
|
|
120
|
-
|
|
121
|
-
// Validate that we have some content
|
|
122
|
-
if (!content && !link && (!mediaFiles || mediaFiles.length === 0)) {
|
|
123
|
-
return {
|
|
124
|
-
Success: false,
|
|
125
|
-
Message: 'At least one of Content, Link, or MediaFiles is required',
|
|
126
|
-
ResultCode: 'MISSING_CONTENT',
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Build post data
|
|
131
|
-
const postData: CreatePostData = {};
|
|
132
|
-
|
|
133
|
-
if (content) {
|
|
134
|
-
postData.message = content;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (link) {
|
|
138
|
-
postData.link = link;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (placeId) {
|
|
142
|
-
postData.place = placeId;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (tags && tags.length > 0) {
|
|
146
|
-
postData.tags = tags;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (privacy) {
|
|
150
|
-
postData.privacy = {
|
|
151
|
-
value: privacy as 'EVERYONE' | 'ALL_FRIENDS' | 'FRIENDS_OF_FRIENDS' | 'SELF',
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
postData.published = published;
|
|
156
|
-
|
|
157
|
-
// Handle scheduling
|
|
158
|
-
if (scheduledTime) {
|
|
159
|
-
const scheduledDate = new Date(scheduledTime);
|
|
160
|
-
const now = new Date();
|
|
161
|
-
const minScheduleTime = new Date(now.getTime() + 10 * 60 * 1000); // 10 minutes from now
|
|
162
|
-
const maxScheduleTime = new Date(now.getTime() + 180 * 24 * 60 * 60 * 1000); // 6 months from now
|
|
163
|
-
|
|
164
|
-
if (scheduledDate < minScheduleTime) {
|
|
165
|
-
return {
|
|
166
|
-
Success: false,
|
|
167
|
-
Message: 'Scheduled time must be at least 10 minutes in the future',
|
|
168
|
-
ResultCode: 'INVALID_SCHEDULE_TIME',
|
|
169
|
-
};
|
|
170
|
-
}
|
|
14
|
+
/**
|
|
15
|
+
* Get action description
|
|
16
|
+
*/
|
|
17
|
+
public get Description(): string {
|
|
18
|
+
return 'Creates a new post on a Facebook page with optional media attachments and scheduling';
|
|
19
|
+
}
|
|
171
20
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Define the parameters for this action
|
|
23
|
+
*/
|
|
24
|
+
public get Params(): ActionParam[] {
|
|
25
|
+
return [
|
|
26
|
+
...this.commonSocialParams,
|
|
27
|
+
{
|
|
28
|
+
Name: 'PageID',
|
|
29
|
+
Type: 'Input',
|
|
30
|
+
Value: null,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
Name: 'Content',
|
|
34
|
+
Type: 'Input',
|
|
35
|
+
Value: null,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
Name: 'Link',
|
|
39
|
+
Type: 'Input',
|
|
40
|
+
Value: null,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
Name: 'MediaFiles',
|
|
44
|
+
Type: 'Input',
|
|
45
|
+
Value: null,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
Name: 'ScheduledTime',
|
|
49
|
+
Type: 'Input',
|
|
50
|
+
Value: null,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
Name: 'Tags',
|
|
54
|
+
Type: 'Input',
|
|
55
|
+
Value: null,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
Name: 'PlaceID',
|
|
59
|
+
Type: 'Input',
|
|
60
|
+
Value: null,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
Name: 'Privacy',
|
|
64
|
+
Type: 'Input',
|
|
65
|
+
Value: null,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
Name: 'Published',
|
|
69
|
+
Type: 'Input',
|
|
70
|
+
Value: true,
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
}
|
|
179
74
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Execute the action
|
|
77
|
+
*/
|
|
78
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
79
|
+
const { Params, ContextUser } = params;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
// Validate required parameters
|
|
83
|
+
const companyIntegrationId = this.getParamValue(Params, 'CompanyIntegrationID');
|
|
84
|
+
const pageId = this.getParamValue(Params, 'PageID');
|
|
85
|
+
|
|
86
|
+
if (!companyIntegrationId) {
|
|
87
|
+
return {
|
|
88
|
+
Success: false,
|
|
89
|
+
Message: 'CompanyIntegrationID is required',
|
|
90
|
+
ResultCode: 'INVALID_TOKEN'
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!pageId) {
|
|
95
|
+
return {
|
|
96
|
+
Success: false,
|
|
97
|
+
Message: 'PageID is required',
|
|
98
|
+
ResultCode: 'MISSING_REQUIRED_PARAM'
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Initialize OAuth
|
|
103
|
+
if (!await this.initializeOAuth(companyIntegrationId)) {
|
|
104
|
+
return {
|
|
105
|
+
Success: false,
|
|
106
|
+
Message: 'Failed to initialize Facebook OAuth connection',
|
|
107
|
+
ResultCode: 'INVALID_TOKEN'
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Get parameters
|
|
112
|
+
const content = this.getParamValue(Params, 'Content') as string;
|
|
113
|
+
const link = this.getParamValue(Params, 'Link') as string;
|
|
114
|
+
const mediaFiles = this.getParamValue(Params, 'MediaFiles') as MediaFile[];
|
|
115
|
+
const scheduledTime = this.getParamValue(Params, 'ScheduledTime') as string;
|
|
116
|
+
const tags = this.getParamValue(Params, 'Tags') as string[];
|
|
117
|
+
const placeId = this.getParamValue(Params, 'PlaceID') as string;
|
|
118
|
+
const privacy = this.getParamValue(Params, 'Privacy') as string;
|
|
119
|
+
const published = this.getParamValue(Params, 'Published') !== false;
|
|
120
|
+
|
|
121
|
+
// Validate that we have some content
|
|
122
|
+
if (!content && !link && (!mediaFiles || mediaFiles.length === 0)) {
|
|
123
|
+
return {
|
|
124
|
+
Success: false,
|
|
125
|
+
Message: 'At least one of Content, Link, or MediaFiles is required',
|
|
126
|
+
ResultCode: 'MISSING_CONTENT'
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Build post data
|
|
131
|
+
const postData: CreatePostData = {};
|
|
132
|
+
|
|
133
|
+
if (content) {
|
|
134
|
+
postData.message = content;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (link) {
|
|
138
|
+
postData.link = link;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (placeId) {
|
|
142
|
+
postData.place = placeId;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (tags && tags.length > 0) {
|
|
146
|
+
postData.tags = tags;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (privacy) {
|
|
150
|
+
postData.privacy = {
|
|
151
|
+
value: privacy as 'EVERYONE' | 'ALL_FRIENDS' | 'FRIENDS_OF_FRIENDS' | 'SELF'
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
postData.published = published;
|
|
156
|
+
|
|
157
|
+
// Handle scheduling
|
|
158
|
+
if (scheduledTime) {
|
|
159
|
+
const scheduledDate = new Date(scheduledTime);
|
|
160
|
+
const now = new Date();
|
|
161
|
+
const minScheduleTime = new Date(now.getTime() + 10 * 60 * 1000); // 10 minutes from now
|
|
162
|
+
const maxScheduleTime = new Date(now.getTime() + 180 * 24 * 60 * 60 * 1000); // 6 months from now
|
|
163
|
+
|
|
164
|
+
if (scheduledDate < minScheduleTime) {
|
|
165
|
+
return {
|
|
166
|
+
Success: false,
|
|
167
|
+
Message: 'Scheduled time must be at least 10 minutes in the future',
|
|
168
|
+
ResultCode: 'INVALID_SCHEDULE_TIME'
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (scheduledDate > maxScheduleTime) {
|
|
173
|
+
return {
|
|
174
|
+
Success: false,
|
|
175
|
+
Message: 'Scheduled time cannot be more than 6 months in the future',
|
|
176
|
+
ResultCode: 'INVALID_SCHEDULE_TIME'
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
postData.scheduled_publish_time = Math.floor(scheduledDate.getTime() / 1000);
|
|
181
|
+
postData.published = false; // Must be unpublished when scheduling
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Handle media uploads
|
|
185
|
+
if (mediaFiles && mediaFiles.length > 0) {
|
|
186
|
+
LogStatus(`Uploading ${mediaFiles.length} media files to Facebook...`);
|
|
187
|
+
|
|
188
|
+
const mediaIds: string[] = [];
|
|
189
|
+
for (const file of mediaFiles) {
|
|
190
|
+
try {
|
|
191
|
+
const mediaId = await this.uploadMediaToPage(pageId, file);
|
|
192
|
+
mediaIds.push(mediaId);
|
|
193
|
+
LogStatus(`Uploaded media: ${file.filename}`);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
LogError(`Failed to upload media ${file.filename}: ${error}`);
|
|
196
|
+
return {
|
|
197
|
+
Success: false,
|
|
198
|
+
Message: `Failed to upload media: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
199
|
+
ResultCode: 'INVALID_MEDIA'
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Attach media to post
|
|
205
|
+
postData.attached_media = mediaIds.map(id => ({ media_fbid: id }));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Create the post
|
|
209
|
+
LogStatus('Creating Facebook post...');
|
|
210
|
+
const post = await this.createPost(pageId, postData);
|
|
211
|
+
|
|
212
|
+
LogStatus(`Facebook post created successfully: ${post.id}`);
|
|
213
|
+
|
|
214
|
+
// Return normalized post data
|
|
215
|
+
const normalizedPost = this.normalizePost(post);
|
|
216
|
+
|
|
217
|
+
// Update output parameters
|
|
218
|
+
const outputParams = [...Params];
|
|
219
|
+
// TODO: Set output parameters based on result
|
|
220
|
+
|
|
196
221
|
return {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
222
|
+
Success: true,
|
|
223
|
+
Message: scheduledTime ? 'Post scheduled successfully' : 'Post created successfully',
|
|
224
|
+
ResultCode: 'SUCCESS',
|
|
225
|
+
Params: outputParams
|
|
200
226
|
};
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
227
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
// Update output parameters
|
|
218
|
-
const outputParams = [...Params];
|
|
219
|
-
// TODO: Set output parameters based on result
|
|
220
|
-
|
|
221
|
-
return {
|
|
222
|
-
Success: true,
|
|
223
|
-
Message: scheduledTime ? 'Post scheduled successfully' : 'Post created successfully',
|
|
224
|
-
ResultCode: 'SUCCESS',
|
|
225
|
-
Params: outputParams,
|
|
226
|
-
};
|
|
227
|
-
} catch (error) {
|
|
228
|
-
LogError(`Failed to create Facebook post: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
229
|
-
|
|
230
|
-
if (this.isAuthError(error)) {
|
|
231
|
-
return this.handleOAuthError(error);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return {
|
|
235
|
-
Success: false,
|
|
236
|
-
Message: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
237
|
-
ResultCode: 'ERROR',
|
|
238
|
-
};
|
|
228
|
+
} catch (error) {
|
|
229
|
+
LogError(`Failed to create Facebook post: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
230
|
+
|
|
231
|
+
if (this.isAuthError(error)) {
|
|
232
|
+
return this.handleOAuthError(error);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return {
|
|
236
|
+
Success: false,
|
|
237
|
+
Message: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
238
|
+
ResultCode: 'ERROR'
|
|
239
|
+
};
|
|
240
|
+
}
|
|
239
241
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
}
|