<commit_before>import { post } from '../utils/Request';
import { djSelector } from '../selectors/boothSelectors';
import { tokenSelector } from '../selectors/userSelectors';

import {
  SKIP_DJ_START, SKIP_DJ_COMPLETE
} from '../constants/actionTypes/moderation';

export function skipCurrentDJ(reason = '') {
  return (dispatch, getState) => {
    const jwt = tokenSelector(getState());
    const dj = djSelector(getState());
    if (!dj) {
      return;
    }
    const payload = { userID: dj._id, reason };
    dispatch({
      type: SKIP_DJ_START,
      payload
    });
    post(jwt, `/v1/booth/skip`, payload)
      .then(res => res.json())
      .then(() => dispatch({
        type: SKIP_DJ_COMPLETE,
        payload
      }))
      .catch(error => dispatch({
        type: SKIP_DJ_COMPLETE,
        error: true,
        payload: error,
        meta: payload
      }));
  };
}<commit_msg>mod: add actions for deleting chat messages (by id, user, all)<commit_after>import { del, post } from '../utils/Request';
import { djSelector } from '../selectors/boothSelectors';
import { tokenSelector } from '../selectors/userSelectors';

import {
  SKIP_DJ_START, SKIP_DJ_COMPLETE
} from '../constants/actionTypes/moderation';

import {
  removeMessage, removeMessagesByUser, removeAllMessages
} from './ChatActionCreators';

export function skipCurrentDJ(reason = '') {
  return (dispatch, getState) => {
    const jwt = tokenSelector(getState());
    const dj = djSelector(getState());
    if (!dj) {
      return;
    }
    const payload = { userID: dj._id, reason };
    dispatch({
      type: SKIP_DJ_START,
      payload
    });
    post(jwt, `/v1/booth/skip`, payload)
      .then(res => res.json())
      .then(() => dispatch({
        type: SKIP_DJ_COMPLETE,
        payload
      }))
      .catch(error => dispatch({
        type: SKIP_DJ_COMPLETE,
        error: true,
        payload: error,
        meta: payload
      }));
  };
}

export function deleteChatMessage(id) {
  return (dispatch, getState) => {
    const jwt = tokenSelector(getState());
    del(jwt, `/v1/chat/${id}`)
      .then(res => res.json())
      .then(() => dispatch(removeMessage(id)))
      .catch(error => dispatch({
        type: undefined,
        error: true,
        payload: error,
        meta: { id }
      }));
  };
}

export function deleteChatMessagesByUser(userID) {
  return (dispatch, getState) => {
    const jwt = tokenSelector(getState());
    del(jwt, `/v1/chat/user/${userID}`)
      .then(res => res.json())
      .then(() => dispatch(removeMessagesByUser(userID)))
      .catch(error => dispatch({
        type: undefined,
        error: true,
        payload: error,
        meta: { userID }
      }));
  };
}

export function deleteAllChatMessages() {
  return (dispatch, getState) => {
    const jwt = tokenSelector(getState());
    del(jwt, `/v1/chat`)
      .then(res => res.json())
      .then(() => dispatch(removeAllMessages()))
      .catch(error => dispatch({
        type: undefined,
        error: true,
        payload: error
      }));
  };
}
{'fraction_non_alphanumeric': 0.15648480888598498, 'fraction_numerical': 0.001633453119895459, 'mean_word_length': 2.6023529411764708, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3505844', 'n_tokens_mistral': 977, 'n_tokens_neox': 970, 'n_words': 212}