diff --git a/.eslintignore b/.eslintignore index 43862e59b..9494d64da 100644 --- a/.eslintignore +++ b/.eslintignore @@ -33,4 +33,5 @@ public !plugins/talk-plugin-sort-oldest !plugins/talk-plugin-subscriber !plugins/talk-plugin-toxic-comments -!plugins/talk-plugin-viewing-options \ No newline at end of file +!plugins/talk-plugin-viewing-options +!plugins/talk-plugin-profile-settings diff --git a/.gitignore b/.gitignore index 5ce310122..c475a9ea7 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ plugins.json plugins/* !plugins/talk-plugin-akismet !plugins/talk-plugin-facebook-auth +!plugins/talk-plugin-google-auth !plugins/talk-plugin-auth !plugins/talk-plugin-respect !plugins/talk-plugin-offtopic @@ -56,6 +57,7 @@ plugins/* !plugins/talk-plugin-subscriber !plugins/talk-plugin-flag-details !plugins/talk-plugin-slack-notifications +!plugins/talk-plugin-profile-settings **/node_modules/* yarn-error.log diff --git a/.nsprc b/.nsprc index 583560bdd..da6cb9865 100644 --- a/.nsprc +++ b/.nsprc @@ -1,6 +1,7 @@ { "exceptions": [ "https://nodesecurity.io/advisories/531", - "https://nodesecurity.io/advisories/532" + "https://nodesecurity.io/advisories/532", + "https://nodesecurity.io/advisories/566" ] } diff --git a/Dockerfile b/Dockerfile index 95aa74d8a..4d0fea440 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,6 @@ ENV NODE_ENV production # Install app dependencies and build static assets. RUN yarn global add node-gyp && \ yarn install --frozen-lockfile && \ - cli plugins reconcile && \ yarn build && \ yarn cache clean diff --git a/Dockerfile.onbuild b/Dockerfile.onbuild index dab06f336..5739d6f95 100644 --- a/Dockerfile.onbuild +++ b/Dockerfile.onbuild @@ -1,6 +1,9 @@ FROM coralproject/talk:latest # Setup the build arguments +ONBUILD ARG TALK_ADDTL_COMMENTS_ON_LOAD_MORE=10 +ONBUILD ARG TALK_ASSET_COMMENTS_LOAD_DEPTH=10 +ONBUILD ARG TALK_REPLY_COMMENTS_LOAD_DEPTH=3 ONBUILD ARG TALK_THREADING_LEVEL=3 ONBUILD ARG TALK_DEFAULT_STREAM_TAB=all ONBUILD ARG TALK_DEFAULT_LANG=en diff --git a/bin/cli-plugins b/bin/cli-plugins index 883682ede..ee331bff2 100755 --- a/bin/cli-plugins +++ b/bin/cli-plugins @@ -135,18 +135,11 @@ function reconcilePackages({ quiet = false, upgradeRemote = false }) { return { local, fetchable, upgradable }; } -async function reconcileRemotePlugins({ skipLocal, dryRun, upgradeRemote }) { - console.log( - `\n[${skipLocal ? '1/2' : '2/3'}] ${emoji.get( - 'mag' - )} Reconciling plugins...`.yellow - ); +async function reconcileRemotePlugins({ dryRun, upgradeRemote }) { + console.log(`\n['1/2'] ${emoji.get('mag')} Reconciling plugins...`.yellow); const { fetchable, upgradable } = reconcilePackages({ upgradeRemote }); - console.log( - `[${skipLocal ? '2/2' : '3/3'}] ${emoji.get('truck')} Fetching plugins...\n` - .yellow - ); + console.log(`['2/2'] ${emoji.get('truck')} Fetching plugins...\n`.yellow); if (fetchable.length > 0) { console.log( @@ -206,98 +199,41 @@ async function reconcileRemotePlugins({ skipLocal, dryRun, upgradeRemote }) { return { upgradable, fetchable }; } -async function reconcileLocalPlugins({ skipRemote, dryRun }) { - console.log( - `\n[${skipRemote ? '1/1' : '1/3'}] ${emoji.get( - 'pick' - )} Installing local plugin dependencies...\n`.yellow - ); - const { local } = reconcilePackages({ quiet: true }); - - for (let i in local) { - let { name } = local[i]; - - if (!fs.existsSync(path.join(dir, 'plugins', name, 'package.json'))) { - continue; - } - - let wd = path.join(dir, 'plugins', name); - - console.log(`$ cd ${wd.cyan} && yarn`); - - if (!dryRun) { - let args = []; - - let output = spawn.sync('yarn', args, { - stdio: ['ignore', 'pipe', 'inherit'], - cwd: wd, - }); - - if (output.status) { - throw new Error( - 'Could not install local plugin dependencies, errors occurred during install' - ); - } - - console.log(output.stdout.toString()); - } - } -} - // This traverses the local plugins and installs any dependencies listed there, // this only is really needed for plugins that are installed via docker because // core plugins will have their dependencies already included in core. -async function reconcilePluginDeps({ - skipLocal, - skipRemote, - dryRun, - upgradeRemote, -}) { +async function reconcilePluginDeps({ dryRun, upgradeRemote }) { try { let startTime = new Date(); - // We don't need to do anything if we skip everything.... - if (skipLocal && skipRemote) { - return; - } - - // Traverse local plugins and install dependencies if enabled. - if (!skipLocal) { - await reconcileLocalPlugins({ skipRemote, dryRun }); - } - // Locate any external plugins and install them. - if (!skipRemote) { - const results = await reconcileRemotePlugins({ - skipLocal, - skipRemote, - dryRun, - upgradeRemote, - }); + const results = await reconcileRemotePlugins({ + dryRun, + upgradeRemote, + }); - let status; - if (dryRun) { - status = '[dry-run] success'.green; - } else { - status = 'success'.green; - } - - let message; - if (results.upgradable.length === 0 && results.fetchable.length === 0) { - message = 'Already up-to-date.'; - } else if (results.upgradable.length === 0) { - message = `Fetched ${results.fetchable.length} new plugins.`; - } else if (results.fetchable.length === 0) { - message = `Upgraded ${results.upgradable.length} new plugins.`; - } else { - message = `Fetched ${results.fetchable.length} new plugins, upgraded ${ - results.upgradable.length - } plugins.`; - } - - console.log(`\n${status} ${message}`); + let status; + if (dryRun) { + status = '[dry-run] success'.green; + } else { + status = 'success'.green; } + let message; + if (results.upgradable.length === 0 && results.fetchable.length === 0) { + message = 'Already up-to-date.'; + } else if (results.upgradable.length === 0) { + message = `Fetched ${results.fetchable.length} new plugins.`; + } else if (results.fetchable.length === 0) { + message = `Upgraded ${results.upgradable.length} new plugins.`; + } else { + message = `Fetched ${results.fetchable.length} new plugins, upgraded ${ + results.upgradable.length + } plugins.`; + } + + console.log(`\n${status} ${message}`); + let endTime = new Date(); let totalTime = ((endTime.getTime() - startTime.getTime()) / 1000).toFixed( @@ -440,16 +376,12 @@ program program .command('reconcile') - .description( - 'reconciles local plugin dependencies and downloads external plugins' - ) + .description('reconciles dependencies by downloading external plugins') .option('-u, --upgrade-remote', 'upgrades remote dependencies') .option( '-d, --dry-run', 'does not actually change anything on the filesystem acts only as a simulation' ) - .option('--skip-local', 'skips the local dependancy reconciliation') - .option('--skip-remote', 'skips the remote plugin reconciliation') .action(reconcilePluginDeps); program.parse(process.argv); diff --git a/client/coral-admin/src/components/AccountHistory.js b/client/coral-admin/src/components/AccountHistory.js index 04df552be..52f3af92d 100644 --- a/client/coral-admin/src/components/AccountHistory.js +++ b/client/coral-admin/src/components/AccountHistory.js @@ -19,14 +19,30 @@ const buildUserHistory = (userState = {}) => { ); }; -const buildActionResponse = (typename, until, status) => { +/** readableDuration returns a readable duration of the suspension/ban in hours or days + * @param {} startDate + * @param {} endDate + */ +const readableDuration = (startDate, endDate) => { + const dur = moment.duration(moment(endDate).diff(moment(startDate))); + const durAsDays = dur.asDays().toFixed(0); + const durAsHours = dur.asHours().toFixed(0); + + return durAsHours > 23 + ? `${durAsDays} ${durAsDays > 1 ? 'days' : 'day'}` + : `${durAsHours} ${durAsHours > 1 ? 'hours' : 'hour'}`; +}; + +const buildActionResponse = (typename, created_at, until, status) => { switch (typename) { case 'UsernameStatusHistory': return `Username ${status}`; case 'BannedStatusHistory': return status ? 'User banned' : 'Ban removed'; case 'SuspensionStatusHistory': - return until ? 'Account Suspended' : 'Suspension removed'; + return until + ? `Suspended, ${readableDuration(created_at, until)}` + : 'Suspension removed'; default: return '-'; } @@ -77,7 +93,7 @@ class AccountHistory extends React.Component { 'talk-admin-account-history-row-status' )} > - {buildActionResponse(__typename, until, status)} + {buildActionResponse(__typename, created_at, until, status)}
{emailAddress}
: null} +{emailAddress}
: null} -- {t('user_no_comment')} -
- )} -