Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a95bf0141e | |||
| b4f6fb7ef7 | |||
| 98f4516217 | |||
| 149bc0c052 | |||
| c190490d9b | |||
| eb767a90f2 | |||
| 156ea44f0d | |||
| ec7f4a4d33 | |||
| 5f9e237f36 |
@@ -1,3 +1,4 @@
|
||||
const url = require('url');
|
||||
const util = require('util');
|
||||
const fetch = require('node-fetch');
|
||||
const groupArray = require('group-array');
|
||||
@@ -14,21 +15,17 @@ module.exports = async function(robot, kredits) {
|
||||
const Contributor = kredits.Contributor;
|
||||
const Operator = kredits.Operator;
|
||||
|
||||
const apiURL = process.env.KREDITS_MEDIAWIKI_URL + 'api.php';
|
||||
const wikiURL = process.env.KREDITS_MEDIAWIKI_URL;
|
||||
const apiURL = wikiURL + 'api.php';
|
||||
|
||||
function getContributorByWikiUser(username) {
|
||||
return Contributor.all().then(contributors => {
|
||||
let contrib = contributors.find(c => {
|
||||
if (typeof c.accounts !== 'object') { return false; }
|
||||
return c.accounts.find(a => {
|
||||
a.url === `${process.env.KREDITS_MEDIAWIKI_URL}User:${username}`;
|
||||
});
|
||||
});
|
||||
if (!contrib) {
|
||||
throw new Error();
|
||||
} else {
|
||||
return contrib;
|
||||
}
|
||||
let account = {
|
||||
site: url.parse(process.env.KREDITS_MEDIAWIKI_URL).hostname,
|
||||
username: username
|
||||
}
|
||||
return Contributor.findByAccount(account).then(contributor => {
|
||||
robot.logger.debug('CONTRIBUTOR: ', contributor)
|
||||
if (contributor) { return contributor; } else { throw new Error(); }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -120,7 +117,7 @@ module.exports = async function(robot, kredits) {
|
||||
}
|
||||
|
||||
function pageTitlesFromChanges(changes) {
|
||||
return changes.map(c => `"${c.title}"`).join(', ');
|
||||
return [...new Set(changes.map(c => `"${c.title}"`))].join(', ');
|
||||
}
|
||||
|
||||
function calculateAmountForChanges(details) {
|
||||
@@ -149,13 +146,14 @@ module.exports = async function(robot, kredits) {
|
||||
if (details.pagesCreated.length > 0) {
|
||||
desc = `Created ${pageTitlesFromChanges(details.pagesCreated)}. ${desc}`;
|
||||
}
|
||||
desc = `Wiki contributions: ${desc}`;
|
||||
|
||||
let url;
|
||||
if (changes.length > 1) {
|
||||
url = `https://wiki.kosmos.org/Special:Contributions/${user}?hideMinor=1`;
|
||||
url = `${wikiURL}Special:Contributions/${user}?hideMinor=1`;
|
||||
} else {
|
||||
rc = changes[0];
|
||||
url = `https://wiki.kosmos.org/index.php?title=${rc.title}&diff=${rc.revid}&oldid=${rc.old_revid}`;
|
||||
url = `${wikiURL}index.php?title=${rc.title}&diff=${rc.revid}&oldid=${rc.old_revid}`;
|
||||
}
|
||||
|
||||
return createProposal(user, amount, desc, url, details);
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hubot-kredits",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hubot-kredits",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.1",
|
||||
"description": "Kosmos Kredits functionality for chat bots",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -23,7 +23,9 @@
|
||||
"url": "git+https://github.com/67P/hubot-kredits.git"
|
||||
},
|
||||
"keywords": [
|
||||
"kosmos"
|
||||
"kosmos",
|
||||
"kredits",
|
||||
"hubot-scripts"
|
||||
],
|
||||
"author": "Kosmos Developers <mail@kosmos.org>",
|
||||
"contributors": [
|
||||
|
||||
Reference in New Issue
Block a user