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

[MI-3082]: Fixed the issue 198 'Added the logic to refresh and store the token' #7

Merged
merged 8 commits into from
May 30, 2023

Conversation

Kshitij-Katiyar
Copy link
Collaborator

server/remote/msgraph/remote.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/remote/msgraph/remote.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
@@ -15,7 +15,7 @@ import (
)

type Remote interface {
MakeClient(context.Context, bot.Poster, store.Store, string, *oauth2.Token) Client
MakeClient(context.Context, *oauth2.Token, store.Store, string, func() bool, func(error)) Client

Choose a reason for hiding this comment

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

Ideally the remote package is not aware of the store package. We can pass in another closure here to avoid this.

Maybe it makes sense to group these 3 callbacks into a struct, like remote.UserTokenHelpers

server/store/user_store.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/remote/msgraph/find_meeting_times.go Outdated Show resolved Hide resolved
server/mscalendar/notification.go Outdated Show resolved Hide resolved
server/remote/msgraph/remote.go Outdated Show resolved Hide resolved
RefreshAndStoreToken: app.Store.RefreshAndStoreToken,
}

client := app.Remote.MakeClient(ctx, tok, mattermostUserID, app.Poster, tokenHelpers)

Choose a reason for hiding this comment

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

Should this be MakeUserClient instead?

Copy link
Collaborator Author

@Kshitij-Katiyar Kshitij-Katiyar May 22, 2023

Choose a reason for hiding this comment

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

@mickmister I guess this gets run during the Oauth, so I thought this won't need the refresh token part here.

Copy link

@mickmister mickmister May 22, 2023

Choose a reason for hiding this comment

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

so I thought this won't need the refresh token part here.

I would say that we should still call MakeUserClient, to differentiate that this is a client for a user, and not a superuser client

bot.Logger
mattermostUserID string
conf *config.Config
tokenHelpers *serializer.UserTokenHelpers

Choose a reason for hiding this comment

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

I'm not sure if serializier is the right package for UserTokenHelpers. It's only used in remote, and it's not ever serialized.

Copy link
Collaborator Author

@Kshitij-Katiyar Kshitij-Katiyar May 22, 2023

Choose a reason for hiding this comment

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

@mickmister I have moved this to the remote package

server/remote/msgraph/create_calendar.go Outdated Show resolved Hide resolved
server/store/user_store.go Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
server/serializer/user.go Outdated Show resolved Hide resolved
server/remote/msgraph/get_schedule_batched.go Outdated Show resolved Hide resolved
server/remote/msgraph/get_notification_data.go Outdated Show resolved Hide resolved
server/remote/msgraph/get_default_calendar_view.go Outdated Show resolved Hide resolved
server/remote/msgraph/get_default_calendar_view.go Outdated Show resolved Hide resolved
Copy link

@mickmister mickmister left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, just one remaining request to rename the functions UserTokenHelpers to match the names in the store. Approving preemptively for this.

Thanks @Kshitij-Katiyar

server/mscalendar/client.go Outdated Show resolved Hide resolved
server/remote/user.go Outdated Show resolved Hide resolved
server/remote/msgraph/remote.go Outdated Show resolved Hide resolved
server/store/user_store.go Outdated Show resolved Hide resolved
@Kshitij-Katiyar Kshitij-Katiyar merged commit 7d8af50 into MM-198 May 30, 2023
@Kshitij-Katiyar Kshitij-Katiyar deleted the MI-3082 branch May 30, 2023 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants