Skip to content

Commit 1a7ff8b

Browse files
committed
feat: add support for pre-uploaded attachment Facebook IDs in sendMessage
1 parent 365dfed commit 1a7ff8b

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

DOCS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ __Parameters__
269269
* If object:
270270
* `text`: string - Message content
271271
* `replyToId?`: string - Message ID to reply to
272+
* `attachmentFbIds?`: bigint[] - Pre-uploaded attachment Facebook IDs (from `uploadMedia()`)
272273
* `mentions?`: Mention[] - List of mentions
273274
* `userId`: bigint - Mentioned user ID
274275
* `offset`: number - Start position in text
@@ -301,6 +302,13 @@ await client.sendMessage(threadId, {
301302
length: 7
302303
}]
303304
})
305+
306+
// Send with pre-uploaded attachments
307+
const upload = await client.uploadMedia(threadId, imageData, 'photo.jpg', 'image/jpeg')
308+
await client.sendMessage(threadId, {
309+
text: 'Check this out!',
310+
attachmentFbIds: [upload.fbId]
311+
})
304312
```
305313

306314
---

DOCS_VI.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ __Tham số__
269269
* Nếu là object:
270270
* `text`: string - Nội dung tin nhắn
271271
* `replyToId?`: string - ID tin nhắn để reply
272+
* `attachmentFbIds?`: bigint[] - Danh sách Facebook ID của media đã upload (từ `uploadMedia()`)
272273
* `mentions?`: Mention[] - Danh sách mention
273274
* `userId`: bigint - ID user được mention
274275
* `offset`: number - Vị trí bắt đầu trong text
@@ -301,6 +302,13 @@ await client.sendMessage(threadId, {
301302
length: 4
302303
}]
303304
})
305+
306+
// Gửi với attachment đã upload trước
307+
const upload = await client.uploadMedia(threadId, imageData, 'photo.jpg', 'image/jpeg')
308+
await client.sendMessage(threadId, {
309+
text: 'Xem này!',
310+
attachmentFbIds: [upload.fbId]
311+
})
304312
```
305313

306314
---

src/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ export class Client<
258258
threadId,
259259
text: opts.text,
260260
replyToId: opts.replyToId,
261+
attachmentFbIds: opts.attachmentFbIds,
261262
mentionIds: opts.mentions?.map(m => m.userId),
262263
mentionOffsets: opts.mentions?.map(m => m.offset),
263264
mentionLengths: opts.mentions?.map(m => m.length),

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ export interface SendMessageOptions {
467467
text: string;
468468
/** Reply to message ID */
469469
replyToId?: string;
470+
/** Pre-uploaded attachment Facebook IDs (from uploadMedia) */
471+
attachmentFbIds?: bigint[];
470472
/** User IDs to mention */
471473
mentions?: Array<{
472474
userId: bigint;

0 commit comments

Comments
 (0)