@@ -9,6 +9,7 @@ export type PressureAction = {
99 targets_id ?: string
1010 email_subject ?: string
1111 email_body ?: string
12+ subject_list ?: string [ ]
1213 token : string
1314 form_data ?: any
1415}
@@ -63,6 +64,7 @@ export const create_email_pressure = async ({ widget, activist, action }: IBaseA
6364 pressure_subject : pressureSubject ,
6465 pressure_body : pressureBody ,
6566 pressure_type : pressureType ,
67+ subject_list : subjectList ,
6668 batch_limit = 100 ,
6769 mail_limit = 1000 ,
6870 optimization_enabled = true
@@ -122,6 +124,17 @@ export const create_email_pressure = async ({ widget, activist, action }: IBaseA
122124 form_data
123125 }
124126
127+ // FUNÇÃO AUXILIAR PARA OBTER O ASSUNTO
128+ const getEmailSubject = ( ) : string => {
129+ if ( subjectList && subjectList . length > 0 ) {
130+ const randomIndex = Math . floor ( Math . random ( ) * subjectList . length ) ;
131+ return subjectList [ randomIndex ] ;
132+ }
133+
134+ // Fallback para o assunto único
135+ return emailSubject || group ?. email_subject || pressureSubject ;
136+ } ;
137+
125138 if ( optimization_enabled ) {
126139 // Pressão otimizado foi habilitada
127140 const pressureInfo = await ActionsAPI . get_pressure_info ( widget . id ) ;
@@ -169,7 +182,7 @@ export const create_email_pressure = async ({ widget, activist, action }: IBaseA
169182 activist,
170183 targets,
171184 emailBody : optimziedBody ,
172- emailSubject : group ?. email_subject || pressureSubject ,
185+ emailSubject : getEmailSubject ( ) ,
173186 } ) ;
174187
175188 logger . child ( { id, created_at } ) . info ( 'ActionsAPI' ) ;
@@ -208,7 +221,7 @@ export const create_email_pressure = async ({ widget, activist, action }: IBaseA
208221 activist,
209222 targets,
210223 emailBody : emailBody || group ?. email_body || pressureBody ,
211- emailSubject : emailSubject || group ?. email_subject || pressureSubject
224+ emailSubject : getEmailSubject ( )
212225 } ) ;
213226 // Cria a pressão na base de dados
214227 const { id, created_at } = await ActionsAPI . pressure ( {
0 commit comments