<commit_before># == Schema Information
# Schema version: 20131024114346
#
# Table name: outgoing_messages
#
#  id                           :integer          not null, primary key
#  info_request_id              :integer          not null
#  body                         :text             not null
#  status                       :string(255)      not null
#  message_type                 :string(255)      not null
#  created_at                   :datetime         not null
#  updated_at                   :datetime         not null
#  last_sent_at                 :datetime
#  incoming_message_followup_id :integer
#  what_doing                   :string(255)      not null
#  prominence                   :string(255)      default("normal"), not null
#  prominence_reason            :text
#

# models/outgoing_message.rb:
# A message, associated with a request, from the user of the site to somebody
# else. e.g. An initial request for information, or a complaint.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: <EMAIL>; WWW: http://www.mysociety.org/

class OutgoingMessage < ActiveRecord::Base
    extend MessageProminence
    include Rails.application.routes.url_helpers
    include LinkToHelper

    # To override the default letter
    attr_accessor :default_letter

    validates_presence_of :info_request
    validates_inclusion_of :status, :in => ['ready', 'sent', 'failed']
    validates_inclusion_of :message_type, :in => ['initial_request', 'followup']
    validate :format_of_body

    belongs_to :info_request
    belongs_to :incoming_message_followup, :foreign_key => 'incoming_message_followup_id', :class_name => 'IncomingMessage'

    # can have many events, for items which were resent by site admin e.g. if
    # contact address changed
    has_many :info_request_events

    after_initialize :set_default_letter
    after_save :purge_in_cache
    # reindex if body text is edited (e.g. by admin interface)
    after_update :xapian_reindex_after_update

    strip_attributes!
    has_prominence

    self.default_url_options[:host] = AlaveteliConfiguration::domain

    # https links in emails if forcing SSL
    if AlaveteliConfiguration::force_ssl
      self.default_url_options[:protocol] = "https"
    end

    def self.default_salutation(public_body)
        _("Dear {{public_body_name}},", :public_body_name => public_body.name)
    end

    def self.placeholder_salutation
        _("Dear [Authority name],")
    end

    def self.fill_in_salutation(body, public_body)<commit_msg>Use dot rather than colon for method call<commit_after># == Schema Information
# Schema version: 20131024114346
#
# Table name: outgoing_messages
#
#  id                           :integer          not null, primary key
#  info_request_id              :integer          not null
#  body                         :text             not null
#  status                       :string(255)      not null
#  message_type                 :string(255)      not null
#  created_at                   :datetime         not null
#  updated_at                   :datetime         not null
#  last_sent_at                 :datetime
#  incoming_message_followup_id :integer
#  what_doing                   :string(255)      not null
#  prominence                   :string(255)      default("normal"), not null
#  prominence_reason            :text
#

# models/outgoing_message.rb:
# A message, associated with a request, from the user of the site to somebody
# else. e.g. An initial request for information, or a complaint.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: <EMAIL>; WWW: http://www.mysociety.org/

class OutgoingMessage < ActiveRecord::Base
    extend MessageProminence
    include Rails.application.routes.url_helpers
    include LinkToHelper

    # To override the default letter
    attr_accessor :default_letter

    validates_presence_of :info_request
    validates_inclusion_of :status, :in => ['ready', 'sent', 'failed']
    validates_inclusion_of :message_type, :in => ['initial_request', 'followup']
    validate :format_of_body

    belongs_to :info_request
    belongs_to :incoming_message_followup, :foreign_key => 'incoming_message_followup_id', :class_name => 'IncomingMessage'

    # can have many events, for items which were resent by site admin e.g. if
    # contact address changed
    has_many :info_request_events

    after_initialize :set_default_letter
    after_save :purge_in_cache
    # reindex if body text is edited (e.g. by admin interface)
    after_update :xapian_reindex_after_update

    strip_attributes!
    has_prominence

    self.default_url_options[:host] = AlaveteliConfiguration.domain

    # https links in emails if forcing SSL
    if AlaveteliConfiguration::force_ssl
      self.default_url_options[:protocol] = "https"
    end

    def self.default_salutation(public_body)
        _("Dear {{public_body_name}},", :public_body_name => public_body.name)
    end

    def self.placeholder_salutation
        _("Dear [Authority name],")
    end

    def self.fill_in_salutation(body, public_body)
{'fraction_non_alphanumeric': 0.07563025210084033, 'fraction_numerical': 0.01172562048075044, 'mean_word_length': 2.6846652267818576, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5370595', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1430, 'n_words': 404}