MCPcopy
hub / github.com/kopia/kopia / Send

Function Send

notification/notification_send.go:116–136  ·  view source on GitHub ↗

Send sends a notification for the given event. Any errors encountered during the process are logged.

(ctx context.Context, rep repo.Repository, templateName string, eventArgs notifydata.TypedEventArgs, sev Severity, opt notifytemplate.Options)

Source from the content-addressed store, hash-verified

114// Send sends a notification for the given event.
115// Any errors encountered during the process are logged.
116func Send(ctx context.Context, rep repo.Repository, templateName string, eventArgs notifydata.TypedEventArgs, sev Severity, opt notifytemplate.Options) {
117 // if we're connected to a repository server, send the notification there.
118 if rem, ok := rep.(repo.RemoteNotifications); ok {
119 jsonData, err := json.Marshal(eventArgs)
120 if err != nil {
121 log(ctx).Warnw("unable to marshal event args", "err", err)
122
123 return
124 }
125
126 if err := rem.SendNotification(ctx, templateName, jsonData, eventArgs.EventArgsType(), int32(sev)); err != nil {
127 log(ctx).Warnw("unable to send notification", "err", err)
128 }
129
130 return
131 }
132
133 if err := SendInternal(ctx, rep, templateName, eventArgs, sev, opt); err != nil {
134 log(ctx).Warnw("unable to send notification", "err", err)
135 }
136}
137
138// SendInternal sends a notification for the given event and returns an error.
139func SendInternal(ctx context.Context, rep repo.Repository, templateName string, eventArgs notifydata.TypedEventArgs, sev Severity, opt notifytemplate.Options) error {

Callers 5

runMethod · 0.92
repositoryActionMethod · 0.92
sendSnapshotReportMethod · 0.92

Calls 3

SendInternalFunction · 0.85
SendNotificationMethod · 0.65
EventArgsTypeMethod · 0.65

Tested by 1