<commit_before>import MsgCtrl from './ctrl';
import { MsgData, Contact, User, Msg, Convo, SearchResult } from './interfaces';

const headers: HeadersInit = {
  'Accept': 'application/vnd.lichess.v5+json'
};
const cache: RequestCache = 'no-cache';

export function loadConvo(userId: string): Promise<MsgData> {
  return fetch(`/inbox/${userId}`, { headers, cache })
    .then(httpResponse)
    .then(upgradeData);
}

export function loadContacts(): Promise<MsgData> {
  return fetch(`/inbox`, { headers, cache })
    .then(httpResponse)
    .then(upgradeData);
}

export function search(q: string): Promise<SearchResult> {
  return fetch(`/inbox/search?q=${q}`)
    .then(httpResponse)
    .then(res => ({
      ...res,
      contacts: res.contacts.map(upgradeContact)
    } as SearchResult));
}

export function block(u: string) {
  return fetch(`/rel/block/${u}`, {
    method: 'post',
    headers
  });
}

export function unblock(u: string) {
  return fetch(`/rel/unblock/${u}`, {
    method: 'post',
    headers
  });
}

export function del(u: string): Promise<MsgData> {
  return fetch(`/inbox/${u}`, {
    method: 'delete',
    headers
  })
    .then(httpResponse)
    .then(upgradeData);
}

export function report(name: string, text: string): Promise<any> {
  const formData = new FormData()
  formData.append('username', name);
  formData.append('text', text);
  formData.append('resource', 'msg');
  return fetch('/report/flag', {
    method: 'post',
    headers,
    body: formData
  });
}

export function post(dest: string, text: string) {
  window.lichess.pubsub.emit('socket.send', 'msgSend', { dest, text });
}
<commit_msg>manually set fetch credentials for safari 10<commit_after>import MsgCtrl from './ctrl';
import { MsgData, Contact, User, Msg, Convo, SearchResult } from './interfaces';

const headers: HeadersInit = {
  'Accept': 'application/vnd.lichess.v5+json'
};
const cache: RequestCache = 'no-cache';
const credentials = 'same-origin';

export function loadConvo(userId: string): Promise<MsgData> {
  return fetch(`/inbox/${userId}`, { headers, cache, credentials })
    .then(httpResponse)
    .then(upgradeData);
}

export function loadContacts(): Promise<MsgData> {
  return fetch(`/inbox`, { headers, cache, credentials })
    .then(httpResponse)
    .then(upgradeData);
}

export function search(q: string): Promise<SearchResult> {
  return fetch(`/inbox/search?q=${q}`, { credentials })
    .then(httpResponse)
    .then(res => ({
      ...res,
      contacts: res.contacts.map(upgradeContact)
    } as SearchResult));
}

export function block(u: string) {
  return fetch(`/rel/block/${u}`, {
    method: 'post',
    headers,
    credentials
  });
}

export function unblock(u: string) {
  return fetch(`/rel/unblock/${u}`, {
    method: 'post',
    headers,
    credentials
  });
}

export function del(u: string): Promise<MsgData> {
  return fetch(`/inbox/${u}`, {
    method: 'delete',
    headers,
    credentials
  })
    .then(httpResponse)
    .then(upgradeData);
}

export function report(name: string, text: string): Promise<any> {
  const formData = new FormData()
  formData.append('username', name);
  formData.append('text', text);
  formData.append('resource', 'msg');
  return fetch('/report/flag', {
    method: 'post',
    headers,
    credentials,
    body: formData
  });
}

export function post(dest: string, text: string) {
  window.lichess.pubsub.emit('socket.send', 'msgSend', { dest, text });
}

{'fraction_non_alphanumeric': 0.16864676905244858, 'fraction_numerical': 0.0011590843233845263, 'mean_word_length': 3.938483547925608, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '5862528', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1134, 'n_words': 258}