@@ -55,7 +55,7 @@ func (m *workflowNotifier) NewIssue(ctx context.Context, issue *issues_model.Iss
5555 // Find workflows for the ItemOpened event
5656 for _ , workflow := range workflows {
5757 if workflow .WorkflowEvent == project_model .WorkflowEventItemOpened {
58- fireIssueWorkflow (ctx , workflow , issue , 0 )
58+ fireIssueWorkflow (ctx , workflow , issue , 0 , 0 )
5959 }
6060 }
6161}
@@ -92,7 +92,7 @@ func (m *workflowNotifier) IssueChangeStatus(ctx context.Context, doer *user_mod
9292 // Find workflows for the specific event
9393 for _ , workflow := range workflows {
9494 if workflow .WorkflowEvent == workflowEvent {
95- fireIssueWorkflow (ctx , workflow , issue , 0 )
95+ fireIssueWorkflow (ctx , workflow , issue , 0 , 0 )
9696 }
9797 }
9898}
@@ -124,12 +124,12 @@ func (*workflowNotifier) IssueChangeProjects(ctx context.Context, doer *user_mod
124124 // Find workflows for the ItemOpened event
125125 for _ , workflow := range workflows {
126126 if workflow .WorkflowEvent == project_model .WorkflowEventItemAddedToProject {
127- fireIssueWorkflow (ctx , workflow , issue , 0 )
127+ fireIssueWorkflow (ctx , workflow , issue , 0 , 0 )
128128 }
129129 }
130130}
131131
132- func (* workflowNotifier ) IssueChangeProjectColumn (ctx context.Context , doer * user_model.User , issue * issues_model.Issue , newColumnID int64 ) {
132+ func (* workflowNotifier ) IssueChangeProjectColumn (ctx context.Context , doer * user_model.User , issue * issues_model.Issue , oldColumnID , newColumnID int64 ) {
133133 if err := issue .LoadRepo (ctx ); err != nil {
134134 log .Error ("IssueChangeStatus: LoadRepo: %v" , err )
135135 return
@@ -158,7 +158,7 @@ func (*workflowNotifier) IssueChangeProjectColumn(ctx context.Context, doer *use
158158 // Find workflows for the ItemColumnChanged event
159159 for _ , workflow := range workflows {
160160 if workflow .WorkflowEvent == project_model .WorkflowEventItemColumnChanged {
161- fireIssueWorkflow (ctx , workflow , issue , newColumnID )
161+ fireIssueWorkflow (ctx , workflow , issue , oldColumnID , newColumnID )
162162 }
163163 }
164164}
@@ -192,7 +192,7 @@ func (*workflowNotifier) MergePullRequest(ctx context.Context, doer *user_model.
192192 // Find workflows for the PullRequestMerged event
193193 for _ , workflow := range workflows {
194194 if workflow .WorkflowEvent == project_model .WorkflowEventPullRequestMerged {
195- fireIssueWorkflow (ctx , workflow , issue , 0 )
195+ fireIssueWorkflow (ctx , workflow , issue , 0 , 0 )
196196 }
197197 }
198198}
@@ -231,12 +231,12 @@ func (*workflowNotifier) PullRequestReview(ctx context.Context, pr *issues_model
231231 for _ , workflow := range workflows {
232232 if (workflow .WorkflowEvent == project_model .WorkflowEventCodeChangesRequested && review .Type == issues_model .ReviewTypeReject ) ||
233233 (workflow .WorkflowEvent == project_model .WorkflowEventCodeReviewApproved && review .Type == issues_model .ReviewTypeApprove ) {
234- fireIssueWorkflow (ctx , workflow , issue , 0 )
234+ fireIssueWorkflow (ctx , workflow , issue , 0 , 0 )
235235 }
236236 }
237237}
238238
239- func fireIssueWorkflow (ctx context.Context , workflow * project_model.Workflow , issue * issues_model.Issue , columnID int64 ) {
239+ func fireIssueWorkflow (ctx context.Context , workflow * project_model.Workflow , issue * issues_model.Issue , sourceColumnID , targetColumnID int64 ) {
240240 if ! workflow .Enabled {
241241 return
242242 }
@@ -247,15 +247,15 @@ func fireIssueWorkflow(ctx context.Context, workflow *project_model.Workflow, is
247247 return
248248 }
249249
250- if ! matchWorkflowsFilters (workflow , issue , columnID ) {
250+ if ! matchWorkflowsFilters (workflow , issue , sourceColumnID , targetColumnID ) {
251251 return
252252 }
253253
254254 executeWorkflowActions (ctx , workflow , issue )
255255}
256256
257257// matchWorkflowsFilters checks if the issue matches all filters of the workflow
258- func matchWorkflowsFilters (workflow * project_model.Workflow , issue * issues_model.Issue , columnID int64 ) bool {
258+ func matchWorkflowsFilters (workflow * project_model.Workflow , issue * issues_model.Issue , sourceColumnID , targetColumnID int64 ) bool {
259259 for _ , filter := range workflow .WorkflowFilters {
260260 switch filter .Type {
261261 case project_model .WorkflowFilterTypeIssueType :
@@ -270,7 +270,7 @@ func matchWorkflowsFilters(workflow *project_model.Workflow, issue *issues_model
270270 if filter .Value == "pull_request" && ! issue .IsPull {
271271 return false
272272 }
273- case project_model .WorkflowFilterTypeColumn :
273+ case project_model .WorkflowFilterTypeTargetColumn :
274274 // If filter value is empty, match all columns
275275 if filter .Value == "" {
276276 continue
@@ -281,7 +281,21 @@ func matchWorkflowsFilters(workflow *project_model.Workflow, issue *issues_model
281281 return false
282282 }
283283 // For column changed event, check against the new column ID
284- if columnID > 0 && columnID != filterColumnID {
284+ if targetColumnID > 0 && targetColumnID != filterColumnID {
285+ return false
286+ }
287+ case project_model .WorkflowFilterTypeSourceColumn :
288+ // If filter value is empty, match all columns
289+ if filter .Value == "" {
290+ continue
291+ }
292+ filterColumnID , _ := strconv .ParseInt (filter .Value , 10 , 64 )
293+ if filterColumnID == 0 {
294+ log .Error ("Invalid column ID: %s" , filter .Value )
295+ return false
296+ }
297+ // For column changed event, check against the new column ID
298+ if sourceColumnID > 0 && sourceColumnID != filterColumnID {
285299 return false
286300 }
287301 case project_model .WorkflowFilterTypeLabels :
0 commit comments