Class ModeratorNotificationService

java.lang.Object
edu.ucsb.cs156.dining.services.ModeratorNotificationService

@Service public class ModeratorNotificationService extends Object
Emails all moderators when a review needs moderation.

The email is sent through the Gmail API from the Google account of the logged-in user who submitted the review, using the OAuth access token they got when they logged in. This requires the gmail.send scope (see docs/oauth.md).

Sending is best effort: every failure is logged, and notifyModerators(Review) never throws, so a problem with email can never stop a review from being saved.

  • Field Details

  • Constructor Details

    • ModeratorNotificationService

      public ModeratorNotificationService(org.springframework.security.oauth2.client.OAuth2AuthorizedClientService authorizedClientService, ModeratorRepository moderatorRepository, org.springframework.boot.web.client.RestTemplateBuilder restTemplateBuilder)
  • Method Details

    • notifyModerators

      public void notifyModerators(Review review)
      Emails every moderator that the given review is waiting for moderation. Never throws.
      Parameters:
      review - the review that needs moderation