// writeNotification creates FSNotifications from paths for file
// write events.
334488
func writeNotification(file data.Path, finish bool) *keybase1.FSNotification {
	n := baseNotification(file, finish)
	if file.Tlf.Type() == tlf.Public {
		n.NotificationType = keybase1.FSNotificationType_SIGNING
	} else {
		n.NotificationType = keybase1.FSNotificationType_ENCRYPTING
	}
	return n
}
1111567
func (s *UpdateSubscriberInput) SetNotification(v *Notification) *UpdateSubscriberInput {
	s.Notification = v
	return s
}
221339
func (k *KeybaseServiceBase) NotifyPathUpdated(
	ctx context.Context, path string) error {
	// Reduce log spam by not repeating log lines for
	// notifications with the same filename.
	//
	// TODO: Only do this in debug mode.
	func() {
		k.lastNotificationFilenameLock.Lock()
		defer k.lastNotificationFilenameLock.Unlock()
		if path != k.lastPathUpdated {
			k.lastPathUpdated = path
			k.log.CDebugf(ctx, "Sending path updated notification for %s", path)
		}
	}()
	return k.kbfsClient.FSPathUpdate(ctx, path)
}
685948
func (pd *PagerDutyNotifier) Notify(messages Messages) bool {

	client := gopherduty.NewClient(pd.ServiceKey)

	if pd.MaxRetry != 0 {
		client.MaxRetry = pd.MaxRetry

		if pd.RetryBaseInterval != 0 {
			client.RetryBaseInterval = pd.RetryBaseInterval
		} else {
			client.RetryBaseInterval = defaultRetryBaseInterval
		}
	}

	result := true

	for _, message := range messages {
		incidentKey := message.Node
		if message.ServiceId != "" {
			incidentKey += ":" + message.ServiceId
		}
		incidentKey += ":" + message.CheckId
		subject := message.Node
		if message.Service != "" {
			subject += ":" + message.Service
		}
		if message.Check != "" {
			subject += ":" + message.Check
		}
		var response *gopherduty.PagerDutyResponse
		switch {
		case message.IsPassing():
			description := subject + " is now HEALTHY"
			response = client.Resolve(incidentKey, description, message)
		case message.IsWarning():
			description := subject + " is UNSTABLE"
			response = client.Trigger(incidentKey, description, pd.ClientName, pd.ClientUrl, message)
		case message.IsCritical():
			description := subject + " is CRITICAL"
			response = client.Trigger(incidentKey, description, pd.ClientName, pd.ClientUrl, message)
		}

		if response.HasErrors() {
			for _, err := range response.Errors {
				log.Printf("Error sending %s notification to pagerduty: %s\n", incidentKey, err)
			}
			result = false
		}
	}

	log.Println("PagerDuty notification complete")
	return result
}
695446
func NotifyOnChange(filename string, ops fsnotify.Op, cancel <-chan interface{}) (<-chan struct{}, error) {
	filename = filepath.Clean(filename)
	dir := filepath.Dir(filename)
	w, err := fsnotify.NewWatcher()
	if err != nil {
		return nil, err
	}
	if err := w.Add(dir); err != nil {
		return nil, err
	}
	outchan := make(chan struct{})
	go func() {
		defer w.Close()
		defer close(outchan)
		for {
			select {
			case e := <-w.Events:
				if filepath.Clean(e.Name) == filename && e.Op&ops != 0 {
					outchan <- struct{}{}
				}
			case <-w.Errors:
			case <-cancel:
				return
			}
		}
	}()
	return outchan, nil
}
339343
func (e *EventListener) Notify(event *ct.Event) {
	e.subMtx.RLock()
	defer e.subMtx.RUnlock()
	if subs, ok := e.subscribers[event.AppID]; ok {
		for sub := range subs {
			sub.Notify(event)
		}
	}
	if event.AppID != "" {
		// Ensure subscribers not filtering by app get the event
		if subs, ok := e.subscribers[""]; ok {
			for sub := range subs {
				sub.Notify(event)
			}
		}
	}
}
145568
func Notify(ctx context.Context, subj, msg string) error {
	if os.Getenv("GOPASS_NO_NOTIFY") != "" || !ctxutil.IsNotifications(ctx) {
		return nil
	}
	conn, err := dbus.SessionBus()
	if err != nil {
		return err
	}

	obj := conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
	call := obj.Call("org.freedesktop.Notifications.Notify", 0, "gopass", uint32(0), iconURI(), subj, msg, []string{}, map[string]dbus.Variant{}, int32(5000))
	if call.Err != nil {
		return err
	}

	return nil
}
807323
func (self *watcher) isWrite(event *fsnotify.Event) bool {
	// instead of MODIFY event, editors may only send CREATE.
	// so we need to capture write & create.
	if event.Op&fsnotify.Write == fsnotify.Write ||
		event.Op&fsnotify.Create == fsnotify.Create {
		return true
	}
	return false
}
664773
func (ref *Consumer) PrintNotification(note map[string][]int32) {
	for k, v := range note {
		fmt.Printf("  Topic: %s\n", k)
		fmt.Printf("    Partitions: %v\n", v)
	}
}
1102782
func (s *statusCodeWithoutCloseNotify) WriteHeader(status int) {
	s.status = status
	s.ResponseWriter.WriteHeader(status)
}
836493
func (client *Client) Notify(err interface{}, extra ...interface{}) (string, error) {
	extra = append([]interface{}{*client.context}, extra...)
	notice := newNotice(client.Config, newError(err, 2), extra...)
	for _, handler := range client.beforeNotifyHandlers {
		if err := handler(notice); err != nil {
			return "", err
		}
	}
	workerErr := client.worker.Push(func() error {
		if err := client.Config.Backend.Notify(Notices, notice); err != nil {
			return err
		}
		return nil
	})
	if workerErr != nil {
		client.Config.Logger.Printf("worker error: %v\n", workerErr)
		return "", workerErr
	}
	return notice.Token, nil
}
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()
}
970827
func (w *gzipResponseWriter) CloseNotify() <-chan bool {
	if cn, ok := w.ResponseWriter.(http.CloseNotifier); ok {
		return cn.CloseNotify()
	}
	panic(httpserver.NonCloseNotifierError{Underlying: w.ResponseWriter})
}
589768
func (s *UpdateJobInput) SetNotification(v *Notification) *UpdateJobInput {
	s.Notification = v
	return s
}
1317723
func (s *JobMetadata) SetNotification(v *Notification) *JobMetadata {
	s.Notification = v
	return s
}
160271
func (logNotifier *LogNotifier) Notify(alerts Messages) bool {

	logrus.Println("logging messages...")

	logDir := path.Dir(logNotifier.Path)
	err := os.MkdirAll(logDir, os.ModePerm)
	if err != nil {
		logrus.Error(fmt.Sprintf("unable to create directory for logfile: %v", err))
		return false
	}

	file, err := os.OpenFile(logNotifier.Path, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0666)
	if err != nil {
		logrus.Error(fmt.Sprintf("unable to write to logfile: %v", err))
		return false
	}

	logger := log.New(file, "[consul-notifier] ", log.LstdFlags)
	for _, alert := range alerts {
		logger.Printf("Node=%s, Service=%s, Check=%s, Status=%s\n", alert.Node, alert.Service, alert.Check, alert.Status)
	}
	logrus.Println("Notifications logged.")
	return true
}
460919
func (c *ConfigLocal) Notifier() Notifier {
	c.lock.RLock()
	defer c.lock.RUnlock()
	return c.notifier
}