-
Notifications
You must be signed in to change notification settings - Fork 24
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
Refactor calendar engine into its own package #267
Conversation
…tion gcal methods
@fmartingr I've reopened this on a Mattermost-owned branch. Also notice that the base branch is |
@@ -91,6 +92,8 @@ func newTestNotification(clientState string, recommendRenew bool) *remote.Notifi | |||
} | |||
|
|||
func TestProcessNotification(t *testing.T) { | |||
t.Skip("TODO gcal implement TestProcessNotification") |
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.
Test needs to be updated
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #267 +/- ##
==========================================
- Coverage 23.71% 20.94% -2.77%
==========================================
Files 62 67 +5
Lines 3087 3442 +355
==========================================
- Hits 732 721 -11
- Misses 2274 2628 +354
- Partials 81 93 +12 ☔ View full report in Codecov by Sentry. |
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.
@fmartingr I gave the plugin a review, and noted some things within this commit d78381a. Note that the commit itself is the review. Please take a look and share any thoughts you might have.
I added some PR review comments on top of the commit, to gather info that is provider-specific. The goal is to put them all in one struct. I plan to search for these strings in the code to find more:
- microsoft
- msgraph
- mscalender
- mscal
- gcal
I think the notification subscription lifecycle is the one thing that seems murky with regards to remaining work to handle both providers. I need to better understand gcal's subscription lifecycle to connect the dots on the code related to subscriptions.
server/command/info.go
Outdated
// REVIEW: hardcoded "microsoft" | ||
func (c *Command) info(parameters ...string) (string, bool, error) { | ||
resp := fmt.Sprintf("Mattermost Microsoft Calendar plugin version: %s, "+ | ||
"[%s](https://github.com/mattermost/%s/commit/%s), built %s\n", |
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.
config: plugin name
server/config/const.go
Outdated
// REVIEW: need an interface for returning bot info | ||
// probably good to have a struct to capture the data clump | ||
const ( | ||
BotUserName = "gcal" | ||
BotDisplayName = "Google Calendar" |
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.
all fields being used here, that should be put into a struct
BotUserName = "gcal"
BotDisplayName = "Google Calendar"
BotDescription = "Created by the Google Calendar Plugin."
ApplicationName = "Google Calendar"
Repository = "mattermost-plugin-gcal"
CommandTrigger = "gcal"
TelemetryShortName = "gcal"
// REVIEW: notification subscription logic in notification settings. this seems a bit weird. what does this function/block have to do specifically with notifications? | ||
_, err := cal.LoadMyEventSubscription() | ||
if err != nil { |
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.
Not really sure what's going on here. It seems like:
"If a setting is a boolean, create an event subscription if not exists"
This is notificationSetting.Set
, so I suppose this is "I want to change notification settings". what do we do when the value hasn't changed? I suppose this function takes care of no-ops
server/mscalendar/subscription.go
Outdated
@@ -21,6 +21,7 @@ type Subscriptions interface { | |||
LoadMyEventSubscription() (*store.Subscription, error) | |||
} | |||
|
|||
// REVIEW: depends on the overlap of subscription logic between providers, but lots of logic about supscription lifecycle in this file |
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.
Need to figure out if google's subscription lifecycle lines up with this
server/mscalendar/welcomer.go
Outdated
// REVIEW: "microsoft" referenced here | ||
WelcomeMessage = `Welcome to the Microsoft Calendar plugin. | ||
[Click here to link your account.](%s/oauth2/connect)` |
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.
"Microsoft Calendar plugin" mentioned here
server/mscalendar/welcomer.go
Outdated
// REVIEW: "microsoft" referenced here | ||
text := ":tada: Congratulations! Your microsoft account (*" + userLogin + "*) has been connected to Mattermost." | ||
return &model.SlackAttachment{ |
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.
"Microsoft" mentioned here
server/plugin/plugin.go
Outdated
// REVIEW: need to make this provider agnostic terminology | ||
mscalendarBot := mscalendar.NewMSCalendarBot(e.bot, e.Env, pluginURL) |
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.
mscalendar terminology leaked into plugin
package. not much else than what's visible here though
@@ -28,6 +28,7 @@ func (oa *oa) oauth2Complete(w http.ResponseWriter, r *http.Request) { | |||
return | |||
} | |||
|
|||
// REVIEW "microsoft" is hardcoded |
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.
"Microsoft Calendar" is hardcoded
Follow ups:
|
assets/profile.png
Outdated
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.
This we should take care as well.
Using the Events.watch endpoint to create a channel, with a default TTL of 7 days, channel can be stopped using Channels.stop. |
* remote logic * allow datetimes without timezone * add calendar settings readonly scope to get tz * event conversion * scopes * revert datetime.time
…268) * plugin profile images * receive provider flag * manifests * retrieve manifest id from file * Build time configuration * revert manifest * using go static configuration for providers * removed unused build flags * revert manifest * Added basic Google Calendar instructions * Update providers/GoogleCalendar.md Co-authored-by: Michael Kochell <[email protected]> * Update providers/GoogleCalendar.md Co-authored-by: Michael Kochell <[email protected]> * Update server/plugin/plugin.go Co-authored-by: Michael Kochell <[email protected]> * remoove log --------- Co-authored-by: Michael Kochell <[email protected]>
* user_store: more information fields on the index * feat: endpoint to autocomplete calendar connected users * revert test event store hashed * Update server/api/autocomplete.go Co-authored-by: Michael Kochell <[email protected]> * Update server/api/autocomplete.go Co-authored-by: Michael Kochell <[email protected]> * dont expose private data in endpoint * lint * Update server/store/user_store.go Co-authored-by: Michael Kochell <[email protected]> --------- Co-authored-by: Michael Kochell <[email protected]>
…276) * chore: replace provider display name * chore: replace command trigger references * revert previous changes
…ot supported (#272) * nil control * use subscriptions default ttl * return specific error when no superuser token can be used * notification formatting logic to other file * Client.GetEventsBetweenDates * typo: import * shorter command name :) * availability without super user token * delete store subs only if we successfuly do on remote * comment * ignore missing subs * update sync method * allow switching acting user on the fly * daily summary without super user token * formatted imports * calendar -> calendarEvents * processAllDailySummaryByUser -> processAllDailySummaryWithIndividualCredentials * revert silenced error under notifications * msgraph GetEventsBetweenDates * Update server/mscalendar/daily_summary.go Co-authored-by: Michael Kochell <[email protected]> * [GCAL] Create event logic (#269) * remote logic * allow datetimes without timezone * add calendar settings readonly scope to get tz * event conversion * scopes * revert datetime.time * Client.GetEventsBetweenDates * fix: store last post time * refactored availability logic * availability test * refactored daily summary logic * test: availability * daily summary tests (wip) * daily summary test * fix: merge duplications * slack attachment for notifications * lint and test * goimports * Update server/mscalendar/availability.go Co-authored-by: Michael Kochell <[email protected]> * remove logges * nullify client when changing acting user * move withActiveUser filter to fenced code outside of general method * tests: handling more scenarios * Fixed test after bugfix * fixed test assertions * allow engine copy to perform safe state mutations --------- Co-authored-by: Michael Kochell <[email protected]>
* Added encrypted kvstore * encrypt only oauth2 kv store * retrieve encryption setting from provider config * explicitly disable encrypted store for mscalendar * remove old comment
Tested this PR. 2 commands, namely Rest all are tested and approved from my side. |
Thanks so much @AayushChaudhary0001. All 3 of those commands are generally unimplemented and should be removed from the codebase |
Should I do that in a separate PR? |
@fmartingr Yeah that sounds good to me |
@fmartingr It seems this PR has been approved by QA. Should we merge this and move forward with a release of this plugin, and also update the gcal plugin's commit to the next tag once created? |
Absolutely! You take care of mscalendar and I take care of gcal? |
Solved conflicts from latest changes. |
@fmartingr Do you think this is good to merge based on QA's approval? |
Yeah, apart from QA we did some testing ourselves back in the day, so I think this is good to go. |
@fmartingr I need at least one dev's explicit approval on this to merge it. Can you please take a look and approve if it looks good? (which it does based on your comment) |
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.
Considering this passed through QA and the Google Calendar plugin works from this, I'm giving my approval, but if we need a proper 2nd dev review I would add someone else, since we are the authors of this PR so my approval seems like cheating.
@larkox Do you mind giving this a review? |
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.
Apart of the many "REVIEW" comments, everything seems fine. And I find this a great idea!
Are we planning on dealing with the review comments now or later?
Summary
This pull requests refactors the main calendar engine used by the mscalendar plugin and leverages the remotes implementation to allow other plugins to easily import this plugin providing its own remote to easily create other calendar plugins.
This work was done to create the mattermost-plugin-google-calendar that could be used as a template, with the caveheat that the google calendar plugin contains it's own frontend code to create events and that is currently not shared and it's a task to tackle in the future.