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)
| 114 | // Send sends a notification for the given event. |
| 115 | // Any errors encountered during the process are logged. |
| 116 | func 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. |
| 139 | func SendInternal(ctx context.Context, rep repo.Repository, templateName string, eventArgs notifydata.TypedEventArgs, sev Severity, opt notifytemplate.Options) error { |