feat(invite_users_to_channel): skip users already in the channel (supersedes #1)#2
Open
VincentGuyader wants to merge 1 commit intomasterfrom
Open
feat(invite_users_to_channel): skip users already in the channel (supersedes #1)#2VincentGuyader wants to merge 1 commit intomasterfrom
VincentGuyader wants to merge 1 commit intomasterfrom
Conversation
Adds get_users_in_channel() (wraps Slack's conversations.members endpoint) and uses its result alongside current_user in the setdiff that builds the invite list, so calling invite_users_to_channel() twice with the same audience no longer: - emits a Slack 'already_in_channel' error, - re-sends a join notification to people who are already there. When the resulting invite list is empty, the function short-circuits with a message and a no-op. The httr::POST stays as a single call (no per-user loop). Also bootstraps a tests/testthat/ folder. Tests exercise both the new helper and the modified inviter via testthat::with_mocked_bindings() on httr::POST + slackr::slackr_users / slackr_channels / auth_test — no real Slack connection needed. Supersedes the never-merged PR #1, which had the right intent but was buggy (length(x > 0) instead of length(x) > 0) and 4 years stale on a heavily refactored function.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Supersedes #1, which had the right intent but was 4 years stale, in conflict with
master, and had a precedence bug (length(users_a_inviter > 0)instead oflength(users_a_inviter) > 0, so theelsebranch was never reached).get_users_in_channel()wraps Slack'sconversations.membersendpoint and is exported with roxygen.invite_users_to_channel()nowsetdiff()s its target list with bothcurrent_user(already there) and the channel's existing members, so a repeated invitation is a no-op + message rather than a noisyalready_in_channelfrom the API + a re-notification to existing members.tests/testthat/folder. Tests usetestthat::with_mocked_bindings()onhttr::POSTand on theslackr::*lookups, so the suite runs offline.Test plan
testthat::test_local(): 6 PASS / 0 FAIL.Closes #1