-
Notifications
You must be signed in to change notification settings - Fork 25
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
Login workflow #44
Login workflow #44
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@larkox Great job with the Welcomer patterns introduced.
My main blocker here is getting the mscalendar-specific Welcomer
code out of the utils
package. No issues found otherwise 👍
server/command/connect.go
Outdated
c.Config.PluginURL) | ||
out := "The bot just sent you a message with the instructions to connect." | ||
if err := c.MSCalendar.Welcome(c.Args.UserId); err != nil { | ||
out = "There has been a problem while trying to connect." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like two spaces got in there somehow
out = "There has been a problem while trying to connect." | |
out = "There has been a problem while trying to connect." |
server/command/connect.go
Outdated
config.ApplicationName, | ||
c.Config.PluginURL) | ||
out := "The bot just sent you a message with the instructions to connect." | ||
if err := c.MSCalendar.Welcome(c.Args.UserId); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're moving away from the if statements in this format, favoring:
err := c.MSCalendar.Welcome(c.Args.UserId)
if err != nil {
out = "There has been a problem while trying to connect."
}
server/utils/bot/welcomer.go
Outdated
Welcome(userID string) error | ||
AfterSuccessfullyConnect(userID, userLogin string) error | ||
AfterUpdateStatus(userID string, status bool) error | ||
AfterSetConfirmations(userID string, set bool) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The utils
package is more-or-less supposed to be plugin-agnostic. Maybe this code should go into the mscalendar
package since the sign-up flow is specific to this plugin. Then we can access the typed kvstore in the store
package, to store the WelcomePostID
.
Edit: Or it can go in a new package that has knowledge of the mscalendar
package.
…mscalendar and improve postID handling on the welcomer
… to get the status updated
Codecov Report
@@ Coverage Diff @@
## master #44 +/- ##
=======================================
Coverage 21.62% 21.62%
=======================================
Files 64 64
Lines 2418 2418
=======================================
Hits 523 523
Misses 1836 1836
Partials 59 59 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left initial feedback; can use a clarification on the stored states/transitions.
server/mscalendar/mscalendar.go
Outdated
@@ -18,6 +18,7 @@ type MSCalendar interface { | |||
EventResponder | |||
Subscriptions | |||
Users | |||
Welcome(userID string) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not Welcomer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(1/5) MSCalendar is not a welcomer, the bot in the dependencies is. But MSCalendar must know how to greet a new user, to be used on the commands, so that is why we expose that function on the interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno, I'd advocate composing the entire interface in. What's the harm? Polluting MSCalendar namespace?
server/mscalendar/welcomer.go
Outdated
AfterDisconnect(userID string) error | ||
} | ||
|
||
type MSCalendarBot struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest s/MSCalendarBot/welcomer/
or... what I think is really the idea here was to have a mscalendar.Bot
(implemented as type bot struct
) that implements all messaging, not just Welcome.
server/mscalendar/welcomer.go
Outdated
} | ||
|
||
func (bot *MSCalendarBot) AfterSuccessfullyConnect(userID, userLogin string) error { | ||
user, err := bot.Store.LoadUser(userID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in solar lottery I chose to pass in *User, etc and then Expand
- most of the time the caller should have the expanded entity values already, if not, create an ID-only entity, and it gets expanded to format the message. Ping me if you want an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the benefit and how to do it, but I think with the new shape of the program this is not necessary. Could you confirm?
@levb After our conversation yesterday, I could not stop thinking about making the flow more detached from the welcome logic, so I made a refactoring in this line. Now we can add any steps we want as long as they are Yes/No questions. With the current implementation, we declare our flow with its steps (an implementation of Flow interface) and our flowStore (an implementation of FlowStore). With that, Welcomer still handles the connection, but all the flow of Yes/No questions is handled by the Flow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @larkox! Just some suggestions and questions.
server/command/connect_test.go
Outdated
}, | ||
expectedOutput: "[Click here to link your Microsoft Calendar account.](http://localhost/oauth2/connect)", | ||
expectedError: "", | ||
expectedOutput: `Welcome to the Microsoft Calendar Bot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what this should be worded as, but I'm thinking that we should be welcoming them to the plugin
or the functionality
, instead of the bot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should review the consolidated messages with @aaronrothschild and @asaadmahmood - let's focus on making sure they're all "in one place"?
server/mscalendar/oauth2_test.go
Outdated
@@ -1,4 +1,4 @@ | |||
package mscalendar | |||
package mscalendar_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a confused question, but if it's a separate package, wouldn't ./test
be a better place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a workaround that Go has for cycles in the tests. Conceptually, it is still a test of mscalendar, but due to the import cycles, it cannot be part of mscalendar package. With this naming, the compiler consider this a separate package, which solves the import cycles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^^ seems fishy to me, we should be well-clear of cyclical dependencies. I'm ok with the PR as is, but would like to understand this better, offline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved by creating the mock of the welcomer in a different package.
server/utils/bot/flower.go
Outdated
} | ||
|
||
func (bot *bot) setFlowStep(userID string, step int) error { | ||
// TODO: Use KVStore for HA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this will be covered in this PR? I'd be fine with deferring to a ticket if you want to get this merged sooner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My plan is to have this covered in this PR, but I wanted to confirm first that the new shape of the flow was interesting. I will take a look to have this done tomorrow.
server/command/connect_test.go
Outdated
}, | ||
expectedOutput: "[Click here to link your Microsoft Calendar account.](http://localhost/oauth2/connect)", | ||
expectedError: "", | ||
expectedOutput: `Welcome to the Microsoft Calendar Bot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should review the consolidated messages with @aaronrothschild and @asaadmahmood - let's focus on making sure they're all "in one place"?
server/mscalendar/mscalendar.go
Outdated
@@ -18,6 +18,7 @@ type MSCalendar interface { | |||
EventResponder | |||
Subscriptions | |||
Users | |||
Welcome(userID string) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno, I'd advocate composing the entire interface in. What's the harm? Polluting MSCalendar namespace?
server/mscalendar/oauth2_test.go
Outdated
@@ -1,4 +1,4 @@ | |||
package mscalendar | |||
package mscalendar_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a confused question, but if it's a separate package, wouldn't ./test
be a better place?
server/utils/flow/flow.go
Outdated
} | ||
} | ||
|
||
func (s *step) PostSA(flowHandler string, i int) *model.SlackAttachment { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's verbose, but 2/5 SlackAttachment
please... (grep-ability)
sh.panel.Set(mattermostUserID, idString, value) | ||
err := sh.panel.Set(mattermostUserID, idString, value) | ||
if err != nil { | ||
utils.SlackAttachmentError(w, "Error: cannot set the property, "+err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these errors get shown in the UI? It seems a bit low-level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, these would get shown in the UI. My idea is the error to be meaningful to debug, but we could move the internals of the error to a log in the server. Nevertheless, that would imply passing a logger to the handler, which will make things a bit dirtier.
@larkox I have done a test run through this now. Just a couple points.
|
|
@larkox sorry, I'm not following. Where does the double message show up? |
@aaronrothschild |
@DHaussermann |
@aaronrothschild I just discovered that slash commands can redirect the user to a different URL. What do you think about I type |
@DHaussermann Not sure what is happening with the CI, but this latest commit should fix also 2, so feel free to give it another round whenever you have the time. |
@larkox Thanks for the fixes! 1., 2. and 3. are resolved. This may be ready to merge
Just a couple points:
|
|
I've tested this as well with no issues found. Though I agree with Dylan's comment in our conversation on MM to make it so the user can change their mind within thr settings panel about whether or not they should receive event invitations.
Dylan and I have talked about stale data from different PRs affecting each other. I think it's important to document the behaviors so as to be on the lookout for them when testing master. This can be done with a follow up ticket. No reason to increase scope, thoughts @larkox? Things like connecting to two different Microsoft accounts with one MM account (disconnecting in between them) may cause these sorts of things too. Things that we wouldn't directly design for. I'm not saying that caused this issue, just unexpected user actions like that may get the account in a weird state.
I can confirm this is implemented and working correctly. In fact, when running on localhost, it redirects me to my ngrok instance's bot DM channel. This initially caught me off guard, but it ensures I am logged into the necessary domain before connecting. LGTM 👍 @aaronrothschild We will need your blessing here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and passed.
- I will create an issue with as much detail as possible if I see this occur on master.
- Yes sorry for being unclear on this I also see the bot DM redirect happening as expected.
Thanks for all the effort on this @larkox and thanks to @mickmister for helping with some peer testing.
@aaronrothschild I will created a follow-up issue to add the subscription question to the settings panel. (#103)
LGTM!
Sweet! |
/update-branch |
Summary
Added a first approach to the login workflow defined here. The current solution is far from optimal, but allows us to get a better understanding of the different moving parts of the solution.
I will keep working to improve the different parts, both in how to present the data, and the underlying architecture. Here is the current look of a full login process.