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

prefer logging user ids over emails #338

Merged
merged 3 commits into from
Oct 13, 2023
Merged

Conversation

lieut-data
Copy link
Member

Summary

Prefer logging user ids over emails. For now, we follow the existing convention of naming the fields TeamsUserID and MMUserID.

Ticket Link

None.

@lieut-data lieut-data added the 2: Dev Review Requires review by a core committer label Oct 9, 2023
@@ -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)
Copy link
Member Author

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())
Copy link
Member

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?

Copy link
Member Author

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())
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed!

Copy link
Member

@jespino jespino left a 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.

Copy link
Member

@jespino jespino left a comment

Choose a reason for hiding this comment

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

Now LGTM. Thanks!

@manojmalik20 manojmalik20 merged commit b8a24ab into main Oct 13, 2023
1 check passed
@manojmalik20 manojmalik20 deleted the improve-user-id-logging branch October 13, 2023 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core committer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants