diff --git a/app.js b/app.js index 5826a0272..c0962d3aa 100644 --- a/app.js +++ b/app.js @@ -42,7 +42,7 @@ if (process.env.NODE_ENV !== 'test') { app.use(morgan('dev')); } -if (process.env.NODE_ENV === 'development' && ENABLE_TRACING && APOLLO_ENGINE_KEY) { +if (ENABLE_TRACING && APOLLO_ENGINE_KEY) { const {Engine} = require('apollo-engine'); const engine = new Engine({ @@ -50,7 +50,7 @@ if (process.env.NODE_ENV === 'development' && ENABLE_TRACING && APOLLO_ENGINE_KE apiKey: APOLLO_ENGINE_KEY }, graphqlPort: PORT, - endpoint: '/api/v1/graph/ql', + endpoint: `${MOUNT_PATH}api/v1/graph/ql`, }); engine.start(); diff --git a/client/coral-admin/src/routes/Community/containers/People.js b/client/coral-admin/src/routes/Community/containers/People.js index 81308e773..d408f92bf 100644 --- a/client/coral-admin/src/routes/Community/containers/People.js +++ b/client/coral-admin/src/routes/Community/containers/People.js @@ -19,6 +19,7 @@ class PeopleContainer extends React.Component { onKeyDownHandler = (e) => { if (e.key === 'Enter') { e.preventDefault(); + // this.fetchUsers(); } } diff --git a/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js b/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js index 0485a8625..1039c9913 100644 --- a/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js +++ b/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js @@ -152,6 +152,7 @@ class ModerationQueue extends React.Component { nextComments && nextComments.length < prevComments.length ) { + // Invalidate first cursor if referenced comment was removed. if ( this.state.idCursors[0] && diff --git a/client/coral-admin/src/routes/Moderation/containers/Moderation.js b/client/coral-admin/src/routes/Moderation/containers/Moderation.js index fcfe4c20a..177191607 100644 --- a/client/coral-admin/src/routes/Moderation/containers/Moderation.js +++ b/client/coral-admin/src/routes/Moderation/containers/Moderation.js @@ -111,10 +111,10 @@ class ModerationContainer extends Component { this.props.auth.user.id === user.id ? '' : t( - 'modqueue.notify_accepted', - user.username, - prepareNotificationText(comment.body) - ); + 'modqueue.notify_accepted', + user.username, + prepareNotificationText(comment.body) + ); return this.handleCommentChange(prev, comment, notifyText); }, }, @@ -132,10 +132,10 @@ class ModerationContainer extends Component { this.props.auth.user.id === user.id ? '' : t( - 'modqueue.notify_rejected', - user.username, - prepareNotificationText(comment.body) - ); + 'modqueue.notify_rejected', + user.username, + prepareNotificationText(comment.body) + ); return this.handleCommentChange(prev, comment, notifyText); }, }, @@ -153,10 +153,10 @@ class ModerationContainer extends Component { this.props.auth.user.id === user.id ? '' : t( - 'modqueue.notify_reset', - user.username, - prepareNotificationText(comment.body) - ); + 'modqueue.notify_reset', + user.username, + prepareNotificationText(comment.body) + ); return this.handleCommentChange(prev, comment, notifyText); }, }, @@ -207,6 +207,7 @@ class ModerationContainer extends Component { } componentWillReceiveProps(nextProps) { + // Resubscribe when we change between assets. if ( this.props.data.variables.asset_id !== nextProps.data.variables.asset_id @@ -275,12 +276,14 @@ class ModerationContainer extends Component { if (assetId) { if (asset === null) { + // Not found. return ; } } if (data.loading) { + // loading. return ; } @@ -424,23 +427,23 @@ const withModQueueQuery = withQuery( ({queueConfig}) => gql` query CoralAdmin_Moderation($asset_id: ID, $sortOrder: SORT_ORDER, $allAssets: Boolean!, $nullStatuses: [COMMENT_STATUS!]) { ${Object.keys(queueConfig).map( - (queue) => ` + (queue) => ` ${queue}: comments(query: { statuses: ${ - queueConfig[queue].statuses - ? `[${queueConfig[queue].statuses.join(', ')}],` - : '$nullStatuses' - } + queueConfig[queue].statuses + ? `[${queueConfig[queue].statuses.join(', ')}],` + : '$nullStatuses' +} ${ - queueConfig[queue].tags - ? `tags: ["${queueConfig[queue].tags.join('", "')}"],` - : '' - } + queueConfig[queue].tags + ? `tags: ["${queueConfig[queue].tags.join('", "')}"],` + : '' +} ${ - queueConfig[queue].action_type - ? `action_type: ${queueConfig[queue].action_type}` - : '' - } + queueConfig[queue].action_type + ? `action_type: ${queueConfig[queue].action_type}` + : '' +} asset_id: $asset_id, sortOrder: $sortOrder, limit: 20, @@ -448,29 +451,29 @@ const withModQueueQuery = withQuery( ...CoralAdmin_Moderation_CommentConnection } ` - )} + )} ${Object.keys(queueConfig).map( - (queue) => ` + (queue) => ` ${queue}Count: commentCount(query: { statuses: ${ - queueConfig[queue].statuses - ? `[${queueConfig[queue].statuses.join(', ')}],` - : '$nullStatuses' - } + queueConfig[queue].statuses + ? `[${queueConfig[queue].statuses.join(', ')}],` + : '$nullStatuses' +} ${ - queueConfig[queue].tags - ? `tags: ["${queueConfig[queue].tags.join('", "')}"],` - : '' - } + queueConfig[queue].tags + ? `tags: ["${queueConfig[queue].tags.join('", "')}"],` + : '' +} ${ - queueConfig[queue].action_type - ? `action_type: ${queueConfig[queue].action_type}` - : '' - } + queueConfig[queue].action_type + ? `action_type: ${queueConfig[queue].action_type}` + : '' +} asset_id: $asset_id, }) ` - )} + )} asset(id: $asset_id) @skip(if: $allAssets) { id title diff --git a/client/coral-embed-stream/src/tabs/stream/containers/Stream.js b/client/coral-embed-stream/src/tabs/stream/containers/Stream.js index 9e37e75d4..781fdcb99 100644 --- a/client/coral-embed-stream/src/tabs/stream/containers/Stream.js +++ b/client/coral-embed-stream/src/tabs/stream/containers/Stream.js @@ -50,6 +50,7 @@ class StreamContainer extends React.Component { assetId: this.props.asset.id, }, updateQuery: (prev, {subscriptionData: {data: {commentEdited}}}) => { + // Ignore mutations from me. // TODO: need way to detect mutations created by this client, and allow mutations from other clients. if ( @@ -82,6 +83,7 @@ class StreamContainer extends React.Component { assetId: this.props.asset.id, }, updateQuery: (prev, {subscriptionData: {data: {commentAdded}}}) => { + // Ignore mutations from me. // TODO: need way to detect mutations created by this client, and allow mutations from other clients. if ( @@ -338,14 +340,14 @@ const fragments = { comment(id: $commentId) @include(if: $hasComment) { ...CoralEmbedStream_Stream_comment ${nest( - ` + ` parent { ...CoralEmbedStream_Stream_comment ...nest } `, - THREADING_LEVEL - )} + THREADING_LEVEL + )} } id title diff --git a/client/coral-framework/services/perms.js b/client/coral-framework/services/perms.js index 86af4a7de..e717b7f35 100644 --- a/client/coral-framework/services/perms.js +++ b/client/coral-framework/services/perms.js @@ -45,6 +45,7 @@ export const can = (user, ...perms) => { } return perms.every((perm) => { + // Basic Permissions const permAction = basicPerms[perm]; if (typeof permAction !== 'undefined') { diff --git a/config.js b/config.js index ce830957c..5eefeba61 100644 --- a/config.js +++ b/config.js @@ -16,6 +16,7 @@ const debug = require('debug')('talk:config'); //============================================================================== const CONFIG = { + // WEBPACK indicates when webpack is currently building. WEBPACK: process.env.WEBPACK === 'TRUE', diff --git a/package.json b/package.json index febd7551d..db421953e 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "@coralproject/graphql-anywhere-optimized": "^0.1.0", "accepts": "^1.3.4", "apollo-client": "^1.9.1", + "apollo-engine": "^0.6.0", "apollo-server-express": "^1.2.0", "apollo-utilities": "^1.0.3", "app-module-path": "^2.2.0", @@ -185,7 +186,6 @@ }, "devDependencies": { "@coralproject/eslint-config-talk": "^0.0.4", - "apollo-engine": "^0.6.0", "babel-jest": "^21.2.0", "babel-plugin-dynamic-import-node": "^1.1.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", diff --git a/services/users.js b/services/users.js index 1a8ea7684..c2307727f 100644 --- a/services/users.js +++ b/services/users.js @@ -48,6 +48,7 @@ const loginRateLimiter = new Limit( // UsersService is the interface for the application to interact with the // UserModel through. class UsersService { + /** * Returns a user (if found) for the given email address. */ @@ -530,6 +531,7 @@ class UsersService { } if (checkAgainstWordlist) { + // check for profanity let err = await Wordlist.usernameCheck(username); if (err) { @@ -639,11 +641,13 @@ class UsersService { * @param {Object} token a jwt token used to sign in the user */ static async findOrCreateByIDToken(id, token) { + // Try to get the user. let user = await UserModel.findOne({id}); // If the user was not found, try to look it up. if (user === null) { + // If the user wasn't found, it will return null and the variable will be // unchanged. user = await lookupUserNotFound(token); @@ -693,6 +697,7 @@ class UsersService { DomainList.urlCheck(loc), ]); if (!user) { + // Since we don't want to reveal that the email does/doesn't exist // just go ahead and resolve the Promise with null and check in the // endpoint. @@ -772,6 +777,7 @@ class UsersService { return UserModel.find({ $or: [ + // Search by a prefix match on the username. { lowercaseUsername: { @@ -973,6 +979,7 @@ class UsersService { module.exports = UsersService; events.on(USERS_BAN_CHANGE, async (user, {status, message}) => { + // Check to see if the user was banned now and is currently banned. if (user.banned && status && message && message.length > 0) { await UsersService.sendEmail(user, { @@ -986,6 +993,7 @@ events.on(USERS_BAN_CHANGE, async (user, {status, message}) => { }); events.on(USERS_SUSPENSION_CHANGE, async (user, {until, message}) => { + // Check to see if the user was suspended now and is currently suspended. if ( user.suspended &&