-
Notifications
You must be signed in to change notification settings - Fork 23
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-21688] Use dedicated bot account in Azure #32
Conversation
@mickmister, is this PR ready for review? I usually clone the repo to make checking some of the code easier to traverse and some of the methods don't exist. |
@jfrerich I should have marked the PR as draft since it is not properly building at the moment. The @levb I need to discuss with you how to expose this admin-checking functionality to the The |
@jfrerich I can comment out certain things that need to be restructured/added so it will properly compile, though the tests will still fail without the added functions. |
@jfrerich This PR is ready for review now |
return a.api.GetUserStatusesByIds(mattermostUserIDs) | ||
st, err := a.api.GetUserStatusesByIds(mattermostUserIDs) | ||
if err != nil { | ||
return nil, 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.
@levb If this function is implemented as just return a.api.GetUserStatusesByIds(mattermostUserIDs)
, a nil error will be treated as a non-nil value to the caller.
You and I talked once about handling model.AppError
and error
, specifically that an interface pointer to a (nil pointer to a concrete type) is not a nil interface pointer, but I don't understand why this needs to be here in this case, and not the other functions in this file.
Thanks @mickmister! I'll get on the review soon! |
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.
Just a couple nits/naming.
server/mscalendar/availability.go
Outdated
@@ -35,11 +35,25 @@ func (m *mscalendar) SyncStatusAll() (string, error) { | |||
return "", err | |||
} | |||
|
|||
mmIDs := userIndex.GetMattermostUserIDs() | |||
index := userIndex.GetMattermostUserIDs() |
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 s/index/allIDs/
server/mscalendar/availability.go
Outdated
@@ -35,11 +35,25 @@ func (m *mscalendar) SyncStatusAll() (string, error) { | |||
return "", err | |||
} | |||
|
|||
mmIDs := userIndex.GetMattermostUserIDs() | |||
index := userIndex.GetMattermostUserIDs() | |||
mmIDs := []string{} |
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 s/mmIDs/filteredIDs/
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, @mickmister! I have one question and a single suggestion on response wording to the user.
* reword user error strings * rename vars
index := userIndex.GetMattermostUserIDs() | ||
mmIDs := []string{} | ||
for _, id := range index { | ||
allIDs := userIndex.GetMattermostUserIDs() |
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.
only if you do another push anyway... a nit of a nit, but maybe inline userIndex.GetMattermostUserIDs()
and just use ids
for the return? :)
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.
changes requests have been addressed and questions I had have been explained. Approving and thanks for the awesome work, @mickmister
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.
Spoke with @mickmister about this change. I will test post merge.
Summary
We are using the
getSchedule
Graph API endpoint to fetch user availabilities, and using application-level permissions to do so. The request requires us to supply a user ID, so we need a dedicated user in Azure to reference.This PR allows the MM admin to connect the mscalendar bot to an account in Azure, using the
/mscalendar connect_bot
command.Ticket Link
https://mattermost.atlassian.net/browse/MM-21688
Additional Info
Before running
/mscalendar connect_bot
,/mscalendar availability
should fail, since we do not have a bot user to use for the user id.Todo:
mscalendar/oauth2.go
needs to have access toIsAuthorizedAdmin
so we can ensure only admins can connect the bot accountIsAuthorizedAdmin
is nowbot.IsUserAdmin
andPluginAPI.IsSysAdmin
. Shouldn't we want to union these two, since a sys admin should be treated as a plugin admin?fix
command/connect_test.go
andcommand/disconnect_test.go
once ^ has been resolvedoauth2_connect_test.go
andoauth2_complete_test.go
have been deleted, but there are some tests I have written to assert things pertaining to connecting the bot accountWrite README instructions for creating dedicated account in Azure
Fixes #24