-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathReputationParams.js
More file actions
33 lines (27 loc) · 878 Bytes
/
ReputationParams.js
File metadata and controls
33 lines (27 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
const User = require.main.require('./src/user'),
Posts = require.main.require('./src/posts');
async function findUser(userId) {
return await User.getUserData(userId);
}
async function findPost(postId) {
return await Posts.getPostData(postId);
}
async function findCategory(postId) {
return await Posts.getCidByPid(postId);
}
async function recoverParams(voterId, postId) {
try {
let params = {};
params.user = await findUser(voterId);
params.post = await findPost(postId);
params.author = await findUser(params.post.uid);
params.post.cid = parseInt(await findCategory(postId), 10);
return params;
} catch (err) {
throw new Error('[nodebb-plugin-reputation-rules] Error retrieving vote data on ReputationParams. ' + err.message);
}
}
module.exports = {
recoverParams
};