@photon-ai/advanced-imessage-kit 1.4.0 → 1.5.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/README.md +103 -42
- package/dist/index.cjs +47 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +47 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,30 +18,34 @@ Advanced iMessage Kit is a full-featured iMessage SDK for **reading**, **sending
|
|
|
18
18
|
|
|
19
19
|
## Features
|
|
20
20
|
|
|
21
|
-
| Feature | Method | Example |
|
|
22
|
-
| ---------------------------------------------------------- | ---------------------------------- | --------------------------------------------------------------- |
|
|
23
|
-
| [Send Messages](#send-messages) | `messages.sendMessage()` | [message-send.ts](./examples/message-send.ts) |
|
|
24
|
-
| [Reply to Messages](#send-messages) | `messages.sendMessage()` | [message-reply.ts](./examples/message-reply.ts) |
|
|
25
|
-
| [Message Effects](#send-messages) | `messages.sendMessage()` | [message-effects.ts](./examples/message-effects.ts) |
|
|
26
|
-
| [Unsend Messages](#unsend-messages) | `messages.unsendMessage()` | [message-unsend.ts](./examples/message-unsend.ts) |
|
|
27
|
-
| [Send Tapbacks](#send-tapbacks) | `messages.sendReaction()` | [message-reaction.ts](./examples/message-reaction.ts) |
|
|
28
|
-
| [Query Messages](#query-messages) | `messages.getMessages()` | [message-search.ts](./examples/message-search.ts) |
|
|
29
|
-
| [
|
|
30
|
-
| [Send
|
|
31
|
-
| [Send
|
|
32
|
-
| [
|
|
33
|
-
| [
|
|
34
|
-
| [
|
|
35
|
-
| [
|
|
36
|
-
| [
|
|
37
|
-
| [
|
|
38
|
-
| [
|
|
39
|
-
| [
|
|
40
|
-
| [
|
|
41
|
-
| [
|
|
42
|
-
| [
|
|
43
|
-
| [
|
|
44
|
-
| [
|
|
21
|
+
| Feature | Description | Method | Example |
|
|
22
|
+
| ---------------------------------------------------------- | --------------------------------------------- | ---------------------------------- | --------------------------------------------------------------- |
|
|
23
|
+
| [Send Messages](#send-messages) | Send text messages to any contact | `messages.sendMessage()` | [message-send.ts](./examples/message-send.ts) |
|
|
24
|
+
| [Reply to Messages](#send-messages) | Reply inline to a specific message | `messages.sendMessage()` | [message-reply.ts](./examples/message-reply.ts) |
|
|
25
|
+
| [Message Effects](#send-messages) | Send with effects (confetti, fireworks, etc.) | `messages.sendMessage()` | [message-effects.ts](./examples/message-effects.ts) |
|
|
26
|
+
| [Unsend Messages](#unsend-messages) | Retract a sent message | `messages.unsendMessage()` | [message-unsend.ts](./examples/message-unsend.ts) |
|
|
27
|
+
| [Send Tapbacks](#send-tapbacks) | React with ❤️ 👍 👎 😂 ‼️ ❓ | `messages.sendReaction()` | [message-reaction.ts](./examples/message-reaction.ts) |
|
|
28
|
+
| [Query Messages](#query-messages) | Search and filter message history | `messages.getMessages()` | [message-search.ts](./examples/message-search.ts) |
|
|
29
|
+
| [Message History](#get-chat-messages) | View messages, reactions, polls, stickers | `chats.getChatMessages()` | [message-history.ts](./examples/message-history.ts) |
|
|
30
|
+
| [Send Attachments](#send-attachments) | Send images, files, documents | `attachments.sendAttachment()` | [message-attachment.ts](./examples/message-attachment.ts) |
|
|
31
|
+
| [Send Audio Messages](#send-audio-messages) | Send voice messages | `attachments.sendAttachment()` | [message-audio.ts](./examples/message-audio.ts) |
|
|
32
|
+
| [Send Stickers](#send-stickers) | Send sticker as standalone message | `attachments.sendSticker()` | [message-sticker.ts](./examples/message-sticker.ts) |
|
|
33
|
+
| [Reply Stickers](#send-stickers) | Attach sticker to a message bubble | `attachments.sendSticker()` | [message-reply-sticker.ts](./examples/message-reply-sticker.ts) |
|
|
34
|
+
| [Download Attachments](#download-attachments) | Download received files and media | `attachments.downloadAttachment()` | [attachment-download.ts](./examples/attachment-download.ts) |
|
|
35
|
+
| [Get Chats](#get-chats) | List all conversations | `chats.getChats()` | [chat-fetch.ts](./examples/chat-fetch.ts) |
|
|
36
|
+
| [Manage Group Chats](#manage-group-chats) | Add/remove members, rename groups | `chats.addParticipant()` | [chat-group.ts](./examples/chat-group.ts) |
|
|
37
|
+
| [Typing Indicators](#typing-indicators) | Show "typing..." status | `chats.startTyping()` | [message-typing.ts](./examples/message-typing.ts) |
|
|
38
|
+
| [Get Contacts](#get-contacts) | Fetch device contacts | `contacts.getContacts()` | [contact-list.ts](./examples/contact-list.ts) |
|
|
39
|
+
| [Share Contact Card](#share-contact-card) | Share your contact info in chat | `contacts.shareContactCard()` | [message-contact-card.ts](./examples/message-contact-card.ts) |
|
|
40
|
+
| [Check iMessage Availability](#check-service-availability) | Verify if contact uses iMessage | `handles.getHandleAvailability()` | [service-check.ts](./examples/service-check.ts) |
|
|
41
|
+
| [Server Info](#get-server-info) | Get server status and config | `server.getServerInfo()` | [server-info.ts](./examples/server-info.ts) |
|
|
42
|
+
| [Message Statistics](#message-statistics) | Get message counts and analytics | `server.getMessageStats()` | [message-stats.ts](./examples/message-stats.ts) |
|
|
43
|
+
| [Create Polls](#create-polls) | Create interactive polls in chat | `polls.create()` | [poll-create.ts](./examples/poll-create.ts) |
|
|
44
|
+
| [Vote on Polls](#vote-on-polls) | Vote or unvote on poll options | `polls.vote()` | [poll-create.ts](./examples/poll-create.ts) |
|
|
45
|
+
| [Add Poll Options](#add-poll-options) | Add options to existing polls | `polls.addOption()` | [poll-add-option.ts](./examples/poll-add-option.ts) |
|
|
46
|
+
| [Find My Friends](#find-my-friends) _(WIP)_ | Get friends' locations | `icloud.getFindMyFriends()` | [findmy-friends.ts](./examples/findmy-friends.ts) |
|
|
47
|
+
| [Real-time Events](#real-time-events) | Listen for new messages, typing, etc. | `sdk.on()` | [listen-simple.ts](./examples/listen-simple.ts) |
|
|
48
|
+
| [Auto Reply](#real-time-events) | Build automated reply bots | `sdk.on()` | [auto-reply-hey.ts](./examples/auto-reply-hey.ts) |
|
|
45
49
|
|
|
46
50
|
---
|
|
47
51
|
|
|
@@ -378,11 +382,31 @@ const message = await sdk.attachments.sendAttachment({
|
|
|
378
382
|
|
|
379
383
|
### Send Stickers
|
|
380
384
|
|
|
385
|
+
Stickers can be sent in two ways:
|
|
386
|
+
|
|
387
|
+
**Standalone Sticker** - Sends as its own message (like sending an image, but with sticker styling):
|
|
388
|
+
|
|
389
|
+
```typescript
|
|
390
|
+
await sdk.attachments.sendSticker({
|
|
391
|
+
chatGuid: "iMessage;-;+1234567890",
|
|
392
|
+
filePath: "/path/to/sticker.png",
|
|
393
|
+
});
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
> Example: [message-sticker.ts](./examples/message-sticker.ts)
|
|
397
|
+
|
|
398
|
+
**Reply Sticker (Tapback Sticker)** - Attaches to an existing message bubble:
|
|
399
|
+
|
|
381
400
|
```typescript
|
|
382
401
|
await sdk.attachments.sendSticker({
|
|
383
402
|
chatGuid: "iMessage;-;+1234567890",
|
|
384
403
|
filePath: "/path/to/sticker.png",
|
|
385
|
-
selectedMessageGuid: "message-
|
|
404
|
+
selectedMessageGuid: "target-message-guid", // Required for reply sticker
|
|
405
|
+
stickerX: 0.5, // Position X (0-1), default: 0.5
|
|
406
|
+
stickerY: 0.5, // Position Y (0-1), default: 0.5
|
|
407
|
+
stickerScale: 0.75, // Scale (0-1), default: 0.75
|
|
408
|
+
stickerRotation: 0, // Rotation in radians, default: 0
|
|
409
|
+
stickerWidth: 300, // Width in pixels, default: 300
|
|
386
410
|
});
|
|
387
411
|
```
|
|
388
412
|
|
|
@@ -436,10 +460,38 @@ const contacts = await sdk.contacts.getContacts();
|
|
|
436
460
|
### Get Contact Card
|
|
437
461
|
|
|
438
462
|
```typescript
|
|
439
|
-
// Get by phone or email
|
|
463
|
+
// Get contact card by phone or email
|
|
440
464
|
const card = await sdk.contacts.getContactCard("+1234567890");
|
|
465
|
+
// {
|
|
466
|
+
// firstName: "John",
|
|
467
|
+
// lastName: "Doe",
|
|
468
|
+
// emails: ["john@example.com"],
|
|
469
|
+
// phones: ["+1234567890"],
|
|
470
|
+
// ...
|
|
471
|
+
// }
|
|
441
472
|
```
|
|
442
473
|
|
|
474
|
+
### Share Contact Card
|
|
475
|
+
|
|
476
|
+
Share your contact card with a chat:
|
|
477
|
+
|
|
478
|
+
```typescript
|
|
479
|
+
// chatGuid is the chat identifier (e.g. the `guid` field you get from chat APIs/events)
|
|
480
|
+
// Check whether the SDK recommends sharing your contact card in this chat.
|
|
481
|
+
//
|
|
482
|
+
// Returns:
|
|
483
|
+
// - true: sharing is recommended (typically when the other side shared theirs and you haven't shared yours yet)
|
|
484
|
+
// - false: NOT recommended (e.g. you've already shared, OR the other side hasn't shared theirs yet)
|
|
485
|
+
const shouldShare = await sdk.contacts.shouldShareContact("chat-guid");
|
|
486
|
+
|
|
487
|
+
if (shouldShare) {
|
|
488
|
+
// Share your contact card (iMessage "Share Name and Photo")
|
|
489
|
+
await sdk.contacts.shareContactCard("chat-guid");
|
|
490
|
+
}
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
> Example: [message-contact-card.ts](./examples/message-contact-card.ts)
|
|
494
|
+
|
|
443
495
|
---
|
|
444
496
|
|
|
445
497
|
## Handles
|
|
@@ -543,18 +595,6 @@ const chatMediaStats = await sdk.server.getMediaStatisticsByChat();
|
|
|
543
595
|
const logs = await sdk.server.getServerLogs(100); // Get last 100 logs
|
|
544
596
|
```
|
|
545
597
|
|
|
546
|
-
### Alert Management
|
|
547
|
-
|
|
548
|
-
```typescript
|
|
549
|
-
// Get alerts
|
|
550
|
-
const alerts = await sdk.server.getAlerts();
|
|
551
|
-
|
|
552
|
-
// Mark alerts as read
|
|
553
|
-
await sdk.server.markAlertAsRead(["alert-id-1", "alert-id-2"]);
|
|
554
|
-
```
|
|
555
|
-
|
|
556
|
-
> Example: [server-info.ts](./examples/server-info.ts)
|
|
557
|
-
|
|
558
598
|
---
|
|
559
599
|
|
|
560
600
|
## Polls
|
|
@@ -587,6 +627,24 @@ await sdk.polls.addOption({
|
|
|
587
627
|
|
|
588
628
|
> Example: [poll-add-option.ts](./examples/poll-add-option.ts)
|
|
589
629
|
|
|
630
|
+
### Vote on Polls
|
|
631
|
+
|
|
632
|
+
```typescript
|
|
633
|
+
// Vote on a poll option
|
|
634
|
+
await sdk.polls.vote({
|
|
635
|
+
chatGuid: "iMessage;-;+1234567890",
|
|
636
|
+
pollMessageGuid: "poll-message-guid",
|
|
637
|
+
optionIdentifier: "option-uuid", // UUID of the option to vote for
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
// Remove your vote
|
|
641
|
+
await sdk.polls.unvote({
|
|
642
|
+
chatGuid: "iMessage;-;+1234567890",
|
|
643
|
+
pollMessageGuid: "poll-message-guid",
|
|
644
|
+
optionIdentifier: "option-uuid",
|
|
645
|
+
});
|
|
646
|
+
```
|
|
647
|
+
|
|
590
648
|
### Parse Poll Messages
|
|
591
649
|
|
|
592
650
|
Use the `poll-utils` helper functions to parse and display poll messages:
|
|
@@ -843,6 +901,7 @@ bun run examples/<filename>.ts
|
|
|
843
901
|
| [message-reaction.ts](./examples/message-reaction.ts) | Send Tapbacks |
|
|
844
902
|
| [message-effects.ts](./examples/message-effects.ts) | Message effects |
|
|
845
903
|
| [message-search.ts](./examples/message-search.ts) | Search messages |
|
|
904
|
+
| [message-history.ts](./examples/message-history.ts) | Message history |
|
|
846
905
|
|
|
847
906
|
### Chats & Groups
|
|
848
907
|
|
|
@@ -857,15 +916,17 @@ bun run examples/<filename>.ts
|
|
|
857
916
|
| File | Description |
|
|
858
917
|
| --------------------------------------------------------------- | ----------------------------- |
|
|
859
918
|
| [contact-list.ts](./examples/contact-list.ts) | Get contacts |
|
|
919
|
+
| [message-contact-card.ts](./examples/message-contact-card.ts) | Share contact card |
|
|
860
920
|
| [service-check.ts](./examples/service-check.ts) | Check iMessage availability |
|
|
861
921
|
| [message-service-check.ts](./examples/message-service-check.ts) | Monitor message service types |
|
|
862
922
|
|
|
863
923
|
### Attachments & Media
|
|
864
924
|
|
|
865
|
-
| File | Description
|
|
866
|
-
| --------------------------------------------------------------- |
|
|
867
|
-
| [attachment-download.ts](./examples/attachment-download.ts) | Download attachments
|
|
868
|
-
| [message-
|
|
925
|
+
| File | Description |
|
|
926
|
+
| --------------------------------------------------------------- | ------------------------ |
|
|
927
|
+
| [attachment-download.ts](./examples/attachment-download.ts) | Download attachments |
|
|
928
|
+
| [message-sticker.ts](./examples/message-sticker.ts) | Send standalone stickers |
|
|
929
|
+
| [message-reply-sticker.ts](./examples/message-reply-sticker.ts) | Send reply stickers |
|
|
869
930
|
|
|
870
931
|
### Polls
|
|
871
932
|
|
package/dist/index.cjs
CHANGED
|
@@ -144,7 +144,7 @@ var AttachmentModule = class {
|
|
|
144
144
|
return response.data.data.total;
|
|
145
145
|
}
|
|
146
146
|
async getAttachment(guid) {
|
|
147
|
-
const response = await this.http.get(`/api/v1/attachment/${guid}`);
|
|
147
|
+
const response = await this.http.get(`/api/v1/attachment/${encodeURIComponent(guid)}`);
|
|
148
148
|
return response.data.data;
|
|
149
149
|
}
|
|
150
150
|
async downloadAttachment(guid, options) {
|
|
@@ -154,14 +154,14 @@ var AttachmentModule = class {
|
|
|
154
154
|
if (options?.height !== void 0) params.height = options.height;
|
|
155
155
|
if (options?.width !== void 0) params.width = options.width;
|
|
156
156
|
if (options?.quality !== void 0) params.quality = options.quality;
|
|
157
|
-
const response = await this.http.get(`/api/v1/attachment/${guid}/download`, {
|
|
157
|
+
const response = await this.http.get(`/api/v1/attachment/${encodeURIComponent(guid)}/download`, {
|
|
158
158
|
params,
|
|
159
159
|
responseType: "arraybuffer"
|
|
160
160
|
});
|
|
161
161
|
return Buffer.from(response.data);
|
|
162
162
|
}
|
|
163
163
|
async downloadAttachmentLive(guid) {
|
|
164
|
-
const response = await this.http.get(`/api/v1/attachment/${guid}/live`, {
|
|
164
|
+
const response = await this.http.get(`/api/v1/attachment/${encodeURIComponent(guid)}/live`, {
|
|
165
165
|
responseType: "arraybuffer"
|
|
166
166
|
});
|
|
167
167
|
return Buffer.from(response.data);
|
|
@@ -171,7 +171,7 @@ var AttachmentModule = class {
|
|
|
171
171
|
if (options?.height !== void 0) params.height = options.height;
|
|
172
172
|
if (options?.width !== void 0) params.width = options.width;
|
|
173
173
|
if (options?.quality !== void 0) params.quality = options.quality;
|
|
174
|
-
const response = await this.http.get(`/api/v1/attachment/${guid}/blurhash`, {
|
|
174
|
+
const response = await this.http.get(`/api/v1/attachment/${encodeURIComponent(guid)}/blurhash`, {
|
|
175
175
|
params
|
|
176
176
|
});
|
|
177
177
|
return response.data.data.blurhash;
|
|
@@ -238,35 +238,35 @@ var ChatModule = class {
|
|
|
238
238
|
return response.data.data;
|
|
239
239
|
}
|
|
240
240
|
async getChat(guid, options) {
|
|
241
|
-
const response = await this.http.get(`/api/v1/chat/${guid}`, {
|
|
241
|
+
const response = await this.http.get(`/api/v1/chat/${encodeURIComponent(guid)}`, {
|
|
242
242
|
params: options?.with ? { with: options.with.join(",") } : {}
|
|
243
243
|
});
|
|
244
244
|
return response.data.data;
|
|
245
245
|
}
|
|
246
246
|
async updateChat(guid, options) {
|
|
247
|
-
const response = await this.http.put(`/api/v1/chat/${guid}`, options);
|
|
247
|
+
const response = await this.http.put(`/api/v1/chat/${encodeURIComponent(guid)}`, options);
|
|
248
248
|
return response.data.data;
|
|
249
249
|
}
|
|
250
250
|
async deleteChat(guid) {
|
|
251
|
-
await this.http.delete(`/api/v1/chat/${guid}`);
|
|
251
|
+
await this.http.delete(`/api/v1/chat/${encodeURIComponent(guid)}`);
|
|
252
252
|
}
|
|
253
253
|
async markChatRead(guid) {
|
|
254
|
-
await this.http.post(`/api/v1/chat/${guid}/read`);
|
|
254
|
+
await this.http.post(`/api/v1/chat/${encodeURIComponent(guid)}/read`);
|
|
255
255
|
}
|
|
256
256
|
async markChatUnread(guid) {
|
|
257
|
-
await this.http.post(`/api/v1/chat/${guid}/unread`);
|
|
257
|
+
await this.http.post(`/api/v1/chat/${encodeURIComponent(guid)}/unread`);
|
|
258
258
|
}
|
|
259
259
|
async leaveChat(guid) {
|
|
260
|
-
await this.http.post(`/api/v1/chat/${guid}/leave`);
|
|
260
|
+
await this.http.post(`/api/v1/chat/${encodeURIComponent(guid)}/leave`);
|
|
261
261
|
}
|
|
262
262
|
async addParticipant(chatGuid, address) {
|
|
263
|
-
const response = await this.http.post(`/api/v1/chat/${chatGuid}/participant`, {
|
|
263
|
+
const response = await this.http.post(`/api/v1/chat/${encodeURIComponent(chatGuid)}/participant`, {
|
|
264
264
|
address
|
|
265
265
|
});
|
|
266
266
|
return response.data.data;
|
|
267
267
|
}
|
|
268
268
|
async removeParticipant(chatGuid, address) {
|
|
269
|
-
const response = await this.http.delete(`/api/v1/chat/${chatGuid}/participant`, {
|
|
269
|
+
const response = await this.http.delete(`/api/v1/chat/${encodeURIComponent(chatGuid)}/participant`, {
|
|
270
270
|
data: { address }
|
|
271
271
|
});
|
|
272
272
|
return response.data.data;
|
|
@@ -279,7 +279,7 @@ var ChatModule = class {
|
|
|
279
279
|
if (options?.before !== void 0) params.before = options.before;
|
|
280
280
|
if (options?.after !== void 0) params.after = options.after;
|
|
281
281
|
if (options?.with) params.with = options.with.join(",");
|
|
282
|
-
const response = await this.http.get(`/api/v1/chat/${chatGuid}/message`, {
|
|
282
|
+
const response = await this.http.get(`/api/v1/chat/${encodeURIComponent(chatGuid)}/message`, {
|
|
283
283
|
params
|
|
284
284
|
});
|
|
285
285
|
return response.data.data;
|
|
@@ -289,15 +289,15 @@ var ChatModule = class {
|
|
|
289
289
|
const fileName = path__namespace.default.basename(filePath);
|
|
290
290
|
const form = new FormData__default.default();
|
|
291
291
|
form.append("icon", fileBuffer, fileName);
|
|
292
|
-
await this.http.post(`/api/v1/chat/${chatGuid}/icon`, form, {
|
|
292
|
+
await this.http.post(`/api/v1/chat/${encodeURIComponent(chatGuid)}/icon`, form, {
|
|
293
293
|
headers: form.getHeaders()
|
|
294
294
|
});
|
|
295
295
|
}
|
|
296
296
|
async removeGroupIcon(chatGuid) {
|
|
297
|
-
await this.http.delete(`/api/v1/chat/${chatGuid}/icon`);
|
|
297
|
+
await this.http.delete(`/api/v1/chat/${encodeURIComponent(chatGuid)}/icon`);
|
|
298
298
|
}
|
|
299
299
|
async getGroupIcon(chatGuid) {
|
|
300
|
-
const response = await this.http.get(`/api/v1/chat/${chatGuid}/icon`, {
|
|
300
|
+
const response = await this.http.get(`/api/v1/chat/${encodeURIComponent(chatGuid)}/icon`, {
|
|
301
301
|
responseType: "arraybuffer"
|
|
302
302
|
});
|
|
303
303
|
return Buffer.from(response.data);
|
|
@@ -309,10 +309,10 @@ var ChatModule = class {
|
|
|
309
309
|
return response.data.data;
|
|
310
310
|
}
|
|
311
311
|
async startTyping(chatGuid) {
|
|
312
|
-
await this.http.post(`/api/v1/chat/${chatGuid}/typing`);
|
|
312
|
+
await this.http.post(`/api/v1/chat/${encodeURIComponent(chatGuid)}/typing`);
|
|
313
313
|
}
|
|
314
314
|
async stopTyping(chatGuid) {
|
|
315
|
-
await this.http.delete(`/api/v1/chat/${chatGuid}/typing`);
|
|
315
|
+
await this.http.delete(`/api/v1/chat/${encodeURIComponent(chatGuid)}/typing`);
|
|
316
316
|
}
|
|
317
317
|
async getBackground(chatGuid) {
|
|
318
318
|
const response = await this.http.get(`/api/v1/chat/${encodeURIComponent(chatGuid)}/background`);
|
|
@@ -384,7 +384,7 @@ var HandleModule = class {
|
|
|
384
384
|
};
|
|
385
385
|
}
|
|
386
386
|
async getHandle(guid) {
|
|
387
|
-
const response = await this.http.get(`/api/v1/handle/${guid}`);
|
|
387
|
+
const response = await this.http.get(`/api/v1/handle/${encodeURIComponent(guid)}`);
|
|
388
388
|
return response.data.data;
|
|
389
389
|
}
|
|
390
390
|
async getHandleAvailability(address, type) {
|
|
@@ -394,7 +394,7 @@ var HandleModule = class {
|
|
|
394
394
|
return response.data.data.available;
|
|
395
395
|
}
|
|
396
396
|
async getHandleFocusStatus(guid) {
|
|
397
|
-
const response = await this.http.get(`/api/v1/handle/${guid}/focus`);
|
|
397
|
+
const response = await this.http.get(`/api/v1/handle/${encodeURIComponent(guid)}/focus`);
|
|
398
398
|
return response.data.data.status;
|
|
399
399
|
}
|
|
400
400
|
};
|
|
@@ -475,7 +475,7 @@ var MessageModule = class {
|
|
|
475
475
|
});
|
|
476
476
|
}
|
|
477
477
|
async getMessage(guid, options) {
|
|
478
|
-
const response = await this.http.get(`/api/v1/message/${guid}`, {
|
|
478
|
+
const response = await this.http.get(`/api/v1/message/${encodeURIComponent(guid)}`, {
|
|
479
479
|
params: options?.with ? { with: options.with.join(",") } : {}
|
|
480
480
|
});
|
|
481
481
|
return response.data.data;
|
|
@@ -520,7 +520,7 @@ var MessageModule = class {
|
|
|
520
520
|
}
|
|
521
521
|
async editMessage(options) {
|
|
522
522
|
return this.enqueueSend(async () => {
|
|
523
|
-
const response = await this.http.post(`/api/v1/message/${options.messageGuid}/edit`, {
|
|
523
|
+
const response = await this.http.post(`/api/v1/message/${encodeURIComponent(options.messageGuid)}/edit`, {
|
|
524
524
|
editedMessage: options.editedMessage,
|
|
525
525
|
backwardsCompatibilityMessage: options.backwardsCompatibilityMessage || options.editedMessage,
|
|
526
526
|
partIndex: options.partIndex ?? 0
|
|
@@ -541,21 +541,40 @@ var MessageModule = class {
|
|
|
541
541
|
}
|
|
542
542
|
async unsendMessage(options) {
|
|
543
543
|
return this.enqueueSend(async () => {
|
|
544
|
-
const response = await this.http.post(`/api/v1/message/${options.messageGuid}/unsend`, {
|
|
544
|
+
const response = await this.http.post(`/api/v1/message/${encodeURIComponent(options.messageGuid)}/unsend`, {
|
|
545
545
|
partIndex: options.partIndex ?? 0
|
|
546
546
|
});
|
|
547
547
|
return response.data.data;
|
|
548
548
|
});
|
|
549
549
|
}
|
|
550
550
|
async notifyMessage(guid) {
|
|
551
|
-
await this.http.post(`/api/v1/message/${guid}/notify`);
|
|
551
|
+
await this.http.post(`/api/v1/message/${encodeURIComponent(guid)}/notify`);
|
|
552
552
|
}
|
|
553
553
|
async getEmbeddedMedia(guid) {
|
|
554
|
-
const response = await this.http.get(`/api/v1/message/${guid}/embedded-media`);
|
|
554
|
+
const response = await this.http.get(`/api/v1/message/${encodeURIComponent(guid)}/embedded-media`);
|
|
555
555
|
return response.data.data;
|
|
556
556
|
}
|
|
557
557
|
async searchMessages(options) {
|
|
558
|
-
const
|
|
558
|
+
const { query, chatGuid, offset, limit, sort, before, after } = options;
|
|
559
|
+
if (!query || query.trim().length === 0) {
|
|
560
|
+
throw new Error("Search query cannot be empty");
|
|
561
|
+
}
|
|
562
|
+
const where = [
|
|
563
|
+
{
|
|
564
|
+
statement: "message.text LIKE :text",
|
|
565
|
+
args: { text: `%${query}%` }
|
|
566
|
+
}
|
|
567
|
+
];
|
|
568
|
+
const payload = {
|
|
569
|
+
where
|
|
570
|
+
};
|
|
571
|
+
if (chatGuid) payload.chatGuid = chatGuid;
|
|
572
|
+
if (offset !== void 0) payload.offset = offset;
|
|
573
|
+
if (limit !== void 0) payload.limit = limit;
|
|
574
|
+
if (sort) payload.sort = sort;
|
|
575
|
+
if (before !== void 0) payload.before = before;
|
|
576
|
+
if (after !== void 0) payload.after = after;
|
|
577
|
+
const response = await this.http.post("/api/v1/message/query", payload);
|
|
559
578
|
return response.data.data;
|
|
560
579
|
}
|
|
561
580
|
};
|
|
@@ -619,11 +638,11 @@ var ScheduledMessageModule = class {
|
|
|
619
638
|
return response.data.data;
|
|
620
639
|
}
|
|
621
640
|
async updateScheduledMessage(id, options) {
|
|
622
|
-
const response = await this.http.put(`/api/v1/message/schedule/${id}`, options);
|
|
641
|
+
const response = await this.http.put(`/api/v1/message/schedule/${encodeURIComponent(id)}`, options);
|
|
623
642
|
return response.data.data;
|
|
624
643
|
}
|
|
625
644
|
async deleteScheduledMessage(id) {
|
|
626
|
-
await this.http.delete(`/api/v1/message/schedule/${id}`);
|
|
645
|
+
await this.http.delete(`/api/v1/message/schedule/${encodeURIComponent(id)}`);
|
|
627
646
|
}
|
|
628
647
|
};
|
|
629
648
|
|