Slack
The slack module lets editors search and import files from a linked Slack workspace through Brightspot's federated search.
Dependencies
Depends on db-http and the Slack Web API (files.info, files.list, search.files). Account linking and workspace management are provided by the platform's shared com.psddev:slack module; this module adds the search-specific OAuth scope and search integration.
Installation
- Maven
- Gradle
- Gradle (Kotlin DSL)
<!-- Requires Brightspot 5.0 or later. -->
<dependency>
<groupId>com.brightspot.dbhttp</groupId>
<artifactId>slack</artifactId>
<version>1.0.0</version>
</dependency>
// Requires Brightspot 5.0 or later.
implementation 'com.brightspot.dbhttp:slack:1.0.0'
// Requires Brightspot 5.0 or later.
implementation("com.brightspot.dbhttp:slack:1.0.0")
API reference
com.psddev.slack.search.SlackDatabase
Extends HttpDatabase. With a keyword, calls Slack's search.files; without one, falls back to files.list for the linked workspace, optionally filtered to files created after a chosen date range.
com.psddev.slack.search.SlackFile
Extends ExternalItem.
| Field | Type | Description |
|---|---|---|
filename | String | The file name. |
fileId | String | The Slack file Id. |
mimeType | String | The file's MIME type. |
createdDate | Date | When the file was posted in Slack. |
downloadUrl | String | The file's download URL. |
imagePreviewUrl | String | A preview image URL, for image files. |
Sort order is set through the SlackQueryStringSort enum (relevance and timestamp variants), and results can be filtered to the last day, week, month, or year.
Configuration
Workspace credentials and account linking are configured through the shared com.psddev:slack module. Each editor links their own Slack account (adding a search scope the first time they search Slack) before they can search Slack files; downloaded previews are served through an HMAC-signed proxy so image URLs can't be tampered with.
Extending the plugin
The module doesn't ship a content type for imported files. To let editors create one from search results, define a content type and extend ExternalItemConverter<SlackFile, T> to convert the external item into it on import, downloading the file's content from Slack using the linked editor's token.