Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
MrOrz committed Aug 14, 2020
2 parents c7e8aa9 + da2e9a6 commit 7c28943
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ If you want to build using docker instead, you may need to modify Dockerfile to
LINE_NOTIFY_CLIENT_SECRET=<paste LINE Notify Client Secret here>
NOTIFY_METHOD=LINE_NOTIFY
RUMORS_LINE_BOT_URL=<line bot server url>
LINE_FRIEND_URL=https://line.me/R/ti/p/<paste your chatbot ID here>
```

You can set up a setting page entry point(`LIFF_URL`/liff/index.html?p=setting) in [account manager](https://manager.line.biz/account/) -> rich menu
Expand Down
3 changes: 1 addition & 2 deletions src/database/backtrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import { parseToJson } from '@cofacts/line-bot-log-parser';
*
* 2. run
* ```bash
* npm run build:server
* USER_ID=1 node -r dotenv/config build/database/backtrack.js
* USER_ID=1 node_modules/.bin/babel-node -r dotenv/config src/database/backtrack.js
* ```
*
* @param {string} path a path of rumors-line-bot-logs folder
Expand Down
1 change: 1 addition & 0 deletions src/scripts/__tests__/scanRepliesAndNotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import redis from 'src/lib/redisClient';

it('scan replies and notify', async () => {
redis.set = jest.fn();
redis.quit = jest.fn();
lib.getNotificationList = jest.fn().mockImplementationOnce(() => {});
lib.sendNotification = jest.fn();

Expand Down
12 changes: 11 additions & 1 deletion src/scripts/scanRepliesAndNotify.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import lib from './lib';
import redis from 'src/lib/redisClient';
import rollbar from 'src/lib/rollbar';
import addTime from 'date-fns/add';
import Client from 'src/database/mongoClient';

export default async function scanRepliesAndNotify() {
const timeOffset = JSON.parse(process.env.REVIEW_REPLY_BUFFER) || {};
Expand All @@ -16,8 +18,16 @@ export default async function scanRepliesAndNotify() {
);
await lib.sendNotification(notificationList);
await redis.set('lastScannedAt', nowWithOffset);

// disconnect redis and mongodb
await redis.quit();
await (await Client.getInstance()).close();
}

if (require.main === module) {
scanRepliesAndNotify();
scanRepliesAndNotify().catch(e => {
console.error(e);
rollbar.error(e);
process.exit(1);
});
}

0 comments on commit 7c28943

Please sign in to comment.