Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH87] Add "receive reminder" setting to login flow #117

Merged
merged 4 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions server/mscalendar/welcome_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ func (wf *welcomeFlow) makeSteps() {
FalseButtonMessage: "No - Do not notify me of new events",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not be in the scope of this PR, but I was thinking we should use the language "when you are invited to an event", instead of "when you receive a new event", in the prompts above this line, as it is clearer what we mean by "event".

Also, above we use the language "while you are on a meeting", versus "while you are in a meeting". Just some small improvements for wordings. @larkox Thoughts on this?

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?",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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`.",
Expand Down
44 changes: 12 additions & 32 deletions server/store/flow_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand All @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup here!

}

user.WelcomeFlowStatus.PostIDs[propertyName] = postID

err = s.StoreUser(user)
if err != nil {
return err
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions server/store/user_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down