bot-functions 1.3.4 → 1.3.5

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.
Files changed (2) hide show
  1. package/index.js +17 -29
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -324,42 +324,29 @@ class EmailManager {
324
324
  if (!this.connection) {
325
325
  throw new Error('Not connected to email account');
326
326
  }
327
+
327
328
  const uidArray = Array.isArray(uids) ? uids : [uids];
329
+
328
330
  try {
329
- try {
330
- for (const uid of uidArray) {
331
- await this.connection.move(uid, '[Gmail]/Trash');
332
- }
333
- return { success: true, deletedCount: uidArray.length, action: 'moved_to_trash' };
334
- } catch (moveError) {
335
- try {
336
- for (const uid of uidArray) {
337
- await this.connection.move(uid, 'Deleted Items');
338
- }
339
- return { success: true, deletedCount: uidArray.length, action: 'moved_to_deleted_items' };
340
- } catch (moveError2) {
341
- try {
342
- for (const uid of uidArray) {
343
- await this.connection.move(uid, 'TRASH');
344
- }
345
- return { success: true, deletedCount: uidArray.length, action: 'moved_to_trash_folder' };
346
- } catch (moveError3) {
347
- for (const uid of uidArray) {
348
- await this.connection.addFlags(uid, '\\Deleted');
349
- }
350
- await this.connection.closeBox(false);
351
- await this.connection.openBox('INBOX');
352
- return { success: true, deletedCount: uidArray.length, action: 'marked_deleted' };
353
- }
354
- }
331
+ for (const uid of uidArray) {
332
+ await this.connection.addFlags(uid, '\\Deleted');
355
333
  }
334
+ await this.connection.imap.expunge();
335
+ log.info(`Successfully deleted ${uidArray.length} email(s)`);
336
+
337
+ return {
338
+ success: true,
339
+ deletedCount: uidArray.length,
340
+ action: 'deleted'
341
+ };
342
+
356
343
  } catch (error) {
357
344
  log.error("Error deleting emails:", error);
358
- return;
345
+ throw new Error(`Failed to delete emails: ${error.message}`);
359
346
  } finally {
360
347
  if (this.connection) {
361
348
  try {
362
- this.connection.end();
349
+ await this.connection.end();
363
350
  this.connection = null;
364
351
  } catch (error) {
365
352
  log.error("Error disconnecting:", error);
@@ -1409,5 +1396,6 @@ module.exports = {
1409
1396
  EmailManager,
1410
1397
  manageEmails,
1411
1398
  insertLogExec,
1412
- sendDataCH
1399
+ sendDataCH,
1400
+ processDataDaily
1413
1401
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bot-functions",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Bot functions",
5
5
  "main": "index.js",
6
6
  "scripts": {