This repository has been archived by the owner on May 16, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
command for notifying particular user readme update tests #1
- Loading branch information
Showing
12 changed files
with
272 additions
and
20 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
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,59 @@ | ||
/*jshint node: true*/ | ||
'use strict'; | ||
|
||
var harvest = require('./../../../services/harvest')('default'), | ||
notifier = require('./../../../services/notifier'), | ||
_ = require('lodash'), | ||
logger = require('./../../../services/logger.js')('default'), | ||
reminder = require('./../../../services/reminder/index'), | ||
tools = require('./../../../services/tools.js') | ||
; | ||
|
||
|
||
/** | ||
* Notifies the users on Slack | ||
* | ||
* @param {Object} harvestResponse The harvest API response | ||
* @param {Number} userId The harvest user Id | ||
* @returns {undefined} | ||
*/ | ||
function doNotify (harvestResponse, userId) | ||
{ | ||
notifier.notify('reminder', { | ||
harvestUserId : userId, | ||
harvestResponse : harvestResponse | ||
}); | ||
} | ||
|
||
|
||
/** | ||
* Notifies all mapped slack users to activate their Harvest if that's not done. | ||
* | ||
* @param {Object} req The request object | ||
* @param {Object} res The response object | ||
* @param {Function} next The next callback to apply | ||
* @returns {undefined} | ||
*/ | ||
function remindUserController (req, res, next) | ||
{ | ||
var users; | ||
try { | ||
users = tools.validateGetUser(harvest.users, req.params.user); | ||
} catch (err) { | ||
res.success = false; | ||
res.errors = [ | ||
err.message | ||
]; | ||
next(); | ||
return; | ||
} | ||
reminder.remind(users, function () { | ||
res.success = true; | ||
next(); | ||
}); | ||
} | ||
|
||
module.exports = function (app, config) | ||
{ | ||
app.use('/api/remind-user/:user', remindUserController); | ||
}; |
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
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
Oops, something went wrong.