(proc *process.Process)
| 151 | } |
| 152 | |
| 153 | func (issue *appIssue) notify(proc *process.Process) { |
| 154 | // Get profile from process. |
| 155 | p := proc.Profile().LocalProfile() |
| 156 | if p == nil { |
| 157 | return |
| 158 | } |
| 159 | |
| 160 | // Ignore notifications for unidentified processes. |
| 161 | if p.ID == profile.UnidentifiedProfileID { |
| 162 | return |
| 163 | } |
| 164 | |
| 165 | // Log warning. |
| 166 | log.Warningf( |
| 167 | "compat: detected %s issue with %s", |
| 168 | strings.ReplaceAll( |
| 169 | strings.TrimPrefix( |
| 170 | strings.TrimSuffix(issue.id, "-%s"), |
| 171 | "compat:", |
| 172 | ), |
| 173 | "-", " ", |
| 174 | ), |
| 175 | proc.Path, |
| 176 | ) |
| 177 | |
| 178 | // Check if we already have this notification. |
| 179 | eventID := fmt.Sprintf(issue.id, p.ID) |
| 180 | n := notifications.Get(eventID) |
| 181 | if n != nil { |
| 182 | return |
| 183 | } |
| 184 | |
| 185 | // Check if we reach the threshold to actually send a notification. |
| 186 | if !isOverThreshold(eventID) { |
| 187 | return |
| 188 | } |
| 189 | |
| 190 | // Build message. |
| 191 | message := strings.ReplaceAll(issue.message, "[APPNAME]", p.Name) |
| 192 | |
| 193 | // Create a new notification. |
| 194 | n = ¬ifications.Notification{ |
| 195 | EventID: eventID, |
| 196 | Type: issue.level, |
| 197 | Title: fmt.Sprintf(issue.title, p.Name), |
| 198 | Message: message, |
| 199 | ShowOnSystem: true, |
| 200 | AvailableActions: issue.actions, |
| 201 | } |
| 202 | if len(n.AvailableActions) == 0 { |
| 203 | n.AvailableActions = []*notifications.Action{ |
| 204 | { |
| 205 | ID: "ack", |
| 206 | Text: "OK", |
| 207 | }, |
| 208 | } |
| 209 | } |
| 210 | notifications.Notify(n) |
no test coverage detected