<commit_before># TODO #1: Add MAIL_URL to the settings.json file.
#
# TODO #2: Let's initialize this global variable in some other place.
# TODO #2: This file is only for server-side methods.
Meteor.startup () ->
  process.env.MAIL_URL = Meteor.settings["mail_url"]

Meteor.methods
  sendCompanyEmail: (doc) ->
    check doc, schemas.Invitation
    @unblock()
    doc.emails.forEach (item) =>
      # TODO #4: It would be good make it in a bit more asynchronous way ;)
      # TODO #4: We could add callback into the insert function.
      # TODO #4: In this callback we should send email if there wasn't errors.
      invitationId = Invitations.insert
        companyId: doc.companyId
        message: doc.message or ""
        emails: [item]
      Email.send
        to: item
        # TODO #3: Make this option configurable as well.
        from: '<EMAIL>'
        subject: 'Invitation to ' + doc.companyId
        text: "#{Meteor.absoluteUrl()}invite/#{invitationId}"

  invitationStatus: (id) ->
    check id, String<commit_msg>some changes in sending email method<commit_after># TODO #1: Add MAIL_URL to the settings.json file.
#
# TODO #2: Let's initialize this global variable in some other place.
# TODO #2: This file is only for server-side methods.
Meteor.startup () ->
  process.env.MAIL_URL = Meteor.settings["mail_url"]

Meteor.methods
  sendCompanyEmail: (doc) ->
    check doc, schemas.Invitation
    @unblock()
    doc.emails.forEach (item) =>
      Invitations.insert {
          companyId: doc.companyId
          message: doc.message or ""
          emails: [item]
        }, (err, res) ->
              if err
                console.log err
              else
                Email.send
                  to: item
                # TODO #3: Make this option configurable as well.
                  from: '<EMAIL>'
                  subject: 'Invitation to ' + doc.companyId
                  text: """You were invited to company (there is will be company name in future)\n
                        Please follow this link #{Meteor.absoluteUrl()}invite/#{res} to accept invitation.\n
                        If you don't want to accept this invitation, just ignore it!.\n
                        Please, do not reply on this message!"""

  invitationStatus: (id) ->
    check id, String
{'fraction_non_alphanumeric': 0.09887250650477017, 'fraction_numerical': 0.004770164787510842, 'mean_word_length': 2.16027397260274, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, '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': '4088220', 'n_tokens_mistral': 658, 'n_tokens_neox': 639, 'n_words': 233}