Sha256: e0081fe352491ec93bc6772e0a767ae33ea85b7fb1df700fe7b595dd2c301e79

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

##
## 2023-03-04 _vp_ When I receive one.
##
class Office::EmailFilter
  include Mongoid::Document
  include Mongoid::Timestamps

  field :from_regex
  field :from_exact
  field :subject_regex
  field :subject_exact
  field :body_regex
  field :body_exact

  KIND_AUTORESPOND      = 'autorespond' # @deprecated, DO NOT USE!
  KIND_AUTORESPOND_TMPL = 'autorespond-template'
  KIND_AUTORESPOND_EACT = 'autorespond-email-action'
  KIND_REMOVE_TAG  = 'remove-tag'
  KIND_ADD_TAG     = 'add-tag'
  KIND_DELETE      = 'delete' # @obsolete, use add-tag
  KIND_SKIP_INBOX  = 'skip-inbox' # @obsolete, use remove-tag

  KINDS = [ nil, KIND_AUTORESPOND_TMPL, KIND_AUTORESPOND_EACT, KIND_SKIP_INBOX, KIND_ADD_TAG, KIND_REMOVE_TAG]
  field :kind

  STATE_ACTIVE   = 'active'
  STATE_INACTIVE = 'inactive'
  STATES = [ STATE_ACTIVE, STATE_INACTIVE ]
  field :state, type: :string, default: STATE_ACTIVE
  scope :active, ->{ where( state: STATE_ACTIVE ) }

  belongs_to :email_template, class_name: 'Ish::EmailTemplate', optional: true
  belongs_to :email_action,   class_name: 'Office::EmailAction', optional: true

  field :wp_term_id, type: :integer
  def category
    self.wp_term_id && WpTag.find( self.wp_term_id )
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ish_models-0.0.33.248 lib/office/email_filter.rb