MCPcopy
hub / github.com/kopia/kopia / handleSendNotificationRequest

Method handleSendNotificationRequest

internal/server/grpc_session.go:507–533  ·  view source on GitHub ↗
(ctx context.Context, rep repo.RepositoryWriter, authz auth.AuthorizationInfo, req *grpcapi.SendNotificationRequest)

Source from the content-addressed store, hash-verified

505}
506
507func (s *Server) handleSendNotificationRequest(ctx context.Context, rep repo.RepositoryWriter, authz auth.AuthorizationInfo, req *grpcapi.SendNotificationRequest) *grpcapi.SessionResponse {
508 ctx, span := tracer.Start(ctx, "GRPCSession.SendNotification")
509 defer span.End()
510
511 if authz.ContentAccessLevel() < auth.AccessLevelAppend {
512 return accessDeniedResponse()
513 }
514
515 eventArgs, err := notifydata.UnmarshalEventArgs(req.GetEventArgs(), req.GetEventArgsType())
516 if err != nil {
517 return errorResponse(err)
518 }
519
520 if err := notification.SendInternal(ctx, rep,
521 req.GetTemplateName(),
522 eventArgs,
523 notification.Severity(req.GetSeverity()),
524 s.options.NotifyTemplateOptions); err != nil {
525 return errorResponse(err)
526 }
527
528 return &grpcapi.SessionResponse{
529 Response: &grpcapi.SessionResponse_SendNotification{
530 SendNotification: &grpcapi.SendNotificationResponse{},
531 },
532 }
533}
534
535func accessDeniedResponse() *grpcapi.SessionResponse {
536 return &grpcapi.SessionResponse{

Callers 1

handleSessionRequestMethod · 0.95

Calls 10

UnmarshalEventArgsFunction · 0.92
SendInternalFunction · 0.92
accessDeniedResponseFunction · 0.85
errorResponseFunction · 0.85
GetEventArgsMethod · 0.80
GetEventArgsTypeMethod · 0.80
GetTemplateNameMethod · 0.80
GetSeverityMethod · 0.80
StartMethod · 0.65
ContentAccessLevelMethod · 0.65

Tested by

no test coverage detected