17 Commits

Author SHA1 Message Date
078f78417c 3.7.0 2020-07-18 13:06:48 +02:00
d870099059 Update to latest ethers.js patch release 2020-07-18 13:06:09 +02:00
b7482f2468 package-lock 2020-07-18 13:04:12 +02:00
94c256e3d9 Merge pull request #60 from 67P/dependabot/npm_and_yarn/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19
2020-07-18 12:59:15 +02:00
3b382eadb2 Merge pull request #59 from 67P/ethers-nonce-manager
Use new ethers.js NonceManager to handle transaction nonces
2020-07-18 12:58:45 +02:00
ec63980cd3 Use kredits-contracts 6.0.0 2020-07-17 13:50:37 +02:00
dependabot[bot]
2b86f37fcb Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-16 03:28:48 +00:00
a8e29f2197 Use ethers5 branch of kredits-contracts 2020-06-27 18:38:22 +02:00
b7ff55929c Use new ethers.js NonceManager to handle transaction nonces
So far we have failed to globally handle the transaction nonces.
The new ethers.js v5 comes with a NonceManager that helps us handling
transaction nonces and automatically increases the nonce for each
transaction.
2020-06-27 18:24:44 +02:00
35f6acc150 3.6.0 2020-05-22 12:10:24 +02:00
095a1e0004 Merge pull request #56 from 67P/feature/zoom-meeting-whitelist
Add zoom meeting whitelist
2020-05-18 10:43:25 +02:00
95290a7715 Apply suggestions from code review
Co-authored-by: Sebastian Kippe <sebastian@kip.pe>
2020-05-14 12:13:38 +02:00
fca017c61a Add readme for zoom integration 2020-05-14 10:38:51 +02:00
fb1a471303 Make kredits amount for zoom calls configurable
defaults to 500 - a general small contribution
2020-05-14 10:33:13 +02:00
d82e2e9256 Revert "Update integrations/zoom.js"
This reverts commit 634dc207e6.
2020-05-14 10:00:00 +02:00
634dc207e6 Update integrations/zoom.js
Co-authored-by: Sebastian Kippe <sebastian@kip.pe>
2020-05-14 09:45:42 +02:00
6fd3989118 Add zoom meeting whitelist
This allows to only record meetings for certain whitelisted meeting ids
2020-04-30 16:19:49 +02:00
5 changed files with 1537 additions and 620 deletions

View File

@@ -116,3 +116,29 @@ wiki's API on its own.
[kredits-contracts]: https://github.com/67P/kredits-contracts
[GitHub OAuth app]: https://developer.github.com/apps/about-apps/#about-oauth-apps
### Zoom
The Zoom integration creates contributions for meeting participations.
Every meeting that is longer than 15 minutes and with more than 2 participants will be registered.
An optional meeting whitelist can be configured to create contributions only for specific meetings.
#### Setup
A Zoom JWT app has to be set up and an [event webhook subscription](https://marketplace.zoom.us/docs/api-reference/webhook-reference/meeting-events/meeting-ending")
on `meeting.ended` has to be configured to the following URL:
https://your-hubot.example.com/incoming/kredits/zoom/{webhook_token}
#### Config
| Key | Description |
| --- | --- |
| `KREDITS_ZOOM_JWT` | The JWT for the Zoom application (required)
| `KREDITS_ZOOM_MEETING_WHITELIST` | Comma separated list of meeting names for which kredits should be tracked (optional)
| `KREDITS_ZOOM_CONTRIBUTION_AMOUNT` | The amount of kredits issued for each meeting. (default: 500)
[Zoom apps](https://marketplace.zoom.us/user/build)

View File

@@ -2,6 +2,7 @@ const fs = require('fs');
const util = require('util');
const fetch = require('node-fetch');
const ethers = require('ethers');
const NonceManager = require('@ethersproject/experimental').NonceManager;
const Kredits = require('kredits-contracts');
const walletPath = process.env.KREDITS_WALLET_PATH || './wallet.json';
@@ -43,7 +44,7 @@ module.exports = async function(robot) {
} else {
ethProvider = new ethers.getDefaultProvider('rinkeby');
}
const signer = wallet.connect(ethProvider);
const signer = new NonceManager(wallet.connect(ethProvider));
//
// Kredits contracts setup

View File

@@ -1,5 +1,9 @@
const fetch = require('node-fetch');
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
module.exports = async function(robot, kredits) {
function messageRoom(message) {
@@ -8,14 +12,11 @@ module.exports = async function(robot, kredits) {
const { Contributor, Contribution } = kredits;
const kreditsContributionAmount = 500;
const kreditsContributionAmount = process.env.KREDITS_ZOOM_CONTRIBUTION_AMOUNT || 500;
const kreditsContributionKind = 'community';
const zoomAccessToken = process.env.KREDITS_ZOOM_JWT;
const walletTransactionCount = await kredits.provider.getTransactionCount(kredits.signer.address);
let nonce = walletTransactionCount;
async function createContributionFor (displayName, meeting) {
const contributor = await getContributorByZoomDisplayName(displayName);
@@ -35,7 +36,7 @@ module.exports = async function(robot, kredits) {
time: meeting.end_time.split('T')[1]
}
return Contribution.add(contribution, { nonce: nonce++ })
return Contribution.add(contribution)
.then(tx => {
robot.logger.info(`[hubot-kredits] Contribution created: ${tx.hash}`);
})
@@ -78,6 +79,7 @@ module.exports = async function(robot, kredits) {
for (const displayName of names) {
await createContributionFor(displayName, meetingDetails);
await sleep(60000); // potentially to prevent too many transactions at the sametime. transactions need to be ordered because of the nonce. not sure though if this is needed.
};
}
@@ -87,7 +89,11 @@ module.exports = async function(robot, kredits) {
const payload = data.payload;
const object = payload.object;
if (eventName === 'meeting.ended') {
if (eventName === 'meeting.ended' && (
!process.env.KREDITS_ZOOM_MEETING_WHITELIST ||
process.env.KREDITS_ZOOM_MEETING_WHITELIST.split(',').includes(object.id)
)) {
handleZoomMeetingEnded(object);
}

2103
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "hubot-kredits",
"version": "3.5.1",
"version": "3.7.0",
"description": "Kosmos Kredits functionality for chat bots",
"main": "index.js",
"scripts": {
@@ -12,13 +12,14 @@
"dependencies": {
"cors": "^2.8.5",
"eth-provider": "^0.2.2",
"ethers": "^4.0.27",
"ethers": "^5.0.5",
"@ethersproject/experimental": "5.0.0",
"express": "^4.17.1",
"express-session": "^1.16.2",
"grant-express": "^4.6.1",
"group-array": "^1.0.0",
"kosmos-schemas": "^1.1.2",
"kredits-contracts": "^5.4.0",
"kredits-contracts": "^6.0.0",
"node-cron": "^2.0.3",
"node-fetch": "^2.3.0",
"prompt": "^1.0.0"