-
Notifications
You must be signed in to change notification settings - Fork 11
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
prefer logging user ids over emails #338
Conversation
@@ -339,7 +339,7 @@ func TestSyncUsers(t *testing.T) { | |||
{ | |||
Name: "SyncUsers: Unable to create the user", | |||
SetupAPI: func(api *plugintest.API) { | |||
api.On("LogError", "Unable to create new MM user during sync job", "email", "test@test.com", "error", mock.Anything).Times(1) | |||
api.On("LogError", "Unable to create new MM user during sync job", "MMUserID", mock.Anything, "TeamsUserID", mock.Anything, "error", mock.Anything).Times(1) |
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.
Note that these API assertions don't actually test anything since we never call api.AssertExpectations(t)
, but updated for completeness. (I can't add api.AssertExpectations(t)
without failing all the tests. Ideally, we transition these away from mocks altogether.)
server/plugin.go
Outdated
@@ -502,11 +502,11 @@ func (p *Plugin) syncUsers() { | |||
Value: "0", | |||
}} | |||
if prefErr := p.API.UpdatePreferencesForUser(newUser.Id, preferences); prefErr != nil { | |||
p.API.LogError("Unable to disable email notifications for new user", "MMUserID", newUser.Id, "error", prefErr.Error()) | |||
p.API.LogError("Unable to disable email notifications for new user", "MMUserID", mmUser.Id, "TeamsUserID", msUser.ID, "error", prefErr.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.
Is mmUser.Id
correct here?, should it be newUser.Id
?
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, you're right! I commented that the tests were broken to catch this and failed to do my own due diligence instead :)
server/plugin.go
Outdated
} | ||
|
||
if err = p.store.SetUserInfo(newUser.Id, msUser.ID, nil); err != nil { | ||
p.API.LogError("Unable to set user info during sync user job", "email", msUser.Mail, "error", err.Error()) | ||
p.API.LogError("Unable to set user info during sync user job", "MMUserID", mmUser.Id, "TeamsUserID", msUser.ID, "error", 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.
Same here, it shouldn't be newUser.Id
instead of mmUser.Id
?
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.
Fixed!
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 there is a couple of wrongly named variables. Other than that looks good to me.
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.
Now LGTM. Thanks!
Summary
Prefer logging user ids over emails. For now, we follow the existing convention of naming the fields
TeamsUserID
andMMUserID
.Ticket Link
None.