Skip to content

[GH-744] Add --include-only-org-members flag for channel subscriptions - #797

Merged
raghavaggarwal2308 merged 12 commits into
mattermost:masterfrom
burakcakirel:gh-744-support-include-only-org-members
Apr 8, 2025
Merged

raghavaggarwal2308 merged 12 commits into
mattermost:masterfrom
burakcakirel:gh-744-support-include-only-org-members

Conversation

@burakcakirel

Copy link
Copy Markdown
Contributor

Summary

This PR adds --include-only-org-members flag for channel subscriptions

Ticket Link

Fixes #744

@mattermost-build

Copy link
Copy Markdown
Contributor

Hello @burakcakirel,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

Per the Mattermost Contribution Guide, we need to add you to the list of approved contributors for the Mattermost project.

Please help complete the Mattermost contribution license agreement?
Once you have signed the CLA, please comment with /check-cla and confirm that the CLA check is green.

This is a standard procedure for many open source projects.

Please let us know if you have any questions.

We are very happy to have you join our growing community! If you're not yet a member, please consider joining our Contributors community channel to meet other contributors and discuss new opportunities with the core team.

…e-only-org-members

# Conflicts:
#	README.md
#	server/plugin/webhook.go

@mickmister mickmister left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this contribution @burakcakirel! I have just a few comments. LGTM 👍

Comment thread server/plugin/webhook.go Outdated
return p.isUserOrganizationMember(githubClient, user, organization)
}

func (p *Plugin) includeOnlyConfigOrgMembers(user *github.User, subscription *Subscription) bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (p *Plugin) includeOnlyConfigOrgMembers(user *github.User, subscription *Subscription) bool {
func (p *Plugin) shouldDenyEventDueToNotOrgMember(user *github.User, subscription *Subscription) bool {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done 👍 23c44b9

Flags: SubscriptionFlags{IncludeOnlyOrgMembers: true},
},
expectWarn: true,
want: false,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for these tests @burakcakirel 👍 Can we have one that tests the happy path of want: true?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've tried to test that case but couldn't because the code is unsuitable for testing. I couldn't mock the GetGitHubClient method. Then I've tried to write feature tests for this by mimicking the Jira Plugin tests but couldn't do it again because postIssueEvent method doesn't return anything like in Jira Plugin's PostToChannel method. Hence, this prevents to write a test for this method. Here is the gist file of the tests I've tried to achieve:
https://gist.github.com/burakcakirel/bf8c3da4b67893b70d9871e5032674ae#file-webhook_test-go-L170

Comment thread server/plugin/webhook.go Outdated
@mickmister mickmister added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Jul 4, 2024
@hanzei
hanzei removed their request for review July 5, 2024 05:12
@mattermost-build

Copy link
Copy Markdown
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@wiggin77

Copy link
Copy Markdown
Member

@raghavaggarwal2308 can this be QA'd before merge?

@mattermost-build

Copy link
Copy Markdown
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@arush-vashishtha

arush-vashishtha commented Nov 15, 2024 •

Copy link
Copy Markdown

@raghavaggarwal2308 can this be QA'd before merge?

Hii @burakcakirel @wiggin77 @raghavaggarwal2308 , I have tested this and the flag --include-only-org-members is not working and the user is getting the events triggered by non-member user for an organization.
cc @Kshitij-Katiyar

@wiggin77

Copy link
Copy Markdown
Member

@burakcakirel thank you for your submission. It looks like the --include-only-org-members is not passing our QA testing. Would you like to take a look?

@burakcakirel

Copy link
Copy Markdown
Contributor Author

Hey @wiggin77, it’s been a while since I worked on this, but let me take a look.

@mattermost-build

Copy link
Copy Markdown
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@raghavaggarwal2308

Copy link
Copy Markdown

@burakcakirel WIll you be able to work on it anytime soon?

@raghavaggarwal2308

Copy link
Copy Markdown

@burakcakirel Gentle reminder

@burakcakirel

Copy link
Copy Markdown
Contributor Author

Sorry, @raghavaggarwal2308, I don't have time for that these days.

@Kshitij-Katiyar
Kshitij-Katiyar changed the base branch from master to release_v2.1.3 March 7, 2025 12:16
@Kshitij-Katiyar
Kshitij-Katiyar changed the base branch from release_v2.1.3 to master March 7, 2025 12:16
@Kshitij-Katiyar

Copy link
Copy Markdown
Contributor

@wiggin77 @raghavaggarwal2308 Please review

@AayushChaudhary0001 AayushChaudhary0001 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR has been tested for the flag for --include-only-org-members for both the conditions true and false. The code changes are working fine, LGTM. Approved.

@Kshitij-Katiyar

Copy link
Copy Markdown
Contributor

Thanks @burakcakirel for your efforts

@raghavaggarwal2308 raghavaggarwal2308 removed the 3: QA Review Requires review by a QA tester label Mar 17, 2025
@raghavaggarwal2308

Copy link
Copy Markdown

@wiggin77 Can you please give this PR a review

@raghavaggarwal2308 raghavaggarwal2308 added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Mar 28, 2025
@mattermost-build

Copy link
Copy Markdown
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

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 Contributor Lifecycle/1:stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support --include-only-org-members for channel subscriptions

8 participants