Ahmad Kholid 2 år sedan
förälder
incheckning
468afebaeb
2 ändrade filer med 19 tillägg och 74 borttagningar
  1. 1 1
      package.json
  2. 18 73
      src/workflowEngine/index.js

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "automa",
-  "version": "1.28.0",
+  "version": "1.28.1",
   "description": "An extension for automating your browser by connecting blocks",
   "repository": {
     "type": "git",

+ 18 - 73
src/workflowEngine/index.js

@@ -5,7 +5,6 @@ import dayjs from '@/lib/dayjs';
 import { parseJSON } from '@/utils/helper';
 import { fetchApi } from '@/utils/api';
 import { sendMessage } from '@/utils/message';
-import getBlockMessage from '@/utils/getBlockMessage';
 import convertWorkflowData from '@/utils/convertWorkflowData';
 import WorkflowState from './WorkflowState';
 import WorkflowLogger from './WorkflowLogger';
@@ -65,81 +64,27 @@ export function startWorkflowExec(workflowData, options, isPopup = true) {
   });
 
   engine.init();
-  engine.on(
-    'destroyed',
-    ({
-      id,
-      status,
-      history,
-      startedTimestamp,
-      endedTimestamp,
-      blockDetail,
-    }) => {
-      if (
-        clonedWorkflowData.id.startsWith('team') &&
-        clonedWorkflowData.teamId
-      ) {
-        const payload = {
-          status,
-          workflowId: clonedWorkflowData.id,
-          workflowLog: {
-            status,
-            endedTimestamp,
-            startedTimestamp,
-          },
-        };
-
-        if (status === 'error') {
-          const message = getBlockMessage(blockDetail);
-          const workflowHistory = history.map((item) => {
-            delete item.logId;
-            delete item.prevBlockData;
-            delete item.workerId;
-
-            item.description = item.description || '';
-
-            return item;
+  engine.on('destroyed', ({ id, status }) => {
+    if (status !== 'stopped') {
+      browser.permissions
+        .contains({ permissions: ['notifications'] })
+        .then((hasPermission) => {
+          if (!hasPermission || !clonedWorkflowData.settings.notification)
+            return;
+
+          const name = clonedWorkflowData.name.slice(0, 32);
+
+          browser.notifications.create(`logs:${id}`, {
+            type: 'basic',
+            iconUrl: browser.runtime.getURL('icon-128.png'),
+            title: status === 'success' ? 'Success' : 'Error',
+            message: `${
+              status === 'success' ? 'Successfully' : 'Failed'
+            } to run the "${name}" workflow`,
           });
-          payload.workflowLog = {
-            status,
-            message,
-            endedTimestamp,
-            startedTimestamp,
-            history: workflowHistory,
-            blockId: blockDetail.blockId,
-          };
-        }
-
-        fetchApi(`/teams/${clonedWorkflowData.teamId}/workflows/logs`, {
-          auth: true,
-          method: 'POST',
-          body: JSON.stringify(payload),
-        }).catch((error) => {
-          console.error(error);
         });
-      }
-
-      if (status !== 'stopped') {
-        browser.permissions
-          .contains({ permissions: ['notifications'] })
-          .then((hasPermission) => {
-            if (!hasPermission || !clonedWorkflowData.settings.notification)
-              return;
-
-            const name = clonedWorkflowData.name.slice(0, 32);
-
-            browser.notifications.create(`logs:${id}`, {
-              type: 'basic',
-              iconUrl: browser.runtime.getURL('icon-128.png'),
-              title: status === 'success' ? 'Success' : 'Error',
-              message: `${
-                status === 'success' ? 'Successfully' : 'Failed'
-              } to run the "${name}" workflow`,
-            });
-          });
-      }
     }
-  );
+  });
 
   browser.storage.local.get('checkStatus').then(({ checkStatus }) => {
     const isSameDay = dayjs().isSame(checkStatus, 'day');