55namespace Microsoft . OneFuzz . Service ;
66
77public interface INotificationOperations : IOrm < Notification > {
8- Async . Task NewFiles ( Container container , string filename , bool isLastRetryAttempt ) ;
8+ Async . Task < OneFuzzResultVoid > NewFiles ( Container container , string filename , bool isLastRetryAttempt ) ;
99 IAsyncEnumerable < Notification > GetNotifications ( Container container ) ;
1010 IAsyncEnumerable < ( Task , IEnumerable < Container > ) > GetQueueTasks ( ) ;
1111 Async . Task < OneFuzzResult < Notification > > Create ( Container container , NotificationTemplate config , bool replaceExisting ) ;
@@ -21,10 +21,12 @@ public NotificationOperations(ILogger<NotificationOperations> log, IOnefuzzConte
2121 : base ( log , context ) {
2222
2323 }
24- public async Async . Task NewFiles ( Container container , string filename , bool isLastRetryAttempt ) {
24+ public async Async . Task < OneFuzzResultVoid > NewFiles ( Container container , string filename , bool isLastRetryAttempt ) {
25+ var result = OneFuzzResultVoid . Ok ;
26+
2527 // We don't want to store file added events for the events container because that causes an infinite loop
2628 if ( container == WellKnownContainers . Events ) {
27- return ;
29+ return result ;
2830 }
2931
3032 var notifications = GetNotifications ( container ) ;
@@ -38,7 +40,10 @@ public async Async.Task NewFiles(Container container, string filename, bool isLa
3840 }
3941
4042 done . Add ( notification . Config ) ;
41- _ = await TriggerNotification ( container , notification , reportOrRegression , isLastRetryAttempt ) ;
43+ var notificationResult = await TriggerNotification ( container , notification , reportOrRegression , isLastRetryAttempt ) ;
44+ if ( result . IsOk && ! notificationResult . IsOk ) {
45+ result = notificationResult ;
46+ }
4247 }
4348 }
4449
@@ -77,6 +82,8 @@ public async Async.Task NewFiles(Container container, string filename, bool isLa
7782 } else {
7883 await _context . Events . SendEvent ( new EventFileAdded ( container , filename ) ) ;
7984 }
85+
86+ return result ;
8087 }
8188
8289 public async System . Threading . Tasks . Task < OneFuzzResultVoid > TriggerNotification ( Container container ,
@@ -87,8 +94,12 @@ await _context.Teams.NotifyTeams(teamsTemplate, container, reportOrRegression!,
8794 notification . NotificationId ) ;
8895 break ;
8996 case AdoTemplate adoTemplate when reportOrRegression is not null :
90- return await _context . Ado . NotifyAdo ( adoTemplate , container , reportOrRegression , isLastRetryAttempt ,
91- notification . NotificationId ) ;
97+ if ( await _context . FeatureManagerSnapshot . IsEnabledAsync ( FeatureFlagConstants . EnableWorkItemCreation ) ) {
98+ return await _context . Ado . NotifyAdo ( adoTemplate , container , reportOrRegression , isLastRetryAttempt ,
99+ notification . NotificationId ) ;
100+ } else {
101+ return OneFuzzResultVoid . Error ( ErrorCode . ADO_WORKITEM_PROCESSING_DISABLED , "Work item processing is currently disabled" ) ;
102+ }
92103 case GithubIssuesTemplate githubIssuesTemplate when reportOrRegression is not null :
93104 await _context . GithubIssues . GithubIssue ( githubIssuesTemplate , container , reportOrRegression ,
94105 notification . NotificationId ) ;
0 commit comments