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

MM-56501 Enable/disable automuting when a user connects/disconnects #479

Merged
merged 15 commits into from
Feb 20, 2024

Conversation

hmhealey
Copy link
Member

Summary

Continuing from #477, since automuting is enabled when a user is both connected and has their primary platform set to MS Teams, we need to also potentially enable or disable automuting when a user connects or disconnects from MS Teams.

Ticket Link

https://mattermost.atlassian.net/browse/MM-56501

@lieut-data lieut-data added this to the v1.8.0 milestone Jan 30, 2024
@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2024

Codecov Report

Attention: 21 lines in your changes are missing coverage. Please review.

Comparison is base (d85f24a) 41.43% compared to head (9a02045) 41.67%.
Report is 1 commits behind head on main.

❗ Current head 9a02045 differs from pull request most recent head 39fef97. Consider uploading reports for the commit 39fef97 to get more accurate results

Files Patch % Lines
server/automute_user_connect.go 65.21% 13 Missing and 3 partials ⚠️
server/automute_preferences.go 0.00% 3 Missing ⚠️
server/api.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #479      +/-   ##
==========================================
+ Coverage   41.43%   41.67%   +0.23%     
==========================================
  Files          23       24       +1     
  Lines        6436     6493      +57     
==========================================
+ Hits         2667     2706      +39     
- Misses       3536     3551      +15     
- Partials      233      236       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hmhealey hmhealey marked this pull request as ready for review February 8, 2024 22:28
@hmhealey hmhealey added the 2: Dev Review Requires review by a core committer label Feb 8, 2024
@lieut-data
Copy link
Member

@johndavidlugtu, this relates to the comment on the previous PR, but I'm wondering if we want to restrict this functionality only for connected users. Maybe this setting should work for all users regardless of connection status?

Copy link
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

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

Blocking only for feedback on enduser experience.

@hmhealey
Copy link
Member Author

If we were to make that change, then in other words, a non-connected user would be able to set their primary platform and have all their linked channels auto-muted.

There'd be a fair bit of this logic that would/could be rewritten then, but it would simplify some stuff since the multiple conditions for enabling automuting did make this rather complicated to reason about and make work

Copy link
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

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

This looks great, @hmhealey! Just a handful of comments, but nothing that requires a re-review from me.

@@ -472,6 +472,8 @@ func (a *API) oauthRedirectHandler(w http.ResponseWriter, r *http.Request) {

_, _ = w.Write([]byte(fmt.Sprintf("<html><body><h1>%s</h1><p>You can close this window.</p></body></html>", connectionMessage)))

_, _ = a.p.updateAutomutingOnUserConnect(mmUserID)
Copy link
Member

Choose a reason for hiding this comment

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

Can we log LogWarn any error that's returned here to avoid burying it?

Copy link
Member Author

Choose a reason for hiding this comment

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

This code is actually a bit misleading since we do log any errors inside updateAutomutingOnUserConnect. I wanted the method to log its own errors to keep the automute logic more self-contained, but I still wanted the method to return errors because that makes testing easier

server/automute.go Show resolved Hide resolved
server/automute_user_connect.go Outdated Show resolved Hide resolved

automuteEnabled, err := p.enableAutomute(userID)
if err != nil {
p.API.LogError(
Copy link
Member

Choose a reason for hiding this comment

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

We're about to start raising alerts to SRE for errors. Is this something that we think is human actionable? Or might this fail for other reasons that justifying just a LogWarn?

Alternatively, since we already return the error, can we skip the log altogether?

Copy link
Member Author

@hmhealey hmhealey Feb 14, 2024

Choose a reason for hiding this comment

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

Yeah, I can change them to LogWarn since they're not really human actionable as you said. (Edit: I'll also change this for the methods added in the previous part)

And returning vs logging is the opposite of my previous comment. I can change that if you think it's a good idea if you think it's better to log these in api.go to be a bit more idiomatic

server/automute_user_connect.go Outdated Show resolved Hide resolved
server/automute_user_connect.go Outdated Show resolved Hide resolved
server/automute_user_connect.go Show resolved Hide resolved
@johndavidlugtu
Copy link

Maybe this setting should work for all users regardless of connection status?

Good point @lieut-data . Correct in that receiving "unwanted" DM/GM notifications from Mattermost is dependent on the sender's connection status and not the recipient.

+1 on opening it up to non-connected users

cc: @hmhealey

@hmhealey hmhealey force-pushed the MM-56501_automute-part-2_user-connect-disconnect branch from f23088e to 9a02045 Compare February 16, 2024 20:18
@lieut-data lieut-data removed the request for review from johndavidlugtu February 20, 2024 19:26
@lieut-data lieut-data added the QA/Deferred Agreement with QA that these changes will be tested post-merge label Feb 20, 2024
@hmhealey hmhealey added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Feb 20, 2024
@hmhealey hmhealey merged commit 0328f50 into main Feb 20, 2024
7 checks passed
@hmhealey hmhealey deleted the MM-56501_automute-part-2_user-connect-disconnect branch February 20, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request QA/Deferred Agreement with QA that these changes will be tested post-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants