Ejemplo n.º 1
0
func GetNotifications(w rest.ResponseWriter, r *rest.Request) {
	if UITEST {
		GetNotificationsUITest(w, r)
		return
	}

	var notifications []Notification
	conf := clientconfig.Get()
	// if setup is not done it is the only notification
	if !conf.Settings.Local.UserSetup() {
		notifications = append(notifications, Notification{
			Level:   "info",
			Title:   "setup_required_title",
			Message: "setup_required_firstrun_message",
			Actions: []NotificationAction{
				{"action_continue", "/setup-guide/"},
			},
		})
		notifications = prepareNotifications(notifications)
		w.WriteJson(notifications)
		return
	}
	// put the global status of alkasir first
	if service.TransportOk() {
		notifications = append(notifications, Notification{
			Level:   "success",
			Title:   "status_title",
			Message: "status_ok_message",
		})

		notifications = append(notifications, Notification{
			Level:   "info",
			Title:   "suggest_this_title",
			Message: "suggest_this_message",
			Actions: []NotificationAction{
				{"action_continue", "/suggestions/"},
				{"action_help", "/docs/__/report-url"},
			},
		})

	}

	if !service.TransportOk() {
		notifications = append(notifications, Notification{
			Level:   "danger",
			Title:   "status_title",
			Message: "transport_error_message",
			Actions: []NotificationAction{
				{"action_help", "/docs/__/index"},
			},
		})
	}

	notifications = prepareNotifications(notifications)
	w.WriteJson(notifications)
}
Ejemplo n.º 2
0
// JSON api function
func GetStatusSummary(w rest.ResponseWriter, r *rest.Request) {
	conf := clientconfig.Get()
	summary := &StatusSummary{
		AlkasirVersion:      VERSION,
		CountryCode:         conf.Settings.Local.CountryCode,
		TransportOk:         service.TransportOk(),
		LastBlocklistChange: lastBlocklistChange,
		BrowserOk:           true,
		CentralOk:           true,
	}

	w.WriteJson(summary)
	return
}