MCPcopy
hub / github.com/safing/portmaster / notify

Method notify

service/compat/notify.go:153–232  ·  view source on GitHub ↗
(proc *process.Process)

Source from the content-addressed store, hash-verified

151}
152
153func (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 = &notifications.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)

Callers 3

selfcheckTaskFuncFunction · 0.45

Calls 11

WarningfFunction · 0.92
GetFunction · 0.92
NotifyFunction · 0.92
isOverThresholdFunction · 0.85
LocalProfileMethod · 0.80
ProfileMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65
SaveMethod · 0.65
GoMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected