dashbot
Version:
Analytics for your bot
27 lines (21 loc) • 608 B
JavaScript
/* Copyright (c) 2016-2019 Dashbot Inc All rights reserved */
;
const _ = require('lodash')
module.exports = function (userList, path) {
return function (methodCall) {
let list
if(typeof userList === 'function') {
list = userList(_.get(methodCall, `args.0.json`))
} else {
list = userList
}
if(!list || list.length === 0) {
return methodCall.proceed()
}
const userId = _.get(methodCall, `args.0.json.${path}`)
if(userId && _.find(list, function(item) { return item === userId })) {
return
}
return methodCall.proceed()
}
}