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

MM-15439 Restores 1.0 compatibility for webhook filtering #72

Merged
merged 8 commits into from
May 24, 2019
Merged

MM-15439 Restores 1.0 compatibility for webhook filtering #72

merged 8 commits into from
May 24, 2019

Conversation

levb
Copy link
Contributor

@levb levb commented May 23, 2019

Ticket:
https://mattermost.atlassian.net/browse/MM-15439

@levb levb added 1: PM Review Requires review by a product manager 2: Dev Review Requires review by a core committer labels May 23, 2019
@jasonblais
Copy link
Contributor

By default, only the events supported by 1.0 are shown (eventIssueCreated, eventIssueReopened, eventIssueResolved, eventUnresolvedIssueDeleted)

Does this mean the following events are supported, as listed in ticket

  • Issue created
  • Issue updated - issue assignee updated; issue transitioned (e.g. Reopened, In Progress, Resolved, Submitted)
  • Issue deleted
  • Comment created
  • Comment updated
  • Comment deleted

parsed.style = mdRootStyle
headline = fmt.Sprintf("created %v", issue)
parsed.details = parsed.mdIssueCreatedDetails()
parsed.text = parsed.mdIssueDescription()
case "jira:issue_deleted":
parsed.events = parsed.events | eventIssueDeleted
Copy link
Contributor Author

@levb levb May 23, 2019

Choose a reason for hiding this comment

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

See the 1.1.1 implementation

case "jira:issue_updated":
isResolutionChange := false
for _, change := range w.ChangeLog.Items {
if change.Field == "resolution" {
isResolutionChange = (change.FromString == "") != (change.ToString == "")
break
}
}
if !isResolutionChange {
return nil, nil
}

eventMax = iota
)

const maskLegacy = eventIssueCreated |
Copy link
Contributor Author

@levb levb May 23, 2019

Choose a reason for hiding this comment

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

see the 1.1.1 implementation

switch w.WebhookEvent {
case "jira:issue_created":
case "jira:issue_updated":
isResolutionChange := false
for _, change := range w.ChangeLog.Items {
if change.Field == "resolution" {
isResolutionChange = (change.FromString == "") != (change.ToString == "")
break
}
}
if !isResolutionChange {
return nil, nil
}
case "jira:issue_deleted":
if w.Issue.Fields.Resolution != nil {
return nil, nil
}
default:
return nil, nil
and
if change.Field == "resolution" {
if change.ToString == "" && change.FromString != "" {
verb = "reopened"
} else if change.ToString != "" && change.FromString == "" {
verb = "resolved"
}
break
}

server/utils.go Outdated Show resolved Hide resolved
server/webhook.go Show resolved Hide resolved
server/webhook.go Outdated Show resolved Hide resolved
server/webhook.go Show resolved Hide resolved
@crspeller crspeller added this to the v2.0 milestone May 23, 2019
@levb levb requested review from crspeller and jasonblais May 23, 2019 20:39
Copy link
Contributor

@jasonblais jasonblais left a comment

Choose a reason for hiding this comment

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

From reading the diff and our conversation, changes look correct. Will rely on QA to do final verification post-merge

@jasonblais jasonblais removed the 1: PM Review Requires review by a product manager label May 24, 2019
@levb
Copy link
Contributor Author

levb commented May 24, 2019

@crspeller @cpoile this is ready re-review

}

func getUserURL(issue *JIRAWebhookIssue, user *jira.User) string {
func getUserURL(user *jira.User) string {
// TODO is this right?
Copy link
Member

Choose a reason for hiding this comment

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

TODO? What's this about?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is not used in 2.0, and will likely be deprecated with @cpoile's implementation of /jira settings notify.

I can cut a separate PR and simply remove all "notify" functionality from v2.0 since it's not used. This function will disappear then.

@@ -192,43 +228,52 @@ func parse(in io.Reader, linkf func(w *JIRAWebhook) string) (*parsedJIRAWebhook,
issue := parsed.mdIssueType() + " " + linkf(parsed.JIRAWebhook)
switch parsed.WebhookEvent {
case "jira:issue_created":
parsed.event(eventCreated)
Copy link
Member

Choose a reason for hiding this comment

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

I like the encapsulation, maybe consider completely encapsulating the functionality of the bitset? Or to save time use a library like: https://github.com/willf/bitset

The other thing is there is a mix of concerns in this function. We are creating the bitset but also deriving a headline and other stuff. Maybe split this into multiple functions? Like createEventsBitset and createHeadline, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do a separate PR for 2.1 for this. I am inclined not to bring in an extra dependency for what I consider temporary feature flags. If exposing the bit-logic is not sufficiently intention-revealing, I'd rather just use a go map, it's not a material performance difference in the context.

Copy link
Member

Choose a reason for hiding this comment

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

Alright.

@levb levb requested a review from crspeller May 24, 2019 15:51
Copy link
Member

@cpoile cpoile left a comment

Choose a reason for hiding this comment

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

Nothing really to add, looks good to me.

@cpoile cpoile merged commit ee38bcb into mattermost:jira2 May 24, 2019
@cpoile cpoile added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels May 24, 2019
@jasonblais
Copy link
Contributor

@levb Please create tickets for any follow-up PRs for 2.0/2.1 if applicable, e.g. #72 (comment) and #72 (comment)

@levb levb deleted the lev-MM-15439-webhooks branch May 27, 2019 22:52
crspeller pushed a commit that referenced this pull request May 31, 2019
* MM-15439 Restores 1.0 compatibility for webhook filtering (#72)

* wip

* MM-15439: Restored webhook compatibility with 1.0

* Fixed the tests

* Fixed eventIssueDeleted->eventUresolvedIssueDeleted

* Added support for eventIssueAssigned to URL params

* PR feedback

* PR feedback: adjusted default event mask

* PR feedback from #72, minor

* Style: minor simplification, maskAll

* Refactored for testability

- Refactored webhook code, added tests
- Added separate interfaces (`UserStore`, `InstanceStore`, etc.) to KV methods
- Added store (kv) interface pointers to `type Plugin`
- Added POC mocks for some test stores (as needed)

* Added .code-workspace to .gitignore

* PR feedback: KV->Store, misc

* PR feedback: removed inner function

* PR feedback: clarify recursive URL-unescaping
levb added a commit that referenced this pull request Aug 10, 2020
* iterate through instances when printing out the channel subscriptions
update tests for new printing output format

don't require --intance for subscribelist

* Update tests

* shorten field name

* several PR feedback fixes

* remove unused variable
rename map variable

* Disconnect users on instance uninstall (#41)

* [GH-4] add EE license check (#22)

* restrict plugin activation based on license

* run go mod tidy -v

* wip

* add enterprise package

* rename license naming to enterprise
if user does not have enterprise license, check number of instances
  installed before allowed to install another cloud or server instance

* remove function

* fix review feedback

* Add license checking tests

* wip

* wip by Lev

* wip

* wip

* remove comments

* remove function to return pointer to true bool value

* getMockInstanceStoreKV(0) should return initialized empty store
was returning instance store with one instance
correct all occurences call of getMockInstanceStoreKV(0) to call with 1
instanance. This fixes many failing tests
Add tests for InstallInstance function with extensive license checking

* fix linting

Co-authored-by: Lev Brouk <[email protected]>

* Fixed #31, #33 (#54)

- Use plugin URL as the "home" for app links
- Added extra logging for suspicious callbacks
- Use templates for `/jira instance install` output

* Fix test (#64)

* GH-21 Fixed websocket update on user disconnect, instance uninstall (#61)

* Fixed websocket update on user disconnect

* Revert "Fixed websocket update on user disconnect"

This reverts commit 84ca4b27ca2a3ed55408bf359786b3162dc1b29a.

* Fixed empty set refresh, defaulting in commands

* fixed instance status update

* GH-49: Fixed webhook, transition commands (#67)

* Use connectInstances array for userConnected redux selector (#71)

* Use connectInstances array for userConnected redux selector

* add null check

* [GH-45] Make sure frontend has up-to-date default instance data (#65)

* fetch instances on modal open

* Fix errors regarding redux update and missing channelId prop

* Get instances when subscribe modal opens

* fix tests

* Handle case where default instance value in frontend is stale (uninstalled)

* Make if statement more safe

* Make if statement more safe

* fix test

* lint

* GH-60: Fixed multi-work command alias parsing in webapp (#72)

* Fixed --instance

Co-authored-by: Lev <[email protected]>
Co-authored-by: Lev Brouk <[email protected]>
Co-authored-by: Michael Kochell <[email protected]>
mickmister pushed a commit that referenced this pull request Feb 9, 2024
* [MI-3483] Added issue status field in subscription modal (#71)

* [MI-3483] Added the status field in subscription modal

* [MI-3483] Code refactoring

* [MI-3483] Fix testcases

* [MI-3483] Added error handling and code refactoring

* [MI-3483] Review fixes

* [MI-3483] Review fixes

* [MI-3483] Review fixes

* [MI-3597] Moved the issue status field into filters section of modal (#72)

* [MI-3597] Moved the issue status field into filters section of modal

* [MI-3597] FIxed a minor issue

* [MI-3597] Review fix

* [MI-3628] Updated the code to return the status details in the meta data API (#74)

* [MI-3628] Updated the code to return the status details in the meta data API instead of making a separate API call.

* [MI-3628] Review fixes: Small code optimization

* [MI-3690] Review fixes
- Added testcases for status field.
- Fixed issue: create meta info API not working for Jira server instance

* [MM-4] Review fixes: Fixed some variable names

* [MM-4] Updated the test data files and test cases

* [MM-71] Fix issue: status filter not working with issue created event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants