@@ -5,24 +5,34 @@ import (
55	"net/http" 
66)
77
8+ type  HandledEventResult  struct  {
9+ 	AppliedRules  []string  `json:"applied_rules,omitempty"` 
10+ 	Message       string    `json:"message,omitempty"` 
11+ }
12+ 
813type  Bot  interface  {
9- 	HandleEvent (r  * http.Request )
14+ 	HandleEvent (r  * http.Request )  * HandledEventResult 
1015}
1116
1217type  bot  struct  {
1318	configuration  Configuration 
1419}
1520
16- func  (b  * bot ) HandleEvent (r  * http.Request ) {
21+ func  (b  * bot ) HandleEvent (r  * http.Request ) * HandledEventResult  {
22+ 	result  :=  & HandledEventResult {
23+ 		AppliedRules : []string {},
24+ 	}
1725	data , process  :=  buildFromRequest (b .configuration .GetClientConfig (), r )
1826	if  ! process  {
19- 		return 
27+ 		result .Message  =  "Skipping rules processing (could be not supported event type)" 
28+ 		return  result 
2029	}
2130	applied  :=  make ([]Rule , 0 )
2231	for  _ , rule  :=  range  b .configuration .GetRules () {
2332		if  rule .Accept (data ) {
2433			util .Logger .Debug ("Accepting rule %s for '%s'" , rule .Name (), data .GetTitle ())
2534			applied  =  append (applied , rule )
35+ 			result .AppliedRules  =  append (result .AppliedRules , rule .Name ())
2636		}
2737	}
2838	for  _ , rule  :=  range  applied  {
@@ -31,6 +41,7 @@ func (b *bot) HandleEvent(r *http.Request) {
3141			action .Apply (b .configuration , data )
3242		}
3343	}
44+ 	return  result 
3445}
3546
3647func  New (configPath  string ) (Bot , error ) {
0 commit comments