@@ -173,18 +173,6 @@ func parsePRUrl(prURL string) (*prURLInfo, error) {
173173
174174// Helper functions to reduce cognitive complexity.
175175
176- func matchesEventType (sub Subscription , eventType string ) bool {
177- if len (sub .EventTypes ) == 0 {
178- return true // No filter means all events
179- }
180- for _ , allowedType := range sub .EventTypes {
181- if eventType == allowedType {
182- return true
183- }
184- }
185- return false
186- }
187-
188176func extractEventOrg (payload map [string ]any ) string {
189177 // Check repository owner first
190178 if repo , ok := payload ["repository" ].(map [string ]any ); ok {
@@ -254,8 +242,17 @@ func matchesPRSubscription(sub Subscription, payload map[string]any, eventOrg st
254242
255243func matches (sub Subscription , event Event , payload map [string ]any , userOrgs map [string ]bool ) bool {
256244 // Check if event type matches subscription
257- if ! matchesEventType (sub , event .Type ) {
258- return false
245+ if len (sub .EventTypes ) > 0 {
246+ found := false
247+ for _ , allowedType := range sub .EventTypes {
248+ if event .Type == allowedType {
249+ found = true
250+ break
251+ }
252+ }
253+ if ! found {
254+ return false
255+ }
259256 }
260257
261258 // Extract the organization from the event
@@ -310,18 +307,6 @@ func matchesUserInObject(user map[string]any, username string) bool {
310307 return ok && strings .EqualFold (login , username )
311308}
312309
313- // matchesUserInList checks if username matches any login in a list of user objects.
314- func matchesUserInList (users []any , username string ) bool {
315- for _ , item := range users {
316- if user , ok := item .(map [string ]any ); ok {
317- if matchesUserInObject (user , username ) {
318- return true
319- }
320- }
321- }
322- return false
323- }
324-
325310// checkPullRequestUsers checks PR author, assignees, and reviewers.
326311func checkPullRequestUsers (pr map [string ]any , username string ) bool {
327312 // Check PR author
@@ -333,15 +318,23 @@ func checkPullRequestUsers(pr map[string]any, username string) bool {
333318
334319 // Check assignees
335320 if assignees , ok := pr ["assignees" ].([]any ); ok {
336- if matchesUserInList (assignees , username ) {
337- return true
321+ for _ , item := range assignees {
322+ if user , ok := item .(map [string ]any ); ok {
323+ if matchesUserInObject (user , username ) {
324+ return true
325+ }
326+ }
338327 }
339328 }
340329
341330 // Check requested reviewers
342331 if reviewers , ok := pr ["requested_reviewers" ].([]any ); ok {
343- if matchesUserInList (reviewers , username ) {
344- return true
332+ for _ , item := range reviewers {
333+ if user , ok := item .(map [string ]any ); ok {
334+ if matchesUserInObject (user , username ) {
335+ return true
336+ }
337+ }
345338 }
346339 }
347340
0 commit comments