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

Include extra metadata when clicking an interactive button #12697

Merged
merged 6 commits into from
Oct 30, 2019
Merged

Include extra metadata when clicking an interactive button #12697

merged 6 commits into from
Oct 30, 2019

Conversation

rfoyard
Copy link
Contributor

@rfoyard rfoyard commented Oct 9, 2019

Summary

Includes user_name, team_domain and channel_name when clicking an interactive button.

Ticket Link

JIRA: MM-10164
Fixes #12377

@rfoyard rfoyard marked this pull request as ready for review October 9, 2019 13:28
@jasonblais jasonblais added the 1: PM Review Requires review by a product manager label Oct 10, 2019
Copy link
Contributor

@aaronrothschild aaronrothschild left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks @rfoyard for your contribution. This is certainly helpful when developing interactive apps!

@aaronrothschild aaronrothschild removed the 1: PM Review Requires review by a product manager label Oct 10, 2019
@hanzei hanzei added 2: Dev Review Requires review by a developer 3: QA Review Requires review by a QA tester. May occur at the same time as Dev Review labels Oct 15, 2019
@hanzei hanzei requested review from lieut-data and hanzei and removed request for lieut-data October 15, 2019 09:49
@hanzei hanzei added this to the v5.18.0 milestone Oct 15, 2019
Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @rfoyard. I think we can improve a bit on the performance side of the code. In general it looks good 👍

model/integration_action.go Outdated Show resolved Hide resolved
@@ -69,13 +69,6 @@ func (a *App) DoPostActionWithCookie(postId, actionId, userId, selectedOption st
close(pchan)
}()

cchan := make(chan store.StoreResult, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

This code was here to make the db requests asynchronous and improve performance. I would like to keep it here, or is there a reason not to?

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 requests the channel from the postId but when the post does not exist, it's useless.
It was not a problem before, but as I need the channel to get the teamId, I would have to make another synchronous request when the post does not exist (to get the channel from the cookie's channelId line 85).
With this change I'm doing only one request to get the channel but if you prefer, I can change it and do another request just when using the cookie.
Just let me know.

Copy link
Contributor

Choose a reason for hiding this comment

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

The usual case is the the cookie is not set and we jump into the else case of L94. Hence, It don't see a problem with just making the request even though we might not need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I didn't know this was the usual case but with this in mind, I'll rework the PR. Thanks

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 changed the requests flow in 1b85d42, just let me know what you think.

app/integration_action.go Outdated Show resolved Hide resolved
app/integration_action.go Outdated Show resolved Hide resolved
Renamed TeamDomain to TeamName.
Copy link
Member

@saturninoabril saturninoabril left a comment

Choose a reason for hiding this comment

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

Tested and looks good to me.

@saturninoabril saturninoabril added QA/Review Done QA review is completed but other reviews are outstanding (exception to usual process) and removed 3: QA Review Requires review by a QA tester. May occur at the same time as Dev Review labels Oct 29, 2019
@hanzei hanzei self-requested a review October 29, 2019 21:49
Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

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

@hanzei hanzei requested a review from levb October 30, 2019 12:35
Copy link
Contributor

@levb levb left a comment

Choose a reason for hiding this comment

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

Just one small nit, otherwise LGTM. Thanks for parsing through that complex function!

@hanzei @crspeller This PR reminds me of my earlier proposal to eliminate the dependency on the database, and always use the "cookie" for the action metadata. Thoughts?

app/integration_action.go Outdated Show resolved Hide resolved
app/integration_action.go Outdated Show resolved Hide resolved
@hanzei
Copy link
Contributor

hanzei commented Oct 30, 2019

@hanzei @crspeller This PR reminds me of my earlier proposal to eliminate the dependency on the database, and always use the "cookie" for the action metadata. Thoughts?

3/5 that we want this. Performance is key with post actions.

Does this need client side changes?

@levb
Copy link
Contributor

levb commented Oct 30, 2019

@hanzei I believe that all of the client code is in place, we should check what minimum client versions support cookies (including the RN fixes). Let's take this conversation (switching to cookies 100%) out of this ticket though, I'll log a Jira issue for Toolkit to triage.

@hanzei hanzei requested review from hanzei and levb October 30, 2019 16:16
Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

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

Thanks for digging into this 👍

app/integration_action.go Outdated Show resolved Hide resolved
@levb
Copy link
Contributor

levb commented Oct 30, 2019

(waiting for the tests)

@levb levb added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a developer labels Oct 30, 2019
@levb levb merged commit 4111ffd into mattermost:master Oct 30, 2019
@rfoyard rfoyard deleted the MM-10164 branch October 30, 2019 17:46
@rfoyard
Copy link
Contributor Author

rfoyard commented Oct 30, 2019

Thanks everybody

@hanzei
Copy link
Contributor

hanzei commented Nov 1, 2019

Hey @rfoyard,

Would you be interested in adding an example usage of this functionality to the demo plugin? This would greatly help with testing this.

@rfoyard
Copy link
Contributor Author

rfoyard commented Nov 1, 2019

Hey @hanzei, sure, I'll take a look at it next week.

jozuenoon pushed a commit to jozuenoon/mattermost-server that referenced this pull request Nov 2, 2019
* master: (70 commits)
  Run unused against codebase (mattermost#12968)
  [MM-12623] Create CLI command "config reset" (mattermost#10296)
  Migrate tests from store/storetest/status_store.go to use test… (mattermost#12873)
  Fix golangci-lint target (mattermost#12985)
  [MM-16437] Plugin crashes the server when calling WriteHeader with an invalid http code (mattermost#11276)
  MM-18060: Include deleted posts in compliance export. (mattermost#12957)
  [MM-18331] When patching a bot send websocket notification (mattermost#12373)
  [MM-19473] Fix data race on user login (mattermost#12870)
  license, openGraph tests: convert to testify (mattermost#12919)
  oauth_test: use testify (mattermost#12949)
  [MM-18830] Unhelpful error message when adding bot to a channel before adding to team (mattermost#12844)
  emoji_test: update to use testify (mattermost#12932)
  MM-19310 - Wrong validation message when Bot name ends in a . (mattermost#12905)
  Migrate tests from store/storetest/oauth_store.go to use testify (mattermost#12875)
  Include extra metadata when clicking an interactive button (mattermost#12697)
  MM-19553: Generate valid passwords on bulk import. (mattermost#12871)
  Convert api4/webhook_test.go t.Fatal calls into require/assert calls (mattermost#12904)
  Fix golangci-lint target for non GOPATH installations (mattermost#12934)
  MM-17888 Check plugin Helpers minimum server version comments (mattermost#12663)
  [MM-18898] Stringify plugin.Log* parameters (mattermost#12700)
  ...
@rfoyard
Copy link
Contributor Author

rfoyard commented Nov 4, 2019

@hanzei I created a draft PR in the demo plugin.
It creates a new /interactive command with an Interactive Button.
When clicked, a new post is created displaying the JSON generated by the request (user_id, user_name, channel_id, channel_name, team_id, team_domain, ...).
Do you need something more specific ?

@hanzei
Copy link
Contributor

hanzei commented Nov 4, 2019

That's totally fine. 👍 I will review your PR soon.

@hanzei hanzei added the Demo Plugin Changes/Done Required changes to the demo plugin have been submitted label Nov 14, 2019
@amyblais amyblais added Changelog/Done Required changelog entry has been written Docs/Needed Requires documentation labels Nov 18, 2019
@aaronrothschild aaronrothschild removed their assignment Feb 13, 2020
@aaronrothschild aaronrothschild removed the Docs/Needed Requires documentation label Feb 13, 2020
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 Changelog/Done Required changelog entry has been written Demo Plugin Changes/Done Required changes to the demo plugin have been submitted Hacktoberfest QA/Review Done QA review is completed but other reviews are outstanding (exception to usual process)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include extra metadata when clicking an interactive button
7 participants