ramirez/src/blocked.js

28 lines
552 B
JavaScript
Raw Normal View History

2017-02-09 21:56:36 -05:00
const jsonDb = require('./jsonDb');
function isBlocked(userId) {
return jsonDb.get('blocked').then(blocked => {
return blocked.indexOf(userId) !== -1;
});
}
function block(userId) {
return jsonDb.get('blocked').then(blocked => {
blocked.push(userId);
return jsonDb.save('blocked', blocked);
});
}
function unblock(userId) {
return jsonDb.get('blocked').then(blocked => {
blocked.splice(blocked.indexOf(userId), 1);
return jsonDb.save('blocked', blocked);
});
}
module.exports = {
isBlocked,
block,
unblock,
};