Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eaa87e0
commit bed4d6c
Showing
4 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
grails-app/services/deep/dive/SendEmailScheduleService.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package deep.dive | ||
|
||
import groovy.util.logging.Slf4j | ||
import org.springframework.scheduling.annotation.Scheduled | ||
|
||
@Slf4j | ||
class SendEmailScheduleService { | ||
|
||
static lazyInit = false | ||
|
||
SubscriberEntityDataService subscriberEntityDataService | ||
EmailService emailService | ||
|
||
@Scheduled(cron = "0 0/1 * * * ?") | ||
void sendEmailNewsletters() { | ||
List<SubscriberEntity> subscribers = subscriberEntityDataService.findAllByVerified(true, [:]) | ||
|
||
log.info("Sending newsletter to {} verified subscribers", subscribers.size()) | ||
|
||
subscribers.each { subscriber -> | ||
emailService.sendEmail(subscriber.email, EmailType.NEWSLETTER) | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters