From 46aa1a3cad87215880e89bd7e4653aa082586d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Wed, 6 May 2020 10:53:18 +0200 Subject: [PATCH 1/2] Add "receive reminder" to login flow and minor flow refactoring --- server/mscalendar/welcome_flow.go | 8 ++++++ server/store/flow_store.go | 44 +++++++++---------------------- server/store/user_store.go | 6 ++--- 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/server/mscalendar/welcome_flow.go b/server/mscalendar/welcome_flow.go index 9fca9d4d..9ebcdf82 100644 --- a/server/mscalendar/welcome_flow.go +++ b/server/mscalendar/welcome_flow.go @@ -76,6 +76,14 @@ func (wf *welcomeFlow) makeSteps() { FalseButtonMessage: "No - Do not notify me of new events", TrueResponseMessage: "Great, you will receive a message any time you receive a new event.", FalseResponseMessage: "Great, you will not receive any notification on new events.", + }, &flow.SimpleStep{ + Title: "Receive reminder", + Message: "Do you want to receive reminder of upcoming events?", + PropertyName: store.ReceiveUpcomingEventReminderName, + TrueButtonMessage: "Yes - I would like to receive reminders for upcoming events", + FalseButtonMessage: "No - Do not notify me of upcoming events", + TrueResponseMessage: "Great, you will receive a message before your meetings.", + FalseResponseMessage: "Great, you will not receive any notification on upcoming events.", }, &flow.EmptyStep{ Title: "Daily Summary", Message: "Remember that you can set-up a daily summary by typing `/mscalendar summary time 8:00AM`.", diff --git a/server/store/flow_store.go b/server/store/flow_store.go index fd343fe9..3aa5eae0 100644 --- a/server/store/flow_store.go +++ b/server/store/flow_store.go @@ -3,9 +3,10 @@ package store import "fmt" const ( - UpdateStatusPropertyName = "update_status" - GetConfirmationPropertyName = "get_confirmation" - SubscribePropertyName = "subscribe" + UpdateStatusPropertyName = "update_status" + GetConfirmationPropertyName = "get_confirmation" + SubscribePropertyName = "subscribe" + ReceiveUpcomingEventReminderName = "receive_reminder" ) func (s *pluginStore) SetProperty(userID, propertyName string, value bool) error { @@ -19,6 +20,8 @@ func (s *pluginStore) SetProperty(userID, propertyName string, value bool) error user.Settings.UpdateStatus = value case GetConfirmationPropertyName: user.Settings.GetConfirmation = value + case ReceiveUpcomingEventReminderName: + user.Settings.ReceiveReminders = value default: return fmt.Errorf("property %s not found", propertyName) } @@ -37,17 +40,12 @@ func (s *pluginStore) SetPostID(userID, propertyName, postID string) error { return err } - switch propertyName { - case UpdateStatusPropertyName: - user.WelcomeFlowStatus.UpdateStatusPostID = postID - case GetConfirmationPropertyName: - user.WelcomeFlowStatus.GetConfirmationPostID = postID - case SubscribePropertyName: - user.WelcomeFlowStatus.SubscribePostID = postID - default: - return fmt.Errorf("property %s not found", propertyName) + if user.WelcomeFlowStatus.PostIDs == nil { + user.WelcomeFlowStatus.PostIDs = make(map[string]string) } + user.WelcomeFlowStatus.PostIDs[propertyName] = postID + err = s.StoreUser(user) if err != nil { return err @@ -62,16 +60,7 @@ func (s *pluginStore) GetPostID(userID, propertyName string) (string, error) { return "", err } - switch propertyName { - case UpdateStatusPropertyName: - return user.WelcomeFlowStatus.UpdateStatusPostID, nil - case GetConfirmationPropertyName: - return user.WelcomeFlowStatus.GetConfirmationPostID, nil - case SubscribePropertyName: - return user.WelcomeFlowStatus.SubscribePostID, nil - default: - return "", fmt.Errorf("property %s not found", propertyName) - } + return user.WelcomeFlowStatus.PostIDs[propertyName], nil } func (s *pluginStore) RemovePostID(userID, propertyName string) error { @@ -80,16 +69,7 @@ func (s *pluginStore) RemovePostID(userID, propertyName string) error { return err } - switch propertyName { - case UpdateStatusPropertyName: - user.WelcomeFlowStatus.UpdateStatusPostID = "" - case GetConfirmationPropertyName: - user.WelcomeFlowStatus.GetConfirmationPostID = "" - case SubscribePropertyName: - user.WelcomeFlowStatus.SubscribePostID = "" - default: - return fmt.Errorf("property %s not found", propertyName) - } + delete(user.WelcomeFlowStatus.PostIDs, propertyName) err = s.StoreUser(user) if err != nil { diff --git a/server/store/user_store.go b/server/store/user_store.go index 4d2548d3..e655bc66 100644 --- a/server/store/user_store.go +++ b/server/store/user_store.go @@ -51,10 +51,8 @@ type Settings struct { } type WelcomeFlowStatus struct { - UpdateStatusPostID string - GetConfirmationPostID string - SubscribePostID string - Step int + PostIDs map[string]string + Step int } func (settings Settings) String() string { From ac88d7791cb98b3eebd65453accea6363c4cc00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Fri, 8 May 2020 13:48:35 +0200 Subject: [PATCH 2/2] Improve texts --- server/mscalendar/welcome_flow.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/mscalendar/welcome_flow.go b/server/mscalendar/welcome_flow.go index 9ebcdf82..fc5af517 100644 --- a/server/mscalendar/welcome_flow.go +++ b/server/mscalendar/welcome_flow.go @@ -78,12 +78,12 @@ func (wf *welcomeFlow) makeSteps() { FalseResponseMessage: "Great, you will not receive any notification on new events.", }, &flow.SimpleStep{ Title: "Receive reminder", - Message: "Do you want to receive reminder of upcoming events?", + Message: "Do you want to receive a reminder for upcoming events?", PropertyName: store.ReceiveUpcomingEventReminderName, TrueButtonMessage: "Yes - I would like to receive reminders for upcoming events", FalseButtonMessage: "No - Do not notify me of upcoming events", TrueResponseMessage: "Great, you will receive a message before your meetings.", - FalseResponseMessage: "Great, you will not receive any notification on upcoming events.", + FalseResponseMessage: "Great, you will not receive any notification for upcoming events.", }, &flow.EmptyStep{ Title: "Daily Summary", Message: "Remember that you can set-up a daily summary by typing `/mscalendar summary time 8:00AM`.",