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

Use slack-webhook library #35

Closed
wants to merge 8 commits into from
Closed

Use slack-webhook library #35

wants to merge 8 commits into from

Conversation

eljobe
Copy link
Contributor

@eljobe eljobe commented Sep 28, 2016

I'm not 100% happy with this change. It definitely simplifies the creation of slack messages from the data that is generated by the TeamCity build status events. However, I notice that the SlackWrapper class is basically a useless abstraction in the current way the code is organized.

For each event the SlackNotificator receives and each user in the set of users who need to be notified for this event, we instantiate a new SlackWrapper and then call send on that wrapper instance. But, we never need to reuse any of the state on the SlackWrapper object, so, we might as well just be passing the data straight through instead of storing it on an object.

I'd like to get this much of the code integrated into the project as it provides some benefit (no longer need the SlackPayload class.) But, then I'm going to continue restructuring the SlackNotificator such that it's job is basically to:

  1. Create a TeamCityEvent object which describes what happened from TeamCity's point of view (e.g. The build failed.)
  2. For each user who needs to be notified, create a SlackTarget object which describes the data we currently keep on SlackWrapper and then passes that Set<SlackTarget> and TeamCityEvent to a new version of SlackWrapper.send() which will just be responsible for creating a SlackMessage and sending it to the SlackApi for each SlackTarget and TeamCityEvent This way, we can construct the SlackWrapper only once and cache instances of SlackApi based on the slackUrl from which they are constructed.

If you'd prefer, I can go ahead and work on those changes as part of this pull request, but this code is working, so I'd prefer to get it checked in, and then add these other pieces incrementally.

We were previously building the json payload ourselves. Now, we off-load
that work onto a library which is made for this purpose.

This is just an initial shim that works. We probably need to ditch the
SlackPayload class entirely favoring a SlackMessage Factory that does
the work currently in the SlackPayload constructor.
Before this change, the Verbose setting wasn't able to be set to `True`
because it was the same value as the placeholder text.
This also cleans up a few warnings from the IDE
This simplifies what is essentially a functional operation into a static
function.
@eljobe
Copy link
Contributor Author

eljobe commented May 6, 2024

I'm guessing this is not going to be merged. Closing.

@eljobe eljobe closed this May 6, 2024
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.

None yet

1 participant