Skip to content

Pretext per Workflow Case, Auto-Check for Private Channel, and Bug Fix#101

Open
jordan8037310 wants to merge 4 commits into
pantheon-systems:masterfrom
jordan8037310:slack-public-private-channels-and-pretext
Open

Pretext per Workflow Case, Auto-Check for Private Channel, and Bug Fix#101
jordan8037310 wants to merge 4 commits into
pantheon-systems:masterfrom
jordan8037310:slack-public-private-channels-and-pretext

Conversation

@jordan8037310
Copy link
Copy Markdown
Contributor

…orkflow case

* Automatically check to see if the channel is private (no # in channel name) and if so, don’t post to Slack with the username in the payload
@pantheon-mentionbot
Copy link
Copy Markdown

@jordan8037310, thanks for your PR! By analyzing the blame information on this pull request, we identified @greg-1-anderson and @joshkoenig to be potential reviewers

$post += array(
'channel' => $channel,
'icon_emoji' => ':lightning_cloud:',
'icon_emoji' => ':pantheon:',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this is (yet) a standard emoji. ;)

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.

Good point! We should probably convert this to a full url to a 128x128 Pantheon Emoji. Slack accepts full image urls for this field.

// Load our hidden credentials.
// See the README.md for instructions on storing secrets.
$secrets = _get_secrets(array('slack_url'), $defaults);
$secrets = _get_secrets(array('slack_url','slack_channel'), $defaults);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why store slack_channel in secrets?

@joshkoenig
Copy link
Copy Markdown
Member

@jordan8037310 thanks for the PR! I added a couple comments where I see potential issues. Respond when you have a chance. ;)

@jordan8037310
Copy link
Copy Markdown
Contributor Author

@joshkoenig I didn't introduce that change, that's explicitly where the current script is looking. I'm just working with that information. Someone already made that decision to search for the slack channel in secrets.json and I am adding validation.

);
}

_slack_notification($secrets['slack_url'], $secrets['slack_channel'], $secrets['slack_username'], $text, $attachment, $secrets['always_show_text']);
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.

@joshkoenig - You'll see here that someone has already configured the _slack_notification to look for slack_channel in the secrets. Perhaps you want to check git blame here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was looking at:

jordan8037310@c475bd1

We removed the channel from the code intentionally because if left blank the default channel the webhook is configured to post into should be used, which is what developers were expecting. Unless something's changed, you don't need to specify a channel in order for it to work.

27a3251

However, we clearly missed taking it end-to-end, hence the confusion.

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.

As I mentioned elsewhere, I used secrets for all sorts of configuration early on. This is probably just one place that was missed when we took the non-secret configuration information out of secrets.json in all of the examples.

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.

Personally I think that even if it wasn't reading from the secrets file, I would probably just rework into a local config.json file that I would store parallel to the /private/scripts.

Much easier for us to keep scripts unified across all our clients with consistent inputs & outputs that way. This is especially attractive to us as we work with multiple agencies at times and will be doing some work to make slack notifications loop through multiple slack configs and channels.

Either way if you want to take the quicksilver-examples in a different direction that is cool, I just wanted to contribute where I saw this discrepancy!

@jordan8037310
Copy link
Copy Markdown
Contributor Author

Updated per feedback! Let me know how this looks when you have some time 👍

@ccharlton
Copy link
Copy Markdown
Collaborator

Ah! Just did this myself. The pretext context of what is running is nice to have. I also have a 'before' and 'after' for 'clear_cache' so I know it's happening on LIVE (before) and when the flush is complete (after).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants