<commit_before>import { isEmpty, mapKeys, pick, snakeCase, size, trim } from 'lodash'
import underlyingFindOrCreateThread, {
  validateThreadData
} from '../../models/post/findOrCreateThread'
import underlyingFindLinkPreview from '../../models/linkPreview/findOrCreateByUrl'
import convertGraphqlData from './convertGraphqlData'

export {
  createAffiliation,
  deleteAffiliation
} from './affiliation'
export {
  createComment,
  createMessage,
  deleteComment,
  canDeleteComment,
  updateComment,
  canUpdateComment
} from './comment'
export {
  findOrCreateLocation
} from './location'
export {
  addCommunityToNetwork,
  addNetworkModeratorRole,
  removeCommunityFromNetwork,
  removeNetworkModeratorRole,
  updateCommunityHiddenSetting,
  updateNetwork
} from './network'
export { registerDevice } from './mobile'
export {
  createTopic,
  subscribe
} from './topic'
export {
  createInvitation,
  expireInvitation,
  resendInvitation,
  reinviteAll,
  useInvitation
} from './invitation'
export {
  acceptJoinRequest,
  createJoinRequest,
  declineJoinRequest,
  joinCommunity,
} from './join_request'
export {
  updateCommunity,
  addModerator,
  deleteCommunityTopic,
  deleteCommunity,
  removeModerator,
  removeMember,
  regenerateAccessCode,
  createCommunity
} from './community'
export {
  createPost,
  fulfillPost,
  unfulfillPost,
  updatePost,
  vote,
  deletePost,
  pinPost
} from './post'
export {
  createProject,
  createProjectRole,
  deleteProjectRole,
  addPeopleToProjectRole,
  joinProject,
  leaveProject,
  processStripeToken
} from './project'
export {
  respondToEvent,
  invitePeopleToEvent
} from './event'
export {
  blockUser,
  unblockUser,
  updateStripeAccount,
  registerStripeAccount
} from './user'
export { updateMembership } from './membership'
export { deleteSavedSearch, createSavedSearch } from './savedSearch'

export function updateMe (userId, changes) {
  return User.find(userId)
  .then(user => user.validateAndSave(convertGraphqlData(changes)))
}

export function allowCommunityInvites (communityId, data) {
  return Community.query().where('id', communityId).update({allow_community_invites: data})
  .then(() => ({success: true}))
}

export async function leaveCommunity (userId, communityId) {
  const community = await Community.find(communityId)
  const user = await User.find(userId)
  return user.leaveCommunity(community)
}

export function findOrCreateThread (userId, data) {
  return validateThreadData(userId, data)
  .then(() => underlyingFindOrCreateThread(userId, data.participantIds))
}
<commit_msg>return communityId after leaving community<commit_after>import { isEmpty, mapKeys, pick, snakeCase, size, trim } from 'lodash'
import underlyingFindOrCreateThread, {
  validateThreadData
} from '../../models/post/findOrCreateThread'
import underlyingFindLinkPreview from '../../models/linkPreview/findOrCreateByUrl'
import convertGraphqlData from './convertGraphqlData'

export {
  createAffiliation,
  deleteAffiliation
} from './affiliation'
export {
  createComment,
  createMessage,
  deleteComment,
  canDeleteComment,
  updateComment,
  canUpdateComment
} from './comment'
export {
  findOrCreateLocation
} from './location'
export {
  addCommunityToNetwork,
  addNetworkModeratorRole,
  removeCommunityFromNetwork,
  removeNetworkModeratorRole,
  updateCommunityHiddenSetting,
  updateNetwork
} from './network'
export { registerDevice } from './mobile'
export {
  createTopic,
  subscribe
} from './topic'
export {
  createInvitation,
  expireInvitation,
  resendInvitation,
  reinviteAll,
  useInvitation
} from './invitation'
export {
  acceptJoinRequest,
  createJoinRequest,
  declineJoinRequest,
  joinCommunity,
} from './join_request'
export {
  updateCommunity,
  addModerator,
  deleteCommunityTopic,
  deleteCommunity,
  removeModerator,
  removeMember,
  regenerateAccessCode,
  createCommunity
} from './community'
export {
  createPost,
  fulfillPost,
  unfulfillPost,
  updatePost,
  vote,
  deletePost,
  pinPost
} from './post'
export {
  createProject,
  createProjectRole,
  deleteProjectRole,
  addPeopleToProjectRole,
  joinProject,
  leaveProject,
  processStripeToken
} from './project'
export {
  respondToEvent,
  invitePeopleToEvent
} from './event'
export {
  blockUser,
  unblockUser,
  updateStripeAccount,
  registerStripeAccount
} from './user'
export { updateMembership } from './membership'
export { deleteSavedSearch, createSavedSearch } from './savedSearch'

export function updateMe (userId, changes) {
  return User.find(userId)
  .then(user => user.validateAndSave(convertGraphqlData(changes)))
}

export function allowCommunityInvites (communityId, data) {
  return Community.query().where('id', communityId).update({allow_community_invites: data})
  .then(() => ({success: true}))
}

export async function leaveCommunity (userId, communityId) {
  const community = await Community.find(communityId)
  const user = await User.find(userId)
  await user.leaveCommunity(community)
  return communityId
}

export function findOrCreateThread (userId, data) {
  return validateThreadData(userId, data)
  .then(() => underlyingFindOrCreateThread(userId, data.participantIds))
}

{'fraction_non_alphanumeric': 0.09951783992285439, 'fraction_numerical': 0.0, 'mean_word_length': 5.210778443113773, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3602637', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1539, 'n_words': 352}