-
Notifications
You must be signed in to change notification settings - Fork 69
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
GitHub Issue #170 - Update status when starting/ending a zoom meeting #171
Conversation
Hello @cvhariharan, Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here. |
@cvhariharan thanks for the contribution! Are you open to help review the build failure and let us know if you have any questions on how to resolve? |
Codecov Report
@@ Coverage Diff @@
## master #171 +/- ##
==========================================
- Coverage 20.85% 19.76% -1.09%
==========================================
Files 7 7
Lines 729 855 +126
==========================================
+ Hits 152 169 +17
- Misses 536 633 +97
- Partials 41 53 +12
Continue to review full report at Codecov.
|
Thanks @cvhariharan 🚀 |
@cvhariharan Thank you for the contribution. The current implementation seems nice, but I am not 100% sure about the use, because of edge cases. For example:
@aaronrothschild any thoughts on this? It is a similar problem as the one we had on Microsoft Calendar. Also, should we add a setting to set this on or off? |
Hi @larkox, to solve the first issue, could we do something like only update the status to dnd iff the status is online already or maybe save the old status before changing to dnd and reverting back when the meeting ends? For the second issue, I do agree that the status won't go back to online if the webhooks are not setup unless we have some background job that checks the meeting status. |
@cvhariharan To handle the "which status should we set the user back to" issue, we used the If the most recent status was manually set, meaning
If the most recent status was not manually set:
I think this can be put into a follow up ticket |
I think we should ask the user what they would like us to do the first time we are about to set their status to Away/Dnd. Frankly, you should probably just copy the behavior from the MS Calendar plugin that asks the user about their preference. Not sure how much scope that might add to this ticket (or not).
Agreed, hopefully most should have webhooks setup. The important aspect is that we tell the user that we've switched their status (add some text to the Zoom message saying it started the meeting AND "We've set your Mattermost status to "Away/Dnd"" |
From what I understand, for the first meeting that the user creates with this feature on, the plugin asks their preference on allowing automatic status updates. Their preference is persisted for future use. I will go through the MS Calendar plugin and try to see how I can replicate the behavior here. |
@cvhariharan What you want to use for prompting the user are Slack Attachments. You could try to use the experimental flow (or wizard, I plan to change the name eventually), but probably it is an overkill. You should also add a slash command to change this setting. Something simple as Finally, for the status change, you may want to check this PR: mattermost/mattermost-plugin-mscalendar#140 |
Thanks @larkox, I was beginning to experiment with slack attachments. The PR is also very helpful. I will see what I can do. |
Hello, from the previous discussions I have made the following changes
Let me know if something should be changed. 😄 |
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 general it looks good. Just some minor improvements.
@cvhariharan Could you also post screenshots with all possible outcomes so @aaronrothschild can check from a UX perspective the messages and look of the feature? |
Thanks for your work @cvhariharan , looking forward to checking this out! |
@cvhariharan Thanks for the screenshots! @abhijit-singh @levb or @hanzei thoughts on the "settings" as part of the Perhaps we should add a |
0/5 the idea is awesome, the UX needs some work - sorry late to the discussion. Either way, we can ship with the feature off by default while we work out the kinks of managing the setting. |
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
|
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.
From my side it looks good. Thanks for the contribution!
@cvhariharan Heads up that there is a merge conflict to resolve |
The merge conflicts are now resolved @hanzei. |
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 @cvhariharan! I just have some requests regarding error handling
@@ -19,6 +19,8 @@ const oAuthHelpText = `* |/zoom connect| - Connect to zoom | |||
|
|||
const alreadyConnectedString = "Already connected" | |||
|
|||
const statusHelpText = `* |/zoom status yes/no| - Change automatic status change setting, yes/no` |
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.
Can we describe what this means a bit here? Maybe something like "With this activated, your status will automatically change based on if you are in a meeting"
p.API.LogDebug("Could not save status change preference ", appErr) | ||
return "Could not save status preference", appErr | ||
} | ||
return "Status preference updated successfully", 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.
Can this message convey the fact of "Your status will be updated" or "Your status will not be updated"?
appErr := p.API.KVSet(key, []byte(changeStatus)) | ||
if appErr != nil { | ||
p.API.LogDebug("failed to set status change preference", "error", appErr.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.
I think we should return here instead of proceeding after the if statement. Maybe have this function return an error, and call this function with a smaller function that handles the error. Any error that occurs in this function should cause the function to return early.
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.
@mickmister Here if we don't return early, the next call is to setUserStatus which would automatically send another slack attachment for user confirmation on automatic status change. Won't that be more convenient?
Also, if I understand this correctly, you are suggesting we remove the KVSet
and setUserStatus
snippets and put it in a separate function and return early if that function throws any error?
err := p.setUserStatus(userID, int(meetingID), false) | ||
if appErr != nil { | ||
p.API.LogDebug("failed to change user status", "error", err) | ||
} |
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.
err := p.setUserStatus(userID, int(meetingID), false) | |
if appErr != nil { | |
p.API.LogDebug("failed to change user status", "error", err) | |
} | |
err := p.setUserStatus(userID, int(meetingID), false) | |
if err != nil { | |
p.API.LogDebug("failed to change user status", "error", err) | |
} |
@@ -283,12 +329,17 @@ func (p *Plugin) handleMeetingEnded(w http.ResponseWriter, r *http.Request, webh | |||
return | |||
} | |||
|
|||
err := p.setUserStatus(post.UserId, int(meetingID), true) | |||
if err != nil { | |||
p.API.LogDebug("failed to change user status", "error", err) |
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.
Can we return the error, and handle it on the caller's side? I think we will need to make a separate small function to do so.
statusVal, err := p.API.KVGet(statusKey) | ||
if err != nil { | ||
p.API.LogDebug("Could not get old status from KVStore", "err", appErr.Error()) | ||
return err | ||
} |
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.
statusVal, err := p.API.KVGet(statusKey) | |
if err != nil { | |
p.API.LogDebug("Could not get old status from KVStore", "err", appErr.Error()) | |
return err | |
} | |
statusVal, appErr := p.API.KVGet(statusKey) | |
if appErr != nil { | |
p.API.LogDebug("Could not get old status from KVStore", "err", appErr.Error()) | |
return appErr | |
} |
p.API.LogDebug("Create Attachment: ", appErr) | ||
return appErr |
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.
p.API.LogDebug("Create Attachment: ", appErr) | |
return appErr | |
return errors.Wrap(appErr, "Failed to create status change attachment post") |
p.API.LogDebug("Create Attachment: ", appErr) | ||
return appErr |
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.
p.API.LogDebug("Create Attachment: ", appErr) | |
return appErr | |
return errors.Wrap(appErr, "Failed to get bot DM channel") |
p.API.LogDebug("Failed to update user status", "err", appErr) | ||
return appErr |
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.
Can we use errors.Wrap
to decorate errors with relevant error messages in this function and have the parent log, instead of logging here?
if appErr != nil { | ||
p.API.LogDebug("Could not get stored status preference from KV ", appErr) | ||
} |
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.
Should we return 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.
Yes, we should.
@mickmister Hi, sorry I have been caught up with work, I will take a look into this over the weekend. |
No problem, thanks @cvhariharan 🙂 |
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
Hi @cvhariharan! Have you had a chance to address the PR feedback? Do you need any assistance? Thanks! |
Hi @jfrerich, I haven't been able to look into this yet. I have been caught up with work for sometime. I will get back to this as soon as possible. |
Hi @cvhariharan - I'm helping to review stale PRs and will be closing this one for now as it's been standing for 6 months. Please feel free to re-open it if you're able to prioritize the work :) I've re-added the "Up for Grabs" label on #170 //cc @larkox @mickmister |
Summary
This PR adds ability to the mattermost-zoom-plugin to automatically update the status of the user starting/ending a zoom meeting. When the meeting is started by a user, their status is set to DND and when they end the meeting, the status is set to ONLINE.
Ticket Link
Fixes #170