@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/dist/index.js
CHANGED
|
@@ -115,7 +115,7 @@ var AttachmentModule = class {
|
|
|
115
115
|
return response.data.data.total;
|
|
116
116
|
}
|
|
117
117
|
async getAttachment(guid) {
|
|
118
|
-
const response = await this.http.get(`/api/v1/attachment/${guid}`);
|
|
118
|
+
const response = await this.http.get(`/api/v1/attachment/${encodeURIComponent(guid)}`);
|
|
119
119
|
return response.data.data;
|
|
120
120
|
}
|
|
121
121
|
async downloadAttachment(guid, options) {
|
|
@@ -125,14 +125,14 @@ var AttachmentModule = class {
|
|
|
125
125
|
if (options?.height !== void 0) params.height = options.height;
|
|
126
126
|
if (options?.width !== void 0) params.width = options.width;
|
|
127
127
|
if (options?.quality !== void 0) params.quality = options.quality;
|
|
128
|
-
const response = await this.http.get(`/api/v1/attachment/${guid}/download`, {
|
|
128
|
+
const response = await this.http.get(`/api/v1/attachment/${encodeURIComponent(guid)}/download`, {
|
|
129
129
|
params,
|
|
130
130
|
responseType: "arraybuffer"
|
|
131
131
|
});
|
|
132
132
|
return Buffer.from(response.data);
|
|
133
133
|
}
|
|
134
134
|
async downloadAttachmentLive(guid) {
|
|
135
|
-
const response = await this.http.get(`/api/v1/attachment/${guid}/live`, {
|
|
135
|
+
const response = await this.http.get(`/api/v1/attachment/${encodeURIComponent(guid)}/live`, {
|
|
136
136
|
responseType: "arraybuffer"
|
|
137
137
|
});
|
|
138
138
|
return Buffer.from(response.data);
|
|
@@ -142,7 +142,7 @@ var AttachmentModule = class {
|
|
|
142
142
|
if (options?.height !== void 0) params.height = options.height;
|
|
143
143
|
if (options?.width !== void 0) params.width = options.width;
|
|
144
144
|
if (options?.quality !== void 0) params.quality = options.quality;
|
|
145
|
-
const response = await this.http.get(`/api/v1/attachment/${guid}/blurhash`, {
|
|
145
|
+
const response = await this.http.get(`/api/v1/attachment/${encodeURIComponent(guid)}/blurhash`, {
|
|
146
146
|
params
|
|
147
147
|
});
|
|
148
148
|
return response.data.data.blurhash;
|
|
@@ -209,35 +209,35 @@ var ChatModule = class {
|
|
|
209
209
|
return response.data.data;
|
|
210
210
|
}
|
|
211
211
|
async getChat(guid, options) {
|
|
212
|
-
const response = await this.http.get(`/api/v1/chat/${guid}`, {
|
|
212
|
+
const response = await this.http.get(`/api/v1/chat/${encodeURIComponent(guid)}`, {
|
|
213
213
|
params: options?.with ? { with: options.with.join(",") } : {}
|
|
214
214
|
});
|
|
215
215
|
return response.data.data;
|
|
216
216
|
}
|
|
217
217
|
async updateChat(guid, options) {
|
|
218
|
-
const response = await this.http.put(`/api/v1/chat/${guid}`, options);
|
|
218
|
+
const response = await this.http.put(`/api/v1/chat/${encodeURIComponent(guid)}`, options);
|
|
219
219
|
return response.data.data;
|
|
220
220
|
}
|
|
221
221
|
async deleteChat(guid) {
|
|
222
|
-
await this.http.delete(`/api/v1/chat/${guid}`);
|
|
222
|
+
await this.http.delete(`/api/v1/chat/${encodeURIComponent(guid)}`);
|
|
223
223
|
}
|
|
224
224
|
async markChatRead(guid) {
|
|
225
|
-
await this.http.post(`/api/v1/chat/${guid}/read`);
|
|
225
|
+
await this.http.post(`/api/v1/chat/${encodeURIComponent(guid)}/read`);
|
|
226
226
|
}
|
|
227
227
|
async markChatUnread(guid) {
|
|
228
|
-
await this.http.post(`/api/v1/chat/${guid}/unread`);
|
|
228
|
+
await this.http.post(`/api/v1/chat/${encodeURIComponent(guid)}/unread`);
|
|
229
229
|
}
|
|
230
230
|
async leaveChat(guid) {
|
|
231
|
-
await this.http.post(`/api/v1/chat/${guid}/leave`);
|
|
231
|
+
await this.http.post(`/api/v1/chat/${encodeURIComponent(guid)}/leave`);
|
|
232
232
|
}
|
|
233
233
|
async addParticipant(chatGuid, address) {
|
|
234
|
-
const response = await this.http.post(`/api/v1/chat/${chatGuid}/participant`, {
|
|
234
|
+
const response = await this.http.post(`/api/v1/chat/${encodeURIComponent(chatGuid)}/participant`, {
|
|
235
235
|
address
|
|
236
236
|
});
|
|
237
237
|
return response.data.data;
|
|
238
238
|
}
|
|
239
239
|
async removeParticipant(chatGuid, address) {
|
|
240
|
-
const response = await this.http.delete(`/api/v1/chat/${chatGuid}/participant`, {
|
|
240
|
+
const response = await this.http.delete(`/api/v1/chat/${encodeURIComponent(chatGuid)}/participant`, {
|
|
241
241
|
data: { address }
|
|
242
242
|
});
|
|
243
243
|
return response.data.data;
|
|
@@ -250,7 +250,7 @@ var ChatModule = class {
|
|
|
250
250
|
if (options?.before !== void 0) params.before = options.before;
|
|
251
251
|
if (options?.after !== void 0) params.after = options.after;
|
|
252
252
|
if (options?.with) params.with = options.with.join(",");
|
|
253
|
-
const response = await this.http.get(`/api/v1/chat/${chatGuid}/message`, {
|
|
253
|
+
const response = await this.http.get(`/api/v1/chat/${encodeURIComponent(chatGuid)}/message`, {
|
|
254
254
|
params
|
|
255
255
|
});
|
|
256
256
|
return response.data.data;
|
|
@@ -260,15 +260,15 @@ var ChatModule = class {
|
|
|
260
260
|
const fileName = path__default.basename(filePath);
|
|
261
261
|
const form = new FormData();
|
|
262
262
|
form.append("icon", fileBuffer, fileName);
|
|
263
|
-
await this.http.post(`/api/v1/chat/${chatGuid}/icon`, form, {
|
|
263
|
+
await this.http.post(`/api/v1/chat/${encodeURIComponent(chatGuid)}/icon`, form, {
|
|
264
264
|
headers: form.getHeaders()
|
|
265
265
|
});
|
|
266
266
|
}
|
|
267
267
|
async removeGroupIcon(chatGuid) {
|
|
268
|
-
await this.http.delete(`/api/v1/chat/${chatGuid}/icon`);
|
|
268
|
+
await this.http.delete(`/api/v1/chat/${encodeURIComponent(chatGuid)}/icon`);
|
|
269
269
|
}
|
|
270
270
|
async getGroupIcon(chatGuid) {
|
|
271
|
-
const response = await this.http.get(`/api/v1/chat/${chatGuid}/icon`, {
|
|
271
|
+
const response = await this.http.get(`/api/v1/chat/${encodeURIComponent(chatGuid)}/icon`, {
|
|
272
272
|
responseType: "arraybuffer"
|
|
273
273
|
});
|
|
274
274
|
return Buffer.from(response.data);
|
|
@@ -280,10 +280,10 @@ var ChatModule = class {
|
|
|
280
280
|
return response.data.data;
|
|
281
281
|
}
|
|
282
282
|
async startTyping(chatGuid) {
|
|
283
|
-
await this.http.post(`/api/v1/chat/${chatGuid}/typing`);
|
|
283
|
+
await this.http.post(`/api/v1/chat/${encodeURIComponent(chatGuid)}/typing`);
|
|
284
284
|
}
|
|
285
285
|
async stopTyping(chatGuid) {
|
|
286
|
-
await this.http.delete(`/api/v1/chat/${chatGuid}/typing`);
|
|
286
|
+
await this.http.delete(`/api/v1/chat/${encodeURIComponent(chatGuid)}/typing`);
|
|
287
287
|
}
|
|
288
288
|
async getBackground(chatGuid) {
|
|
289
289
|
const response = await this.http.get(`/api/v1/chat/${encodeURIComponent(chatGuid)}/background`);
|
|
@@ -355,7 +355,7 @@ var HandleModule = class {
|
|
|
355
355
|
};
|
|
356
356
|
}
|
|
357
357
|
async getHandle(guid) {
|
|
358
|
-
const response = await this.http.get(`/api/v1/handle/${guid}`);
|
|
358
|
+
const response = await this.http.get(`/api/v1/handle/${encodeURIComponent(guid)}`);
|
|
359
359
|
return response.data.data;
|
|
360
360
|
}
|
|
361
361
|
async getHandleAvailability(address, type) {
|
|
@@ -365,7 +365,7 @@ var HandleModule = class {
|
|
|
365
365
|
return response.data.data.available;
|
|
366
366
|
}
|
|
367
367
|
async getHandleFocusStatus(guid) {
|
|
368
|
-
const response = await this.http.get(`/api/v1/handle/${guid}/focus`);
|
|
368
|
+
const response = await this.http.get(`/api/v1/handle/${encodeURIComponent(guid)}/focus`);
|
|
369
369
|
return response.data.data.status;
|
|
370
370
|
}
|
|
371
371
|
};
|
|
@@ -446,7 +446,7 @@ var MessageModule = class {
|
|
|
446
446
|
});
|
|
447
447
|
}
|
|
448
448
|
async getMessage(guid, options) {
|
|
449
|
-
const response = await this.http.get(`/api/v1/message/${guid}`, {
|
|
449
|
+
const response = await this.http.get(`/api/v1/message/${encodeURIComponent(guid)}`, {
|
|
450
450
|
params: options?.with ? { with: options.with.join(",") } : {}
|
|
451
451
|
});
|
|
452
452
|
return response.data.data;
|
|
@@ -491,7 +491,7 @@ var MessageModule = class {
|
|
|
491
491
|
}
|
|
492
492
|
async editMessage(options) {
|
|
493
493
|
return this.enqueueSend(async () => {
|
|
494
|
-
const response = await this.http.post(`/api/v1/message/${options.messageGuid}/edit`, {
|
|
494
|
+
const response = await this.http.post(`/api/v1/message/${encodeURIComponent(options.messageGuid)}/edit`, {
|
|
495
495
|
editedMessage: options.editedMessage,
|
|
496
496
|
backwardsCompatibilityMessage: options.backwardsCompatibilityMessage || options.editedMessage,
|
|
497
497
|
partIndex: options.partIndex ?? 0
|
|
@@ -512,21 +512,40 @@ var MessageModule = class {
|
|
|
512
512
|
}
|
|
513
513
|
async unsendMessage(options) {
|
|
514
514
|
return this.enqueueSend(async () => {
|
|
515
|
-
const response = await this.http.post(`/api/v1/message/${options.messageGuid}/unsend`, {
|
|
515
|
+
const response = await this.http.post(`/api/v1/message/${encodeURIComponent(options.messageGuid)}/unsend`, {
|
|
516
516
|
partIndex: options.partIndex ?? 0
|
|
517
517
|
});
|
|
518
518
|
return response.data.data;
|
|
519
519
|
});
|
|
520
520
|
}
|
|
521
521
|
async notifyMessage(guid) {
|
|
522
|
-
await this.http.post(`/api/v1/message/${guid}/notify`);
|
|
522
|
+
await this.http.post(`/api/v1/message/${encodeURIComponent(guid)}/notify`);
|
|
523
523
|
}
|
|
524
524
|
async getEmbeddedMedia(guid) {
|
|
525
|
-
const response = await this.http.get(`/api/v1/message/${guid}/embedded-media`);
|
|
525
|
+
const response = await this.http.get(`/api/v1/message/${encodeURIComponent(guid)}/embedded-media`);
|
|
526
526
|
return response.data.data;
|
|
527
527
|
}
|
|
528
528
|
async searchMessages(options) {
|
|
529
|
-
const
|
|
529
|
+
const { query, chatGuid, offset, limit, sort, before, after } = options;
|
|
530
|
+
if (!query || query.trim().length === 0) {
|
|
531
|
+
throw new Error("Search query cannot be empty");
|
|
532
|
+
}
|
|
533
|
+
const where = [
|
|
534
|
+
{
|
|
535
|
+
statement: "message.text LIKE :text",
|
|
536
|
+
args: { text: `%${query}%` }
|
|
537
|
+
}
|
|
538
|
+
];
|
|
539
|
+
const payload = {
|
|
540
|
+
where
|
|
541
|
+
};
|
|
542
|
+
if (chatGuid) payload.chatGuid = chatGuid;
|
|
543
|
+
if (offset !== void 0) payload.offset = offset;
|
|
544
|
+
if (limit !== void 0) payload.limit = limit;
|
|
545
|
+
if (sort) payload.sort = sort;
|
|
546
|
+
if (before !== void 0) payload.before = before;
|
|
547
|
+
if (after !== void 0) payload.after = after;
|
|
548
|
+
const response = await this.http.post("/api/v1/message/query", payload);
|
|
530
549
|
return response.data.data;
|
|
531
550
|
}
|
|
532
551
|
};
|
|
@@ -590,11 +609,11 @@ var ScheduledMessageModule = class {
|
|
|
590
609
|
return response.data.data;
|
|
591
610
|
}
|
|
592
611
|
async updateScheduledMessage(id, options) {
|
|
593
|
-
const response = await this.http.put(`/api/v1/message/schedule/${id}`, options);
|
|
612
|
+
const response = await this.http.put(`/api/v1/message/schedule/${encodeURIComponent(id)}`, options);
|
|
594
613
|
return response.data.data;
|
|
595
614
|
}
|
|
596
615
|
async deleteScheduledMessage(id) {
|
|
597
|
-
await this.http.delete(`/api/v1/message/schedule/${id}`);
|
|
616
|
+
await this.http.delete(`/api/v1/message/schedule/${encodeURIComponent(id)}`);
|
|
598
617
|
}
|
|
599
618
|
};
|
|
600
619
|
|