Implantação da geração de mensagem de forma livre e mudança na engine de mensagem

This commit is contained in:
2026-08-24 17:32:16 -03:00
parent 94bbe7556f
commit 88f19dd8f5
77 changed files with 4650 additions and 25 deletions

View File

@@ -0,0 +1,22 @@
# app/models/grupo_evento_assinatura.rb
#
# "O grupo X recebe o evento Y por WhatsApp/e-mail/ambos."
class GrupoEventoAssinatura < ApplicationRecord
CANAIS = %w[ambos whatsapp email].freeze
CANAL_LABEL = { 'ambos' => 'WhatsApp e e-mail', 'whatsapp' => 'Só WhatsApp', 'email' => 'Só e-mail' }.freeze
belongs_to :grupo_contato
belongs_to :evento_notificacao
validates :canal, inclusion: { in: CANAIS }
validates :grupo_contato_id, uniqueness: { scope: :evento_notificacao_id,
message: 'já assina este evento' }
scope :ativas, -> { where(ativo: true) }
def cobre_canal?(canal)
self.canal == 'ambos' || self.canal == canal.to_s
end
def canal_label = CANAL_LABEL[canal] || canal
end