Skip to content

Commit

Permalink
Improves naming of default channel type.
Browse files Browse the repository at this point in the history
  • Loading branch information
outofcoffee committed Aug 22, 2019
1 parent 1c157d2 commit ed3cb1d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
## [0.3.0] - 2019-08-22
### Added
- Adds support for creating and posting to public channels.
- Adds support for specifying the default channel type to create.

### Changed
- Private, then public channels are searched before attempting to create a channel.

## [0.2.0] - 2019-08-08
### Added
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ This will result in message text such as the following:

You can specify the channel type as public or private. This will be used when creating channels, or posting messages.

Set the `channel_type` query parameter in the HTTP request, or use the `DEFAULT_CHANNEL_TYPE` environment variable.
Set the `channel_type` query parameter in the HTTP request, or use the `DEFAULT_CREATE_CHANNEL_TYPE` environment variable.

Valid values:

Expand Down Expand Up @@ -184,7 +184,7 @@ Configure the bot using the following environment variables.
- HTTP_BIND_PORT (default 8080)
- HTTP_BIND_HOST (default 0.0.0.0)
- SLACK_CACHE_SECONDS - period to cache Slack objects like users and user groups (default 300)
- DEFAULT_CHANNEL_TYPE (default 'private') - the default channel type if none is specified in the request
- DEFAULT_CREATE_CHANNEL_TYPE (default 'private') - the default channel type to create if none is specified in the request

## Contributing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SlackOutboundMessageService @Inject constructor(

} ?: run {
// create the channel
val createChannelType = channelType ?: Settings.defaultChannelType
val createChannelType = channelType ?: Settings.defaultCreateChannelType
logger.debug("Channel $channelName ($createChannelType) does not exist - creating")
slackOperationsService.createChannel(channelName, createChannelType)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.gatehill.slackgateway.model.ChannelType
* Core application settings.
*/
object Settings : EnvironmentSettings() {
val defaultChannelType: ChannelType by lazy {
getenv("DEFAULT_CHANNEL_TYPE")?.let { ChannelType.parse(it) } ?: ChannelType.PRIVATE
val defaultCreateChannelType: ChannelType by lazy {
getenv("DEFAULT_CREATE_CHANNEL_TYPE")?.let { ChannelType.parse(it) } ?: ChannelType.PRIVATE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import com.gatehill.slackgateway.util.VersionUtil

fun main(args: Array<String>) {
println("Starting Slack Gateway [version ${VersionUtil.version}]")
println("Default channel type: ${Settings.defaultChannelType}")
println("Default channel type: ${Settings.defaultCreateChannelType}")
Bootstrap.build(HttpModule(), SlackModule()).start()
}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ services:
environment:
- SLACK_USER_TOKEN
- SLACK_CHANNEL_MEMBERS
- DEFAULT_CHANNEL_TYPE
- DEFAULT_CREATE_CHANNEL_TYPE
- JAVA_OPTS

0 comments on commit ed3cb1d

Please sign in to comment.