~jshsj/gise_reminder_server

6026ae3b33fcbdc731a5e3dcbc6499a85359e3b5 — JSH 1 year, 7 months ago e43a5ed
changed notification on free days and fixed cron task
2 files changed, 12 insertions(+), 17 deletions(-)

M gise_reminder
M main.go
M gise_reminder => gise_reminder +0 -0

M main.go => main.go +12 -17
@@ 37,6 37,7 @@ type ReminderResponse struct {

func main() {
	initNotificationTimer()
	//handleNotification()
	router := chi.NewRouter()
	cors := cors.New(cors.Options{
		// AllowedOrigins: []string{"https://foo.com"}, // Use this to allow specific origin hosts


@@ 118,22 119,22 @@ func initNotificationTimer() {

func handleNotification() {
	fmt.Println("checking for notification")
	content := "Heute hast du frei!"
	headings := "Juchuuu!"
	if isItTimeToday() {
		runRequestToOnesigal()
		content = "Heute musst du dich spritzen."
		headings = "Spritzalarm!"
	}
}

func runRequestToOnesigal() {
	var jsonStr = []byte(`{
	var jsonStr = []byte(fmt.Sprintf(`{
		"app_id": "bb39087a-9bb9-488a-8aee-a18f2a6311f7",
  		"included_segments": ["All"],
		"large-icon": "icon",
		"small-icon": "icon",
		"android_led_color": "FF00CCCC",
		"android_accent_color": "FF00CCCC",
		"contents": {"en": "Heute musst du dich spritzen."},
		"headings": {"en": "Spritzalarm!" }
		}`)
		"contents": {"en": "%s"},
		"headings": {"en": "%s" }
		}`, content, headings))
	req, err := http.NewRequest("POST", "https://onesignal.com/api/v1/notifications", bytes.NewBuffer(jsonStr))

	if err != nil {


@@ 145,15 146,9 @@ func runRequestToOnesigal() {

	client := &http.Client{}
	client.Do(req)
	// resp, err := client.Do(req)
	// if err != nil {
	// 	fmt.Println(err)
	// }
	// defer resp.Body.Close()

	// body, _ := ioutil.ReadAll(resp.Body)
	// s := string(body[:])
	// fmt.Println(s)
}

func runRequestToOnesigal() {

}