Esempio n. 1
0
  rejectUsername = async ({ reason, message }) => {
    const {
      postFlag,
      rejectUsername,
      hideRejectUsernameDialog,
      userId,
    } = this.props;

    // First flag the user.
    try {
      await postFlag({
        item_id: userId,
        item_type: 'USERS',
        reason,
        message,
      });
    } catch (error) {
      // Ignore already exists error, otherwise show error.
      if (
        error.errors &&
        (error.errors.length !== 1 ||
          error.errors[0].translation_key !== 'ALREADY_EXISTS')
      ) {
        notify('error', getErrorMessages(error));
      }
    }

    await rejectUsername(userId);
    hideRejectUsernameDialog();
  };
Esempio n. 2
0
 suspendUser = async ({ message, until }) => {
   const {
     userId,
     username,
     commentStatus,
     commentId,
     hideSuspendUserDialog,
     setCommentStatus,
     suspendUser,
     notify,
   } = this.props;
   hideSuspendUserDialog();
   await suspendUser({ id: userId, message, until });
   notify(
     'success',
     t('suspenduser.notify_suspend_until', username, timeago(until))
   );
   if (commentId && commentStatus && commentStatus !== 'REJECTED') {
     await setCommentStatus({ commentId, status: 'REJECTED' });
   }
 };
Esempio n. 3
0
      deleteReaction = () => {
        if (this.duringMutation) {
          return;
        }
        this.duringMutation = true;

        // If the current user is suspended, do nothing.
        if (!can(this.props.user, 'INTERACT_WITH_COMMUNITY')) {
          notify('error', t('error.NOT_AUTHORIZED'));
          return;
        }

        return this.props
          .deleteReaction(this.props.comment)
          .then(result => {
            this.duringMutation = false;
            return result;
          })
          .catch(err => {
            this.duringMutation = false;
            throw err;
          });
      };
Esempio n. 4
0
 notifyErrors(messages) {
   this.context.store.dispatch(notify('error', messages));
 }