This commit is contained in:
Wyatt Johnson
2017-12-20 16:11:39 -07:00
parent 97406e1b18
commit ad68346332
7 changed files with 60 additions and 43 deletions
@@ -19,6 +19,7 @@ class PeopleContainer extends React.Component {
onKeyDownHandler = (e) => {
if (e.key === 'Enter') {
e.preventDefault();
// this.fetchUsers();
}
}
@@ -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] &&
@@ -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 <NotFoundAsset assetId={assetId} />;
}
}
if (data.loading) {
// loading.
return <Spinner />;
}
@@ -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
@@ -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
+1
View File
@@ -45,6 +45,7 @@ export const can = (user, ...perms) => {
}
return perms.every((perm) => {
// Basic Permissions
const permAction = basicPerms[perm];
if (typeof permAction !== 'undefined') {
+1
View File
@@ -16,6 +16,7 @@ const debug = require('debug')('talk:config');
//==============================================================================
const CONFIG = {
// WEBPACK indicates when webpack is currently building.
WEBPACK: process.env.WEBPACK === 'TRUE',
+8
View File
@@ -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 &&