// IsNotifications returns the value of Notifications or the default (true)
553991
func IsNotifications(ctx context.Context) bool {
	bv, ok := ctx.Value(ctxKeyNotifications).(bool)
	if !ok {
		return true
	}
	return bv
}
556114
func NewSetPressureNotificationsSuppressedArgs(suppressed bool) *SetPressureNotificationsSuppressedArgs {
	args := new(SetPressureNotificationsSuppressedArgs)
	args.Suppressed = suppressed
	return args
}
381786
func (cfg *notificationsAsConfigV0) mapToNotificationFromConfig() *notificationsAsConfig {
	r := &notificationsAsConfig{}
	if cfg == nil {
		return r
	}

	for _, notification := range cfg.Notifications {
		r.Notifications = append(r.Notifications, &notificationFromConfig{
			Uid:                   notification.Uid.Value(),
			OrgId:                 notification.OrgId.Value(),
			OrgName:               notification.OrgName.Value(),
			Name:                  notification.Name.Value(),
			Type:                  notification.Type.Value(),
			IsDefault:             notification.IsDefault.Value(),
			Settings:              notification.Settings.Value(),
			DisableResolveMessage: notification.DisableResolveMessage.Value(),
			Frequency:             notification.Frequency.Value(),
			SendReminder:          notification.SendReminder.Value(),
		})
	}

	for _, notification := range cfg.DeleteNotifications {
		r.DeleteNotifications = append(r.DeleteNotifications, &deleteNotificationConfig{
			Uid:     notification.Uid.Value(),
			OrgId:   notification.OrgId.Value(),
			OrgName: notification.OrgName.Value(),
			Name:    notification.Name.Value(),
		})
	}

	return r
}
827321
func (client *Client) ListNotifications(ctx context.Context, options *ListOptions) (list NotificationList, err error) {
	err = client.listRequest(ctx, "assembly_notifications", options, &list)
	return list, err
}
520040
func (n *Notification) ShouldNotify(oldStatus, newStatus buildbucketpb.Status) bool {
	switch {
	case newStatus == buildbucketpb.Status_STATUS_UNSPECIFIED:
		panic("new status must always be valid")
	case n.OnSuccess && newStatus == buildbucketpb.Status_SUCCESS:
	case n.OnFailure && newStatus == buildbucketpb.Status_FAILURE:
	case n.OnChange && oldStatus != buildbucketpb.Status_STATUS_UNSPECIFIED && newStatus != oldStatus:
	case n.OnNewFailure && newStatus == buildbucketpb.Status_FAILURE && oldStatus != buildbucketpb.Status_FAILURE:

	default:
		return false
	}
	return true
}
425795
func (s *AssessmentRun) SetNotifications(v []*AssessmentRunNotification) *AssessmentRun {
	s.Notifications = v
	return s
}
122179
func (s *NotificationWithSubscribers) SetNotification(v *Notification) *NotificationWithSubscribers {
	s.Notification = v
	return s
}
132818
func (s *PutNotificationConfigurationInput) SetNotificationTypes(v []*string) *PutNotificationConfigurationInput {
	s.NotificationTypes = v
	return s
}
626040
func (s *GetIdentityNotificationAttributesOutput) SetNotificationAttributes(v map[string]*IdentityNotificationAttributes) *GetIdentityNotificationAttributesOutput {
	s.NotificationAttributes = v
	return s
}
720668
func (emailNotifier *EmailNotifier) Notify(alerts Messages) bool {

	overAllStatus, pass, warn, fail := alerts.Summary()
	nodeMap := mapByNodes(alerts)

	var emailDataList []TemplateData

	if emailNotifier.OnePerAlert {
		log.Println("Going to send one email per alert")
		emailDataList = []TemplateData{}
		for _, check := range alerts {

			singleAlertChecks := make(Messages, 0)
			singleAlertChecks = append(singleAlertChecks, check)
			singleAlertMap := mapByNodes(singleAlertChecks)

			alertStatus, alertPassing, alertWarnings, alertFailures := singleAlertChecks.Summary()

			alertClusterName := emailNotifier.ClusterName + " " + check.Node + " - " + check.CheckId

			e := TemplateData{
				ClusterName:  alertClusterName,
				SystemStatus: alertStatus,
				FailCount:    alertFailures,
				WarnCount:    alertWarnings,
				PassCount:    alertPassing,
				Nodes:        singleAlertMap,
			}
			emailDataList = append(emailDataList, e)
		}
	} else if emailNotifier.OnePerNode {
		log.Println("Going to send one email per node")
		emailDataList = []TemplateData{}
		for nodeName, checks := range nodeMap {
			singleNodeMap := mapByNodes(checks)
			nodeStatus, nodePassing, nodeWarnings, nodeFailures := checks.Summary()

			nodeClusterName := emailNotifier.ClusterName + " " + nodeName

			e := TemplateData{
				ClusterName:  nodeClusterName,
				SystemStatus: nodeStatus,
				FailCount:    nodeFailures,
				WarnCount:    nodeWarnings,
				PassCount:    nodePassing,
				Nodes:        singleNodeMap,
			}
			emailDataList = append(emailDataList, e)
		}
	} else {
		log.Println("Going to send one email for many alerts")
		e := TemplateData{
			ClusterName:  emailNotifier.ClusterName,
			SystemStatus: overAllStatus,
			FailCount:    fail,
			WarnCount:    warn,
			PassCount:    pass,
			Nodes:        nodeMap,
		}

		emailDataList = []TemplateData{e}
	}

	success := true

	for _, e := range emailDataList {

		var renderedTemplate string
		var err error
		renderedTemplate, err = renderTemplate(e, emailNotifier.Template, defaultTemplate)

		if err != nil {
			log.Println("Template error, unable to send email notification: ", err)
			success = false
			continue
		}

		msg := fmt.Sprintf(`From: "%s" <%s>
To: %s
Subject: %s is %s
MIME-version: 1.0;
Content-Type: text/html; charset="UTF-8";

%s
`,
			emailNotifier.SenderAlias,
			emailNotifier.SenderEmail,
			strings.Join(emailNotifier.Receivers, ", "),
			e.ClusterName,
			e.SystemStatus,
			renderedTemplate)

		addr := fmt.Sprintf("%s:%d", emailNotifier.Url, emailNotifier.Port)
		auth := smtp.PlainAuth("", emailNotifier.Username, emailNotifier.Password, emailNotifier.Url)
		if err := sendMail(addr, auth, emailNotifier.SenderEmail, emailNotifier.Receivers, []byte(msg)); err != nil {
			log.Println("Unable to send notification:", err)
			continue
		}
		log.Println("Email notification sent.")
		success = success && true
	}

	return success
}
1110939
func (s *NotificationConfig) SetNotificationEvents(v []*string) *NotificationConfig {
	s.NotificationEvents = v
	return s
}
876214
func (p Path) IsValidForNotification() bool {
	if !p.IsValid() {
		return false
	}

	if p.Tlf == (tlf.NullID) {
		return false
	}

	return len(p.Path[0].Name) > 0 && !strings.HasPrefix(p.Path[0].Name, "<")
}
384048
func (hc *Check) Notify() {
	hc.notify <- &Notification{
		Id:     hc.Id,
		Status: hc.Status(),
	}
}
835672
func Notify(ctx context.Context, subj, msg string) error {
	if os.Getenv("GOPASS_NO_NOTIFY") != "" || !ctxutil.IsNotifications(ctx) {
		return nil
	}
	osas, err := exec.LookPath("osascript")
	if err != nil {
		return err
	}

	return exec.Command(
		osas,
		"-e",
		`display notification "`+msg+`" with title "`+subj+`"`,
	).Start()
}
475893
func Notify(appName string, title string, text string, iconPath string) {
	notification(appName, title, text, iconPath)
}
725044
func NotificationHandlers(ntfn rpcclient.NotificationHandlers) RescanOption {
	return func(ro *rescanOptions) {
		ro.ntfn = ntfn
	}
}
478379
func (a *API) DeleteNotification(user int, notification *Notification) error {
	url := a.BuildURL("/v2/user/%d/notification/%d", user, notification.Id)
	return a.Delete(url, Params{})
}