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

[GH-89] Allow status change to support DND and Away #118

Merged
merged 7 commits into from
May 20, 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: 4 additions & 4 deletions server/mscalendar/availability.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (m *mscalendar) setUserStatuses(users []*store.User, calendarViews []*remot
func (m *mscalendar) setStatusFromCalendarView(user *store.User, currentStatus string, res *remote.ViewCalendarResponse) (string, error) {
events := filterBusyEvents(res.Events)
busyStatus := model.STATUS_DND
if user.Settings.ReceiveNotificationsWhileOnMeeting {
if user.Settings.ReceiveNotificationsDuringMeeting {
busyStatus = model.STATUS_AWAY
}

Expand All @@ -199,7 +199,7 @@ func (m *mscalendar) setStatusFromCalendarView(user *store.User, currentStatus s
}
message = "User is no longer busy in calendar. Set status to online."
} else {
message = "User is no longer busy in calendar, but is not set to busy. No status change."
message = fmt.Sprintf("User is no longer busy in calendar, but is not set to busy(%s). No status change.", busyStatus)
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking nit, I'm thinking there should be a space between "busy" and the busyStatus

Suggested change
message = fmt.Sprintf("User is no longer busy in calendar, but is not set to busy(%s). No status change.", busyStatus)
message = fmt.Sprintf("User is no longer busy in calendar, but is not set to busy (%s). No status change.", busyStatus)

}
err := m.Store.StoreUserActiveEvents(user.MattermostUserID, []string{})
if err != nil {
Expand Down Expand Up @@ -234,7 +234,7 @@ func (m *mscalendar) setStatusFromCalendarView(user *store.User, currentStatus s
if err != nil {
return "", err
}
return "User was free, but is now busy. Set status to busy.", nil
return fmt.Sprintf("User was free, but is now busy(%s). Set status to busy.", busyStatus), nil
}

newEventExists := false
Expand All @@ -261,7 +261,7 @@ func (m *mscalendar) setStatusFromCalendarView(user *store.User, currentStatus s
if err != nil {
return "", err
}
message = "User was free, but is now busy. Set status to busy."
message = fmt.Sprintf("User was free, but is now busy. Set status to busy(%s).", busyStatus)
} else {
message = "User is already busy. No status change."
}
Expand Down
4 changes: 2 additions & 2 deletions server/mscalendar/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func NewSettingsPanel(bot bot.Bot, panelStore settingspanel.PanelStore, settingS
settingStore,
))
settings = append(settings, settingspanel.NewBoolSetting(
store.ReceiveNotificationsWhileOnMeeting,
store.ReceiveNotificationsDuringMeetingID,
"Receive notifications while on meetings",
"Do you want to still receive Mattermost notifications while you are on a meeting?",
"Do you want to still receive Mattermost notifications while you are on a meeting?\nIf you want notifications, you will be set as \"Away\" during meetings. If not, you will be set as \"Do Not Disturb\".",
store.UpdateStatusSettingID,
settingStore,
))
Expand Down
2 changes: 1 addition & 1 deletion server/mscalendar/welcome_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (wf *welcomeFlow) makeSteps() {
}, &flow.SimpleStep{
Title: "Receive notifications while on meetings",
Message: "Do you want to receive notifications while you are on a meeting?",
PropertyName: store.ReceiveNotificationsWhileOnMeetingName,
PropertyName: store.ReceiveNotificationsDuringMeetingName,
TrueButtonMessage: "Yes - I would like to set my status to Away during meetings to continue receiving notifications.",
FalseButtonMessage: "No - I would like to set my status to Do Not Disturb during meetings to not receive notifications.",
mickmister marked this conversation as resolved.
Show resolved Hide resolved
TrueResponseMessage: "Great, your status will be set to Away.",
Expand Down
12 changes: 6 additions & 6 deletions server/store/flow_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package store
import "fmt"

const (
UpdateStatusPropertyName = "update_status"
GetConfirmationPropertyName = "get_confirmation"
ReceiveNotificationsWhileOnMeetingName = "receive_notifications"
SubscribePropertyName = "subscribe"
UpdateStatusPropertyName = "update_status"
GetConfirmationPropertyName = "get_confirmation"
ReceiveNotificationsDuringMeetingName = "receive_notifications"
SubscribePropertyName = "subscribe"
)

func (s *pluginStore) SetProperty(userID, propertyName string, value bool) error {
Expand All @@ -20,8 +20,8 @@ func (s *pluginStore) SetProperty(userID, propertyName string, value bool) error
user.Settings.UpdateStatus = value
case GetConfirmationPropertyName:
user.Settings.GetConfirmation = value
case ReceiveNotificationsWhileOnMeetingName:
user.Settings.ReceiveNotificationsWhileOnMeeting = value
case ReceiveNotificationsDuringMeetingName:
user.Settings.ReceiveNotificationsDuringMeeting = value
default:
return fmt.Errorf("property %s not found", propertyName)
}
Expand Down
18 changes: 9 additions & 9 deletions server/store/setting_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
)

const (
UpdateStatusSettingID = "update_status"
GetConfirmationSettingID = "get_confirmation"
ReceiveNotificationsWhileOnMeeting = "receive_notification"
ReceiveRemindersSettingID = "get_reminders"
DailySummarySettingID = "summary_setting"
UpdateStatusSettingID = "update_status"
GetConfirmationSettingID = "get_confirmation"
ReceiveNotificationsDuringMeetingID = "receive_notification"
ReceiveRemindersSettingID = "get_reminders"
DailySummarySettingID = "summary_setting"
)

func (s *pluginStore) SetSetting(userID, settingID string, value interface{}) error {
Expand All @@ -32,12 +32,12 @@ func (s *pluginStore) SetSetting(userID, settingID string, value interface{}) er
return fmt.Errorf("cannot read value %v for setting %s (expecting bool)", value, settingID)
}
user.Settings.GetConfirmation = storableValue
case ReceiveNotificationsWhileOnMeeting:
case ReceiveNotificationsDuringMeetingID:
storableValue, ok := value.(bool)
if !ok {
return fmt.Errorf("cannot read value %v for setting %s (expecting bool)", value, settingID)
}
user.Settings.ReceiveNotificationsWhileOnMeeting = storableValue
user.Settings.ReceiveNotificationsDuringMeeting = storableValue
case ReceiveRemindersSettingID:
storableValue, ok := value.(bool)
if !ok {
Expand Down Expand Up @@ -69,8 +69,8 @@ func (s *pluginStore) GetSetting(userID, settingID string) (interface{}, error)
return user.Settings.UpdateStatus, nil
case GetConfirmationSettingID:
return user.Settings.GetConfirmation, nil
case ReceiveNotificationsWhileOnMeeting:
return user.Settings.ReceiveNotificationsWhileOnMeeting, nil
case ReceiveNotificationsDuringMeetingID:
return user.Settings.ReceiveNotificationsDuringMeeting, nil
case ReceiveRemindersSettingID:
return user.Settings.ReceiveReminders, nil
case DailySummarySettingID:
Expand Down
10 changes: 5 additions & 5 deletions server/store/user_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ type User struct {
}

type Settings struct {
EventSubscriptionID string
UpdateStatus bool
GetConfirmation bool
ReceiveReminders bool
ReceiveNotificationsWhileOnMeeting bool
EventSubscriptionID string
UpdateStatus bool
GetConfirmation bool
ReceiveReminders bool
ReceiveNotificationsDuringMeeting bool
}

type WelcomeFlowStatus struct {
Expand Down