@muench-dev/n8n-nodes-bluesky 3.1.0 → 4.0.2
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/README.md +151 -24
- package/dist/nodes/Bluesky/V2/BlueskyV2.node.d.ts +1 -1
- package/dist/nodes/Bluesky/V2/BlueskyV2.node.js +212 -128
- package/dist/nodes/Bluesky/V2/BlueskyV2.node.js.map +1 -1
- package/dist/nodes/Bluesky/V2/__tests__/analyticsOperations.test.d.ts +1 -0
- package/dist/nodes/Bluesky/V2/__tests__/analyticsOperations.test.js +99 -0
- package/dist/nodes/Bluesky/V2/__tests__/analyticsOperations.test.js.map +1 -0
- package/dist/nodes/Bluesky/V2/__tests__/graphOperations.test.d.ts +1 -0
- package/dist/nodes/Bluesky/V2/__tests__/graphOperations.test.js +19 -0
- package/dist/nodes/Bluesky/V2/__tests__/graphOperations.test.js.map +1 -0
- package/dist/nodes/Bluesky/V2/__tests__/listOperations.test.d.ts +1 -0
- package/dist/nodes/Bluesky/V2/__tests__/listOperations.test.js +97 -0
- package/dist/nodes/Bluesky/V2/__tests__/listOperations.test.js.map +1 -0
- package/dist/nodes/Bluesky/V2/__tests__/postOperations.test.js +70 -8
- package/dist/nodes/Bluesky/V2/__tests__/postOperations.test.js.map +1 -1
- package/dist/nodes/Bluesky/V2/__tests__/searchOperations.test.d.ts +1 -0
- package/dist/nodes/Bluesky/V2/__tests__/searchOperations.test.js +41 -0
- package/dist/nodes/Bluesky/V2/__tests__/searchOperations.test.js.map +1 -0
- package/dist/nodes/Bluesky/V2/analyticsOperations.d.ts +7 -0
- package/dist/nodes/Bluesky/V2/analyticsOperations.js +236 -0
- package/dist/nodes/Bluesky/V2/analyticsOperations.js.map +1 -0
- package/dist/nodes/Bluesky/V2/feedOperations.d.ts +3 -2
- package/dist/nodes/Bluesky/V2/feedOperations.js +113 -13
- package/dist/nodes/Bluesky/V2/feedOperations.js.map +1 -1
- package/dist/nodes/Bluesky/V2/graphOperations.d.ts +4 -0
- package/dist/nodes/Bluesky/V2/graphOperations.js +45 -0
- package/dist/nodes/Bluesky/V2/graphOperations.js.map +1 -0
- package/dist/nodes/Bluesky/V2/listOperations.d.ts +10 -0
- package/dist/nodes/Bluesky/V2/listOperations.js +302 -0
- package/dist/nodes/Bluesky/V2/listOperations.js.map +1 -0
- package/dist/nodes/Bluesky/V2/postOperations.d.ts +21 -9
- package/dist/nodes/Bluesky/V2/postOperations.js +342 -232
- package/dist/nodes/Bluesky/V2/postOperations.js.map +1 -1
- package/dist/nodes/Bluesky/V2/resources.js +18 -2
- package/dist/nodes/Bluesky/V2/resources.js.map +1 -1
- package/dist/nodes/Bluesky/V2/searchOperations.d.ts +5 -0
- package/dist/nodes/Bluesky/V2/searchOperations.js +95 -0
- package/dist/nodes/Bluesky/V2/searchOperations.js.map +1 -0
- package/dist/nodes/Bluesky/V2/userOperations.d.ts +2 -0
- package/dist/nodes/Bluesky/V2/userOperations.js +137 -34
- package/dist/nodes/Bluesky/V2/userOperations.js.map +1 -1
- package/dist/package.json +10 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +80 -66
|
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.postProperties = void 0;
|
|
7
7
|
exports.postOperation = postOperation;
|
|
8
|
+
exports.replyOperation = replyOperation;
|
|
9
|
+
exports.quoteOperation = quoteOperation;
|
|
8
10
|
exports.deletePostOperation = deletePostOperation;
|
|
9
11
|
exports.likeOperation = likeOperation;
|
|
10
12
|
exports.deleteLikeOperation = deleteLikeOperation;
|
|
@@ -13,10 +15,11 @@ exports.deleteRepostOperation = deleteRepostOperation;
|
|
|
13
15
|
const api_1 = require("@atproto/api");
|
|
14
16
|
const sharp_1 = __importDefault(require("sharp"));
|
|
15
17
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
16
|
-
const languages_1 = require("./languages");
|
|
17
18
|
const open_graph_scraper_1 = __importDefault(require("open-graph-scraper"));
|
|
19
|
+
const languages_1 = require("./languages");
|
|
18
20
|
const IMAGE_SIZE_LIMIT = 976.56 * 1024;
|
|
19
21
|
const MAX_IMAGE_WIDTH = 1000;
|
|
22
|
+
const MAX_IMAGES = 4;
|
|
20
23
|
exports.postProperties = [
|
|
21
24
|
{
|
|
22
25
|
displayName: 'Operation',
|
|
@@ -29,36 +32,14 @@ exports.postProperties = [
|
|
|
29
32
|
name: 'operation',
|
|
30
33
|
noDataExpression: true,
|
|
31
34
|
options: [
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
action: 'Delete a post',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'Delete Repost',
|
|
44
|
-
value: 'deleteRepost',
|
|
45
|
-
action: 'Delete a repost',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'Like a Post',
|
|
49
|
-
value: 'like',
|
|
50
|
-
action: 'Like a post',
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: 'Repost a Post',
|
|
54
|
-
value: 'repost',
|
|
55
|
-
action: 'Repost a post',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: 'Unline a Post',
|
|
59
|
-
value: 'deleteLike',
|
|
60
|
-
action: 'Unlike a post',
|
|
61
|
-
},
|
|
35
|
+
{ name: 'Create a Post', value: 'post', action: 'Create a post' },
|
|
36
|
+
{ name: 'Delete a Post', value: 'deletePost', action: 'Delete a post' },
|
|
37
|
+
{ name: 'Delete Repost', value: 'deleteRepost', action: 'Delete a repost' },
|
|
38
|
+
{ name: 'Like a Post', value: 'like', action: 'Like a post' },
|
|
39
|
+
{ name: 'Quote a Post', value: 'quote', action: 'Quote a post' },
|
|
40
|
+
{ name: 'Reply to a Post', value: 'reply', action: 'Reply to a post' },
|
|
41
|
+
{ name: 'Repost a Post', value: 'repost', action: 'Repost a post' },
|
|
42
|
+
{ name: 'Unline a Post', value: 'deleteLike', action: 'Unlike a post' },
|
|
62
43
|
],
|
|
63
44
|
type: 'options',
|
|
64
45
|
},
|
|
@@ -74,6 +55,32 @@ exports.postProperties = [
|
|
|
74
55
|
},
|
|
75
56
|
},
|
|
76
57
|
},
|
|
58
|
+
{
|
|
59
|
+
displayName: 'Reply Text',
|
|
60
|
+
name: 'replyText',
|
|
61
|
+
type: 'string',
|
|
62
|
+
default: '',
|
|
63
|
+
required: true,
|
|
64
|
+
displayOptions: {
|
|
65
|
+
show: {
|
|
66
|
+
resource: ['post'],
|
|
67
|
+
operation: ['reply'],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
displayName: 'Quote Text',
|
|
73
|
+
name: 'quoteText',
|
|
74
|
+
type: 'string',
|
|
75
|
+
default: '',
|
|
76
|
+
required: true,
|
|
77
|
+
displayOptions: {
|
|
78
|
+
show: {
|
|
79
|
+
resource: ['post'],
|
|
80
|
+
operation: ['quote'],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
77
84
|
{
|
|
78
85
|
displayName: 'Language Names or IDs',
|
|
79
86
|
name: 'langs',
|
|
@@ -88,6 +95,34 @@ exports.postProperties = [
|
|
|
88
95
|
},
|
|
89
96
|
},
|
|
90
97
|
},
|
|
98
|
+
{
|
|
99
|
+
displayName: 'Reply Languages',
|
|
100
|
+
name: 'replyLangs',
|
|
101
|
+
type: 'multiOptions',
|
|
102
|
+
description: 'Choose from the list of supported languages. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
|
103
|
+
options: (0, languages_1.getLanguageOptions)(),
|
|
104
|
+
default: ['en'],
|
|
105
|
+
displayOptions: {
|
|
106
|
+
show: {
|
|
107
|
+
resource: ['post'],
|
|
108
|
+
operation: ['reply'],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
displayName: 'Quote Languages',
|
|
114
|
+
name: 'quoteLangs',
|
|
115
|
+
type: 'multiOptions',
|
|
116
|
+
description: 'Choose from the list of supported languages. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
|
117
|
+
options: (0, languages_1.getLanguageOptions)(),
|
|
118
|
+
default: ['en'],
|
|
119
|
+
displayOptions: {
|
|
120
|
+
show: {
|
|
121
|
+
resource: ['post'],
|
|
122
|
+
operation: ['quote'],
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
91
126
|
{
|
|
92
127
|
displayName: 'Uri',
|
|
93
128
|
name: 'uri',
|
|
@@ -98,7 +133,7 @@ exports.postProperties = [
|
|
|
98
133
|
displayOptions: {
|
|
99
134
|
show: {
|
|
100
135
|
resource: ['post'],
|
|
101
|
-
operation: ['deletePost', 'like', 'deleteLike', 'repost'],
|
|
136
|
+
operation: ['deletePost', 'like', 'deleteLike', 'repost', 'reply', 'quote'],
|
|
102
137
|
},
|
|
103
138
|
},
|
|
104
139
|
},
|
|
@@ -112,7 +147,7 @@ exports.postProperties = [
|
|
|
112
147
|
displayOptions: {
|
|
113
148
|
show: {
|
|
114
149
|
resource: ['post'],
|
|
115
|
-
operation: ['like', 'repost'],
|
|
150
|
+
operation: ['like', 'repost', 'reply', 'quote'],
|
|
116
151
|
},
|
|
117
152
|
},
|
|
118
153
|
},
|
|
@@ -127,19 +162,13 @@ exports.postProperties = [
|
|
|
127
162
|
displayName: 'Details',
|
|
128
163
|
name: 'details',
|
|
129
164
|
values: [
|
|
130
|
-
{
|
|
131
|
-
displayName: 'URI',
|
|
132
|
-
name: 'uri',
|
|
133
|
-
type: 'string',
|
|
134
|
-
default: '',
|
|
135
|
-
required: true,
|
|
136
|
-
},
|
|
165
|
+
{ displayName: 'URI', name: 'uri', type: 'string', default: '', required: true },
|
|
137
166
|
{
|
|
138
167
|
displayName: 'Fetch Open Graph Tags',
|
|
139
168
|
name: 'fetchOpenGraphTags',
|
|
140
169
|
type: 'boolean',
|
|
141
170
|
description: 'Whether to fetch open graph tags from the website',
|
|
142
|
-
hint: 'If enabled, the node will fetch
|
|
171
|
+
hint: 'If enabled, the node will fetch open graph tags from the provided URL and use them to create the website card',
|
|
143
172
|
default: false,
|
|
144
173
|
},
|
|
145
174
|
{
|
|
@@ -148,22 +177,14 @@ exports.postProperties = [
|
|
|
148
177
|
type: 'string',
|
|
149
178
|
default: '',
|
|
150
179
|
required: true,
|
|
151
|
-
displayOptions: {
|
|
152
|
-
show: {
|
|
153
|
-
fetchOpenGraphTags: [false],
|
|
154
|
-
},
|
|
155
|
-
}
|
|
180
|
+
displayOptions: { show: { fetchOpenGraphTags: [false] } },
|
|
156
181
|
},
|
|
157
182
|
{
|
|
158
183
|
displayName: 'Description',
|
|
159
184
|
name: 'description',
|
|
160
185
|
type: 'string',
|
|
161
186
|
default: '',
|
|
162
|
-
displayOptions: {
|
|
163
|
-
show: {
|
|
164
|
-
fetchOpenGraphTags: [false],
|
|
165
|
-
},
|
|
166
|
-
}
|
|
187
|
+
displayOptions: { show: { fetchOpenGraphTags: [false] } },
|
|
167
188
|
},
|
|
168
189
|
{
|
|
169
190
|
displayName: 'Binary Property',
|
|
@@ -171,11 +192,7 @@ exports.postProperties = [
|
|
|
171
192
|
type: 'string',
|
|
172
193
|
default: '',
|
|
173
194
|
description: 'Name of the binary property containing the thumbnail image',
|
|
174
|
-
displayOptions: {
|
|
175
|
-
show: {
|
|
176
|
-
fetchOpenGraphTags: [false],
|
|
177
|
-
},
|
|
178
|
-
}
|
|
195
|
+
displayOptions: { show: { fetchOpenGraphTags: [false] } },
|
|
179
196
|
},
|
|
180
197
|
],
|
|
181
198
|
},
|
|
@@ -183,10 +200,66 @@ exports.postProperties = [
|
|
|
183
200
|
displayOptions: {
|
|
184
201
|
show: {
|
|
185
202
|
resource: ['post'],
|
|
186
|
-
operation: ['post'],
|
|
203
|
+
operation: ['post', 'reply'],
|
|
204
|
+
includeMedia: [false],
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
displayName: 'Include Media',
|
|
210
|
+
name: 'includeMedia',
|
|
211
|
+
type: 'boolean',
|
|
212
|
+
default: false,
|
|
213
|
+
description: 'Whether to include media attachments',
|
|
214
|
+
displayOptions: {
|
|
215
|
+
show: {
|
|
216
|
+
resource: ['post'],
|
|
217
|
+
operation: ['post', 'reply'],
|
|
187
218
|
},
|
|
188
219
|
},
|
|
189
220
|
},
|
|
221
|
+
{
|
|
222
|
+
displayName: 'Media Items',
|
|
223
|
+
name: 'mediaItems',
|
|
224
|
+
type: 'fixedCollection',
|
|
225
|
+
default: {},
|
|
226
|
+
placeholder: 'Add Media Item',
|
|
227
|
+
typeOptions: {
|
|
228
|
+
multiple: true,
|
|
229
|
+
multipleValueButtonText: 'Add Media',
|
|
230
|
+
sortable: true,
|
|
231
|
+
},
|
|
232
|
+
displayOptions: {
|
|
233
|
+
show: {
|
|
234
|
+
resource: ['post'],
|
|
235
|
+
operation: ['post', 'reply'],
|
|
236
|
+
includeMedia: [true],
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
options: [
|
|
240
|
+
{
|
|
241
|
+
displayName: 'Media',
|
|
242
|
+
name: 'media',
|
|
243
|
+
values: [
|
|
244
|
+
{
|
|
245
|
+
displayName: 'Binary Property',
|
|
246
|
+
name: 'binaryPropertyName',
|
|
247
|
+
type: 'string',
|
|
248
|
+
default: 'data',
|
|
249
|
+
required: true,
|
|
250
|
+
description: 'Name of the binary property containing the image data',
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
displayName: 'Alt Text',
|
|
254
|
+
name: 'altText',
|
|
255
|
+
type: 'string',
|
|
256
|
+
default: '',
|
|
257
|
+
description: 'Alt text for accessibility',
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
},
|
|
190
263
|
{
|
|
191
264
|
displayName: 'Image',
|
|
192
265
|
name: 'image',
|
|
@@ -198,13 +271,7 @@ exports.postProperties = [
|
|
|
198
271
|
displayName: 'Details',
|
|
199
272
|
name: 'details',
|
|
200
273
|
values: [
|
|
201
|
-
{
|
|
202
|
-
displayName: 'ALT',
|
|
203
|
-
name: 'alt',
|
|
204
|
-
type: 'string',
|
|
205
|
-
default: '',
|
|
206
|
-
required: true,
|
|
207
|
-
},
|
|
274
|
+
{ displayName: 'ALT', name: 'alt', type: 'string', default: '', required: true },
|
|
208
275
|
{
|
|
209
276
|
displayName: 'mimeType',
|
|
210
277
|
name: 'mimeType',
|
|
@@ -212,18 +279,8 @@ exports.postProperties = [
|
|
|
212
279
|
default: '',
|
|
213
280
|
required: true,
|
|
214
281
|
},
|
|
215
|
-
{
|
|
216
|
-
|
|
217
|
-
name: 'width',
|
|
218
|
-
type: 'number',
|
|
219
|
-
default: 400,
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
displayName: 'Height',
|
|
223
|
-
name: 'height',
|
|
224
|
-
type: 'number',
|
|
225
|
-
default: 300,
|
|
226
|
-
},
|
|
282
|
+
{ displayName: 'Width', name: 'width', type: 'number', default: 400 },
|
|
283
|
+
{ displayName: 'Height', name: 'height', type: 'number', default: 300 },
|
|
227
284
|
{
|
|
228
285
|
displayName: 'Binary Property',
|
|
229
286
|
name: 'binary',
|
|
@@ -238,6 +295,7 @@ exports.postProperties = [
|
|
|
238
295
|
show: {
|
|
239
296
|
resource: ['post'],
|
|
240
297
|
operation: ['post'],
|
|
298
|
+
includeMedia: [false],
|
|
241
299
|
},
|
|
242
300
|
},
|
|
243
301
|
},
|
|
@@ -268,203 +326,255 @@ async function resizeImageIfNeeded(imageBuffer, maxWidth, maxSizeBytes) {
|
|
|
268
326
|
}
|
|
269
327
|
return buffer;
|
|
270
328
|
}
|
|
271
|
-
async function
|
|
272
|
-
const
|
|
273
|
-
let rt = new api_1.RichText({ text: postText });
|
|
329
|
+
async function createRichText(agent, text) {
|
|
330
|
+
const rt = new api_1.RichText({ text });
|
|
274
331
|
try {
|
|
275
332
|
await rt.detectFacets(agent);
|
|
276
333
|
}
|
|
277
334
|
catch (facetsErr) {
|
|
278
335
|
n8n_workflow_1.LoggerProxy.error(`Failed to detect facets in post text: ${(facetsErr === null || facetsErr === void 0 ? void 0 : facetsErr.message) || facetsErr}`);
|
|
279
336
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
};
|
|
337
|
+
return rt;
|
|
338
|
+
}
|
|
339
|
+
async function createImageEmbed(agent, images) {
|
|
340
|
+
const validImages = images.filter((image) => Boolean(image.binary));
|
|
341
|
+
if (validImages.length === 0) {
|
|
342
|
+
return undefined;
|
|
343
|
+
}
|
|
344
|
+
if (validImages.length > MAX_IMAGES) {
|
|
345
|
+
throw new Error(`Cannot attach more than ${MAX_IMAGES} images to a post.`);
|
|
346
|
+
}
|
|
347
|
+
const uploadedImages = [];
|
|
348
|
+
for (const image of validImages) {
|
|
349
|
+
const resizedImageBuffer = await resizeImageIfNeeded(image.binary, MAX_IMAGE_WIDTH, IMAGE_SIZE_LIMIT);
|
|
350
|
+
const uploadResponse = await agent.uploadBlob(resizedImageBuffer, {
|
|
351
|
+
encoding: image.mimeType && image.mimeType.trim() !== '' ? image.mimeType : 'image/jpeg',
|
|
352
|
+
});
|
|
353
|
+
const imageEntry = {
|
|
354
|
+
alt: image.alt || '',
|
|
355
|
+
image: uploadResponse.data.blob,
|
|
356
|
+
};
|
|
357
|
+
if (typeof image.width === 'number' &&
|
|
358
|
+
typeof image.height === 'number' &&
|
|
359
|
+
image.width > 0 &&
|
|
360
|
+
image.height > 0) {
|
|
361
|
+
imageEntry.aspectRatio = { width: image.width, height: image.height };
|
|
305
362
|
}
|
|
363
|
+
uploadedImages.push(imageEntry);
|
|
364
|
+
}
|
|
365
|
+
return {
|
|
366
|
+
$type: 'app.bsky.embed.images',
|
|
367
|
+
images: uploadedImages,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
async function createWebsiteCardEmbed(agent, websiteCard) {
|
|
371
|
+
if (!(websiteCard === null || websiteCard === void 0 ? void 0 : websiteCard.uri)) {
|
|
372
|
+
return undefined;
|
|
306
373
|
}
|
|
307
|
-
|
|
308
|
-
|
|
374
|
+
try {
|
|
375
|
+
new URL(websiteCard.uri);
|
|
376
|
+
}
|
|
377
|
+
catch {
|
|
378
|
+
throw new Error(`Invalid URL provided: ${websiteCard.uri}`);
|
|
379
|
+
}
|
|
380
|
+
let thumbBlob = undefined;
|
|
381
|
+
let title = websiteCard.title;
|
|
382
|
+
let description = websiteCard.description;
|
|
383
|
+
if (websiteCard.fetchOpenGraphTags === true) {
|
|
309
384
|
try {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
if (websiteCard.fetchOpenGraphTags === true) {
|
|
317
|
-
try {
|
|
318
|
-
const ogsResponse = await (0, open_graph_scraper_1.default)({ url: websiteCard.uri });
|
|
319
|
-
if (ogsResponse.error) {
|
|
320
|
-
n8n_workflow_1.LoggerProxy.error(`Error fetching Open Graph tags: ${ogsResponse.error}`);
|
|
321
|
-
if (!websiteCard.title) {
|
|
322
|
-
websiteCard.title = websiteCard.uri || 'Untitled';
|
|
323
|
-
}
|
|
385
|
+
const ogsResponse = await (0, open_graph_scraper_1.default)({ url: websiteCard.uri });
|
|
386
|
+
if (!ogsResponse.error) {
|
|
387
|
+
const ogImage = ogsResponse.result.ogImage;
|
|
388
|
+
let imageUrl;
|
|
389
|
+
if (typeof ogImage === 'string') {
|
|
390
|
+
imageUrl = ogImage;
|
|
324
391
|
}
|
|
325
|
-
else {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (imageUrl) {
|
|
340
|
-
try {
|
|
341
|
-
n8n_workflow_1.LoggerProxy.info('Fetching image from Open Graph tags', { imageUrl });
|
|
342
|
-
const imageDataResponse = await fetch(imageUrl);
|
|
343
|
-
if (imageDataResponse.ok) {
|
|
344
|
-
const thumbBlobArrayBuffer = await imageDataResponse.arrayBuffer();
|
|
345
|
-
let thumbBuffer = Buffer.from(thumbBlobArrayBuffer);
|
|
346
|
-
thumbBuffer = await resizeImageIfNeeded(thumbBuffer, MAX_IMAGE_WIDTH, IMAGE_SIZE_LIMIT);
|
|
347
|
-
const { data } = await agent.uploadBlob(thumbBuffer, { encoding: 'image/jpeg' });
|
|
348
|
-
thumbBlob = data.blob;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
catch (imageErr) {
|
|
352
|
-
n8n_workflow_1.LoggerProxy.error(`Failed to fetch or process image from Open Graph tags: ${(imageErr === null || imageErr === void 0 ? void 0 : imageErr.message) || imageErr}`);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
if (ogsResponse.result.ogTitle) {
|
|
356
|
-
websiteCard.title = ogsResponse.result.ogTitle;
|
|
357
|
-
}
|
|
358
|
-
else if (!websiteCard.title) {
|
|
359
|
-
websiteCard.title = websiteCard.uri || 'Untitled';
|
|
360
|
-
}
|
|
361
|
-
if (ogsResponse.result.ogDescription) {
|
|
362
|
-
websiteCard.description = ogsResponse.result.ogDescription;
|
|
363
|
-
}
|
|
364
|
-
else {
|
|
365
|
-
websiteCard.description = '';
|
|
392
|
+
else if (Array.isArray(ogImage) && ogImage.length > 0) {
|
|
393
|
+
const first = ogImage[0];
|
|
394
|
+
imageUrl = typeof first === 'string' ? first : first === null || first === void 0 ? void 0 : first.url;
|
|
395
|
+
}
|
|
396
|
+
else if (ogImage && typeof ogImage === 'object' && 'url' in ogImage) {
|
|
397
|
+
imageUrl = ogImage.url;
|
|
398
|
+
}
|
|
399
|
+
if (imageUrl) {
|
|
400
|
+
const imageDataResponse = await fetch(imageUrl);
|
|
401
|
+
if (imageDataResponse.ok) {
|
|
402
|
+
const thumbBlobArrayBuffer = await imageDataResponse.arrayBuffer();
|
|
403
|
+
const thumbBuffer = await resizeImageIfNeeded(Buffer.from(thumbBlobArrayBuffer), MAX_IMAGE_WIDTH, IMAGE_SIZE_LIMIT);
|
|
404
|
+
const { data } = await agent.uploadBlob(thumbBuffer, { encoding: 'image/jpeg' });
|
|
405
|
+
thumbBlob = data.blob;
|
|
366
406
|
}
|
|
367
407
|
}
|
|
408
|
+
title = ogsResponse.result.ogTitle || title || websiteCard.uri;
|
|
409
|
+
description = ogsResponse.result.ogDescription || description || '';
|
|
368
410
|
}
|
|
369
|
-
|
|
370
|
-
|
|
411
|
+
else if (!title) {
|
|
412
|
+
title = websiteCard.uri;
|
|
413
|
+
description = description || '';
|
|
371
414
|
}
|
|
372
415
|
}
|
|
373
|
-
|
|
374
|
-
n8n_workflow_1.LoggerProxy.
|
|
375
|
-
try {
|
|
376
|
-
websiteCard.thumbnailBinary = await resizeImageIfNeeded(websiteCard.thumbnailBinary, MAX_IMAGE_WIDTH, IMAGE_SIZE_LIMIT);
|
|
377
|
-
const uploadResponse = await agent.uploadBlob(websiteCard.thumbnailBinary, { encoding: 'image/jpeg' });
|
|
378
|
-
thumbBlob = uploadResponse.data.blob;
|
|
379
|
-
}
|
|
380
|
-
catch (thumbErr) {
|
|
381
|
-
n8n_workflow_1.LoggerProxy.error(`Failed to process or upload thumbnail: ${(thumbErr === null || thumbErr === void 0 ? void 0 : thumbErr.message) || thumbErr}`);
|
|
382
|
-
}
|
|
416
|
+
catch (err) {
|
|
417
|
+
n8n_workflow_1.LoggerProxy.error(`Failed to fetch Open Graph tags for URL '${websiteCard.uri}': ${(err === null || err === void 0 ? void 0 : err.message) || err}`);
|
|
383
418
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
catch (thumbErr) {
|
|
392
|
-
n8n_workflow_1.LoggerProxy.error(`Failed to process or upload thumbnail: ${(thumbErr === null || thumbErr === void 0 ? void 0 : thumbErr.message) || thumbErr}`);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
419
|
+
}
|
|
420
|
+
else if (websiteCard.thumbnailBinary) {
|
|
421
|
+
try {
|
|
422
|
+
const resized = await resizeImageIfNeeded(websiteCard.thumbnailBinary, MAX_IMAGE_WIDTH, IMAGE_SIZE_LIMIT);
|
|
423
|
+
const uploadResponse = await agent.uploadBlob(resized, { encoding: 'image/jpeg' });
|
|
424
|
+
thumbBlob = uploadResponse.data.blob;
|
|
395
425
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
title: websiteCard.title,
|
|
399
|
-
description: websiteCard.description,
|
|
400
|
-
};
|
|
401
|
-
if (thumbBlob) {
|
|
402
|
-
externalEmbed.thumb = thumbBlob;
|
|
426
|
+
catch (thumbErr) {
|
|
427
|
+
n8n_workflow_1.LoggerProxy.error(`Failed to process or upload thumbnail: ${(thumbErr === null || thumbErr === void 0 ? void 0 : thumbErr.message) || thumbErr}`);
|
|
403
428
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
429
|
+
}
|
|
430
|
+
const externalEmbed = {
|
|
431
|
+
uri: websiteCard.uri,
|
|
432
|
+
title: title,
|
|
433
|
+
description: description,
|
|
434
|
+
};
|
|
435
|
+
if (thumbBlob) {
|
|
436
|
+
externalEmbed.thumb = thumbBlob;
|
|
437
|
+
}
|
|
438
|
+
return {
|
|
439
|
+
$type: 'app.bsky.embed.external',
|
|
440
|
+
external: externalEmbed,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
async function buildEmbed(agent, websiteCard, image, mediaItems = []) {
|
|
444
|
+
const normalizedImages = mediaItems.length > 0 ? mediaItems : (image === null || image === void 0 ? void 0 : image.binary) ? [image] : [];
|
|
445
|
+
const imageEmbed = await createImageEmbed(agent, normalizedImages);
|
|
446
|
+
if (imageEmbed) {
|
|
447
|
+
return imageEmbed;
|
|
448
|
+
}
|
|
449
|
+
return createWebsiteCardEmbed(agent, websiteCard);
|
|
450
|
+
}
|
|
451
|
+
async function postOperation(agent, postText, langs, websiteCard, image, mediaItems = []) {
|
|
452
|
+
const rt = await createRichText(agent, postText);
|
|
453
|
+
const postData = {
|
|
454
|
+
text: rt.text || postText,
|
|
455
|
+
langs,
|
|
456
|
+
facets: rt.facets,
|
|
457
|
+
};
|
|
458
|
+
const embed = await buildEmbed(agent, websiteCard, image, mediaItems);
|
|
459
|
+
if (embed) {
|
|
460
|
+
postData.embed = embed;
|
|
408
461
|
}
|
|
409
462
|
const postResponse = await agent.post(postData);
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
463
|
+
return [
|
|
464
|
+
{
|
|
465
|
+
json: {
|
|
466
|
+
uri: postResponse.uri,
|
|
467
|
+
cid: postResponse.cid,
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
];
|
|
471
|
+
}
|
|
472
|
+
async function replyOperation(agent, replyText, langs, parentUri, parentCid, websiteCard, mediaItems = []) {
|
|
473
|
+
var _a, _b, _c;
|
|
474
|
+
const rt = await createRichText(agent, replyText);
|
|
475
|
+
const parentThreadResponse = await agent.app.bsky.feed.getPostThread({ uri: parentUri });
|
|
476
|
+
let root = { uri: parentUri, cid: parentCid };
|
|
477
|
+
const thread = parentThreadResponse.data.thread;
|
|
478
|
+
const nestedRoot = (_c = (_b = (_a = thread === null || thread === void 0 ? void 0 : thread.post) === null || _a === void 0 ? void 0 : _a.record) === null || _b === void 0 ? void 0 : _b.reply) === null || _c === void 0 ? void 0 : _c.root;
|
|
479
|
+
if ((nestedRoot === null || nestedRoot === void 0 ? void 0 : nestedRoot.uri) && (nestedRoot === null || nestedRoot === void 0 ? void 0 : nestedRoot.cid)) {
|
|
480
|
+
root = nestedRoot;
|
|
481
|
+
}
|
|
482
|
+
const replyData = {
|
|
483
|
+
text: rt.text || replyText,
|
|
484
|
+
langs,
|
|
485
|
+
facets: rt.facets,
|
|
486
|
+
reply: {
|
|
487
|
+
root,
|
|
488
|
+
parent: { uri: parentUri, cid: parentCid },
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
const embed = await buildEmbed(agent, websiteCard, undefined, mediaItems);
|
|
492
|
+
if (embed) {
|
|
493
|
+
replyData.embed = embed;
|
|
494
|
+
}
|
|
495
|
+
const replyResponse = await agent.post(replyData);
|
|
496
|
+
return [
|
|
497
|
+
{
|
|
498
|
+
json: {
|
|
499
|
+
uri: replyResponse.uri,
|
|
500
|
+
cid: replyResponse.cid,
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
];
|
|
504
|
+
}
|
|
505
|
+
async function quoteOperation(agent, quoteText, langs, quotedUri, quotedCid) {
|
|
506
|
+
const rt = await createRichText(agent, quoteText);
|
|
507
|
+
const quoteResponse = await agent.post({
|
|
508
|
+
text: rt.text || quoteText,
|
|
509
|
+
langs,
|
|
510
|
+
facets: rt.facets,
|
|
511
|
+
embed: {
|
|
512
|
+
$type: 'app.bsky.embed.record',
|
|
513
|
+
record: {
|
|
514
|
+
uri: quotedUri,
|
|
515
|
+
cid: quotedCid,
|
|
516
|
+
},
|
|
414
517
|
},
|
|
415
518
|
});
|
|
416
|
-
return
|
|
519
|
+
return [
|
|
520
|
+
{
|
|
521
|
+
json: {
|
|
522
|
+
uri: quoteResponse.uri,
|
|
523
|
+
cid: quoteResponse.cid,
|
|
524
|
+
},
|
|
525
|
+
},
|
|
526
|
+
];
|
|
417
527
|
}
|
|
418
528
|
async function deletePostOperation(agent, uri) {
|
|
419
|
-
const returnData = [];
|
|
420
529
|
await agent.deletePost(uri);
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
530
|
+
return [
|
|
531
|
+
{
|
|
532
|
+
json: {
|
|
533
|
+
uri,
|
|
534
|
+
},
|
|
424
535
|
},
|
|
425
|
-
|
|
426
|
-
return returnData;
|
|
536
|
+
];
|
|
427
537
|
}
|
|
428
538
|
async function likeOperation(agent, uri, cid) {
|
|
429
|
-
const returnData = [];
|
|
430
539
|
const likeResponse = await agent.like(uri, cid);
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
540
|
+
return [
|
|
541
|
+
{
|
|
542
|
+
json: {
|
|
543
|
+
uri: likeResponse.uri,
|
|
544
|
+
cid: likeResponse.cid,
|
|
545
|
+
},
|
|
435
546
|
},
|
|
436
|
-
|
|
437
|
-
return returnData;
|
|
547
|
+
];
|
|
438
548
|
}
|
|
439
549
|
async function deleteLikeOperation(agent, uri) {
|
|
440
|
-
const returnData = [];
|
|
441
550
|
await agent.deleteLike(uri);
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
551
|
+
return [
|
|
552
|
+
{
|
|
553
|
+
json: {
|
|
554
|
+
uri,
|
|
555
|
+
},
|
|
445
556
|
},
|
|
446
|
-
|
|
447
|
-
return returnData;
|
|
557
|
+
];
|
|
448
558
|
}
|
|
449
559
|
async function repostOperation(agent, uri, cid) {
|
|
450
|
-
const returnData = [];
|
|
451
560
|
const repostResult = await agent.repost(uri, cid);
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
561
|
+
return [
|
|
562
|
+
{
|
|
563
|
+
json: {
|
|
564
|
+
uri: repostResult.uri,
|
|
565
|
+
cid: repostResult.cid,
|
|
566
|
+
},
|
|
456
567
|
},
|
|
457
|
-
|
|
458
|
-
return returnData;
|
|
568
|
+
];
|
|
459
569
|
}
|
|
460
570
|
async function deleteRepostOperation(agent, uri) {
|
|
461
|
-
const returnData = [];
|
|
462
571
|
await agent.deleteRepost(uri);
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
572
|
+
return [
|
|
573
|
+
{
|
|
574
|
+
json: {
|
|
575
|
+
uri,
|
|
576
|
+
},
|
|
466
577
|
},
|
|
467
|
-
|
|
468
|
-
return returnData;
|
|
578
|
+
];
|
|
469
579
|
}
|
|
470
580
|
//# sourceMappingURL=postOperations.js.map
|