22using Core . Data . Models ;
33using Core . Helpers ;
44using Core . Services ;
5+ using Markdig ;
56using Microsoft . AspNetCore . Cors ;
67using Microsoft . AspNetCore . Http ;
78using Microsoft . AspNetCore . Mvc ;
@@ -128,12 +129,22 @@ public async Task<NotificationModel> GetNotifications(string type, int page = 1)
128129 {
129130 var pager = new Pager ( page ) ;
130131 IEnumerable < Notification > items ;
131- AlertType noteType = AlertType . Primary ;
132+ AlertType noteType = AlertType . System ;
132133
133134 if ( type . ToUpper ( ) == "CONTACT" )
135+ {
134136 noteType = AlertType . Contact ;
135-
136- items = await _data . Notifications . GetList ( n => n . AlertType == noteType , pager ) ;
137+ items = await _data . Notifications . GetList ( n => n . AlertType == noteType , pager ) ;
138+ }
139+ else
140+ {
141+ await _notes . PullSystemNotifications ( ) ;
142+ items = await _data . Notifications . GetList ( n => n . AlertType == noteType && n . Active == true , pager ) ;
143+ foreach ( var item in items )
144+ {
145+ item . Content = Markdown . ToHtml ( item . Content ) ;
146+ }
147+ }
137148
138149 if ( page < 1 || page > pager . LastPage )
139150 return null ;
@@ -159,7 +170,17 @@ public IActionResult Delete(int id)
159170 var notification = _data . Notifications . Single ( n => n . Id == id ) ;
160171 if ( notification != null )
161172 {
162- _data . Notifications . Remove ( notification ) ;
173+ if ( notification . AlertType == AlertType . System )
174+ {
175+ // system notifications pulled from external sources
176+ // if just remove it, it will be pulled again
177+ // so just mark it as inactive instead
178+ notification . Active = false ;
179+ }
180+ else
181+ {
182+ _data . Notifications . Remove ( notification ) ;
183+ }
163184 _data . Complete ( ) ;
164185 }
165186 return Ok ( Resources . Removed ) ;
0 commit comments