Skip to content

Commit

Permalink
feat: add isManualExecution flag to workflow execution and related co…
Browse files Browse the repository at this point in the history
…mponents
  • Loading branch information
simlarsen committed Feb 26, 2025
1 parent cf7c39d commit a18207b
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 112 deletions.
16 changes: 10 additions & 6 deletions Common/Server/Services/WorkspaceNotificationRuleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import WorkspaceUserAuthTokenService from "./WorkspaceUserAuthTokenService";
import WorkspaceMessagePayload, {
WorkspaceMessageBlock,
} from "../../Types/Workspace/WorkspaceMessagePayload";
import WorkspaceProjectAuthToken, { MiscData, SlackMiscData } from "../../Models/DatabaseModels/WorkspaceProjectAuthToken";
import WorkspaceProjectAuthToken, {
MiscData,
SlackMiscData,
} from "../../Models/DatabaseModels/WorkspaceProjectAuthToken";
import WorkspaceProjectAuthTokenService from "./WorkspaceProjectAuthTokenService";
import logger from "../Utils/Logger";

Expand All @@ -52,14 +55,16 @@ export class Service extends DatabaseService<Model> {
const miscData: MiscData | undefined = data.projectAuthToken.miscData;

if (!miscData) {
throw new BadDataException("Misc data not found in project auth token");
throw new BadDataException("Misc data not found in project auth token");
}

if(data.workspaceType === WorkspaceType.Slack) {
const userId: string = (miscData as SlackMiscData).botUserId;
if (data.workspaceType === WorkspaceType.Slack) {
const userId: string = (miscData as SlackMiscData).botUserId;

if (!userId) {
throw new BadDataException("Bot user ID not found in project auth token");
throw new BadDataException(
"Bot user ID not found in project auth token",
);
}

return userId;
Expand All @@ -68,7 +73,6 @@ export class Service extends DatabaseService<Model> {
throw new BadDataException("Workspace type not supported");
}


public async createInviteAndPostToChannelsBasedOnRules(data: {
projectId: ObjectID;
notificationRuleEventType: NotificationRuleEventType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export default class OnTriggerBaseModel<
returnValues: {
data: requestData,
},
isManualExecution: false,
};

promises.push(props.executeWorkflow(executeWorkflow));
Expand Down
2 changes: 2 additions & 0 deletions Common/Server/Types/Workflow/Components/Schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default class WebhookTrigger extends TriggerCode {
const executeWorkflow: ExecuteWorkflowType = {
workflowId: new ObjectID(workflow._id!),
returnValues: {},
isManualExecution: false,
};

if (
Expand Down Expand Up @@ -122,6 +123,7 @@ export default class WebhookTrigger extends TriggerCode {
const executeWorkflow: ExecuteWorkflowType = {
workflowId: new ObjectID(workflow._id!),
returnValues: {},
isManualExecution: false,
};

if (
Expand Down
1 change: 1 addition & 0 deletions Common/Server/Types/Workflow/Components/Webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default class WebhookTrigger extends TriggerCode {
"request-params": req.query,
"request-body": req.body,
},
isManualExecution: false,
};

await props.executeWorkflow(executeWorkflow);
Expand Down
2 changes: 2 additions & 0 deletions Common/Server/Types/Workflow/TriggerCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { Port } from "Common/Types/Workflow/Component";
export interface ExecuteWorkflowType {
workflowId: ObjectID;
returnValues: JSONObject;
// is this workflow triggered manually or not
isManualExecution: boolean;
}

export interface InitProps {
Expand Down
1 change: 1 addition & 0 deletions Common/Server/Types/Workflow/Workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export interface RunProps {
workflowId: ObjectID;
workflowLogId: ObjectID | null;
timeout: number;
isManualExecution: boolean;
}
Loading

0 comments on commit a18207b

Please sign in to comment.