Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

Commit

Permalink
fix(notifications): remove a option for last notified time
Browse files Browse the repository at this point in the history
  • Loading branch information
miyajan committed Jan 5, 2017
1 parent 0df1056 commit 14d04de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ class VersionEyeSlack {

/**
* Post notifications of VersionEye to Slack
* @param {!Date} opt_lastNotifiedTime Post only notifications created after the specific time
* @return {!Promise}
*/
postNotifications(opt_lastNotifiedTime) {
postNotifications() {
return this._versioneye.me.listNotifications().then(json => {
const attachments = [];
json['notifications'].forEach(notification => {
const createdAt = Date.parse(notification['created_at']);
if (opt_lastNotifiedTime && opt_lastNotifiedTime > createdAt) {
// already notified
if (notification['read']) {
// already read
return;
}
const productKey = notification['product']['prod_key'];
Expand Down
13 changes: 1 addition & 12 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,14 @@ function main(argv, env, exit) {

program.command('notifications')
.description('Post notifications of VersionEye to Slack')
.option('--last-notified-time <dateString>', 'Post only notifications created after the time')
.action(options => {
if (program.args.length !== 1) {
// any unknown arguments
printHelpAndExit(exit);
}

const versioneyeSlack = setupVersioneyeSlack(options, env, exit);

let lastNotifiedTime;
if (options.lastNotifiedTime) {
lastNotifiedTime = Date.parse(options.lastNotifiedTime);
if (!lastNotifiedTime) {
console.error(options.lastNotifiedTime + ' can not be parsed. Use ISO 8601 syntax.');
exit(1);
}
}

versioneyeSlack.postNotifications(lastNotifiedTime).then(response => {
versioneyeSlack.postNotifications().then(response => {
console.log(response);
}).catch(err => {
console.error(err.message);
Expand Down

0 comments on commit 14d04de

Please sign in to comment.