<commit_before>$_ = require 'underscore'

#=====================================================================

# Generates method to delete objects.
do ->
  types = [
    'message'
    'task'
  ]
  $_.each types, (type) ->
    exports["#{type}.destroy"] = (session, request) ->
      {id} = request.params
      @throw 'INVALID_PARAMS' unless id?

      # FIXME: For now, the current user must be an administrator, but
      # eventually, the user only need to have the “write” permission
      # over the object linked to the message or task.
      @checkPermission session, 'admin'

      # Retrieves the object.
      object = @xo.objects.get id
      @throw 'NO_SUCH_OBJECT' unless object?

      # Gets the corresponding connection.
      xapi = @xo.xapis[object.$pool]
      xapi.call "#{type}.destroy", object.$ref

      # Returns true.
      true<commit_msg>Minor fixes.<commit_after>$_ = require 'underscore'

#=====================================================================

# Generates method to delete objects.
do ->
  types = [
    'message'
    'task'
  ]
  $_.each types, (type) ->
    exports[type] ?= {}
    exports[type].destroy = (session, request) ->
      {id} = request.params
      @throw 'INVALID_PARAMS' unless id?

      # FIXME: For now, the current user must be an administrator, but
      # eventually, the user only need to have the “write” permission
      # over the object linked to the message or task.
      @checkPermission session, 'admin'

      # Retrieves the object.
      object = @xo.xobjs.get id
      @throw 'NO_SUCH_OBJECT' unless object?

      # Gets the corresponding connection.
      xapi = @xo.xapis[object.$pool]
      xapi.call "#{type}.destroy", object.$ref

      # Returns true.
      true
{'fraction_non_alphanumeric': 0.1856492027334852, 'fraction_numerical': 0.0, 'mean_word_length': 2.8530701754385963, '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': '2979941', 'n_tokens_mistral': 513, 'n_tokens_neox': 494, 'n_words': 159}