-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Slack notifications automation (#833)
- Loading branch information
1 parent
a33a0a4
commit 3d953d3
Showing
67 changed files
with
2,261 additions
and
1,199 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Axios from 'axios' | ||
import Permissions from '../../security/permissions' | ||
import PermissionChecker from '../../services/user/permissionChecker' | ||
import SettingsService from '../../services/settingsService' | ||
|
||
export default async (req, res) => { | ||
new PermissionChecker(req).validateHas(Permissions.values.automationCreate) | ||
const { redirectUrl } = JSON.parse(Buffer.from(req.query.state, 'base64').toString()) | ||
|
||
const { url } = req.account | ||
|
||
await SettingsService.save({ slackWebHook: url }, req) | ||
await Axios.post(url, { | ||
text: 'Crowd.dev Notifier has been successfully connected.', | ||
}) | ||
|
||
res.redirect(redirectUrl) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import passport from 'passport' | ||
import Permissions from '../../security/permissions' | ||
import PermissionChecker from '../../services/user/permissionChecker' | ||
import { getSlackNotifierStrategy } from '../../services/auth/passportStrategies/slackStrategy' | ||
|
||
export default async (req, res, next) => { | ||
new PermissionChecker(req).validateHas(Permissions.values.automationCreate) | ||
const state = { | ||
tenantId: req.params.tenantId, | ||
redirectUrl: req.query.redirectUrl, | ||
crowdToken: req.query.crowdToken, | ||
} | ||
|
||
const authenticator = passport.authenticate(getSlackNotifierStrategy(), { | ||
scope: ['incoming-webhook'], | ||
state: Buffer.from(JSON.stringify(state)).toString('base64'), | ||
}) | ||
|
||
authenticator(req, res, next) | ||
} |
Oops, something went wrong.