Skip to content

Commit

Permalink
convert tabs to spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
substack committed Jul 4, 2020
1 parent b73251e commit 5de7c59
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/cabal-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,8 @@ class CabalDetails extends EventEmitter {
this.users = new Map()
Object.keys(users).forEach(key => {
this.users[key] = new User(users[key])
})
this._initializeLocalUser(() => {
})
this._initializeLocalUser(() => {
loadModerationState(() => {
this.registerListener(cabal.moderation.events, 'update', (info) => {
let user = this.users[info.id]
Expand Down
34 changes: 17 additions & 17 deletions src/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ module.exports = {
actions: {
help: () => 'print out a historic log of the moderation actions applied by you, and your active moderators & admins',
call: (cabal, res, arg) => {
const promises = [cabal.moderation.getAdmins(), cabal.moderation.getMods()]
// get all moderation actions issued by our current mods & admins
const promises = [cabal.moderation.getAdmins(), cabal.moderation.getMods()]
// get all moderation actions issued by our current mods & admins
const messages = []
function processMessages (messages) {
res.info('moderation actions')
Expand All @@ -341,7 +341,7 @@ module.exports = {
res.info(message.text)
})
}
Promise.all(promises).then(results => {
Promise.all(promises).then(results => {
const keys = results[0].concat(results[1])
listNextKey()
function listNextKey () {
Expand All @@ -350,7 +350,7 @@ module.exports = {
return res.end()
}
var key = keys.shift()
const write = (row, enc, next) => {
const write = (row, enc, next) => {
if (!row) return
const name = cabal.users[key] ? cabal.users[key].name : key.slice(0, 8)
const target = cabal.users[row.content.id] ? cabal.users[row.content.id].name : row.content.id.slice(0, 8)
Expand All @@ -362,32 +362,32 @@ module.exports = {
if (['admin', 'mod'].includes(role)) { action = (type === 'add' ? 'added' : 'removed') }
if (role === 'hide') { action = (type === 'add' ? 'hid' : 'unhid') }
if (role === 'hide') {
text = `${datestr} ${name} ${action} ${target} ${reason}`
text = `${datestr} ${name} ${action} ${target} ${reason}`
} else {
text = `${datestr} ${name} ${action} ${target} as ${role} ${reason}`
text = `${datestr} ${name} ${action} ${target} as ${role} ${reason}`
}
messages.push({ text, timestamp: parseFloat(row.timestamp) })
next()
}
const end = (next) => {
}
const end = (next) => {
listNextKey()
next()
}
pump(cabal.core.moderation.listModerationBy(key), to.obj(write, end))
pump(cabal.core.moderation.listModerationBy(key), to.obj(write, end))
}
})
}
},
roles: {
help: () => 'list all your current moderators and admins',
call: (cabal, res, arg) => {
const promises = [cabal.moderation.getAdmins(), cabal.moderation.getMods()]
Promise.all(promises).then(results => {
const promises = [cabal.moderation.getAdmins(), cabal.moderation.getMods()]
Promise.all(promises).then(results => {
const keys = results[0].concat(results[1])
const print = (type) => {
return (k) => {
return (k) => {
res.info(`${cabal.users[k] ? cabal.users[k].name : k.slice(0, 8)}: ${type}`)
}
}
}
res.info('moderation roles')
if (keys.length === 1 && keys[0] === cabal.getLocalUser().key) {
Expand All @@ -400,7 +400,7 @@ module.exports = {
results[0].map(printAdmins)
results[1].map(printMods)
res.end()
})
})
}
},
inspect: {
Expand Down Expand Up @@ -588,7 +588,7 @@ function flagCmd (cmd, cabal, res, arg) {
var reason = args.slice(1).join(' ')
const reasonstr = reason ? '(reason: ' + reason + ')' : ''
cabal.moderation.setFlag(flag, type, channel, id, reason).then(() => {
if (['admin', 'mod'].includes(flag)) {
if (['admin', 'mod'].includes(flag)) {
if (/^un/.test(cmd) && flag === 'mod' && !cabal.users[id].isModerator()) {
res.error(`${getPeerName(cabal, id)} is not a mod`)
} else if (/^un/.test(cmd) && flag === 'admin' && !cabal.users[id].isAdmin()) {
Expand All @@ -598,7 +598,7 @@ function flagCmd (cmd, cabal, res, arg) {
} else if (!/^un/.test(cmd) && flag === 'admin' && cabal.users[id].isAdmin()) {
res.error(`${getPeerName(cabal, id)} is already an admin`)
}
} else {
} else {
if (/^un/.test(cmd)) {
if (!cabal.users[id].isHidden()) {
res.error(`cannot unhide ${getPeerName(cabal, id)}: they are not hidden`)
Expand All @@ -608,7 +608,7 @@ function flagCmd (cmd, cabal, res, arg) {
res.error(`${getPeerName(cabal, id)} is already hidden`)
}
}
}
}
res.end()
}).catch((err) => { res.error(err) })
}
Expand Down
10 changes: 5 additions & 5 deletions src/moderation.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ class Moderation {
setFlag (flag, type, channel = '@', id, reason = '') {
// a list of [[id, reason]] was passed in
if (typeof id === 'object' && typeof id[Symbol.iterator] === 'function') {
const promises = id.map((entry) => {
const promises = id.map((entry) => {
return new Promise((resolve, reject) => {
this._flagCmd(flag, type, channel, entry[0], entry[1], (err) => {
this._flagCmd(flag, type, channel, entry[0], entry[1], (err) => {
if (err) { return reject(err) } else { resolve() }
})
})
})
})
return Promise.all(promises)
})
return Promise.all(promises)
}
return new Promise((resolve, reject) => {
this._flagCmd(flag, type, channel, id, reason, (err) => {
Expand Down

0 comments on commit 5de7c59

Please sign in to comment.