use of org.collectiveone.modules.activity.WantToContributeNotification in project CollectiveOneWebapp by CollectiveOne.
the class InitiativeService method wantToContribute.
@Transactional
public PostResult wantToContribute(UUID initiativeId, UUID userId) {
Initiative initiative = initiativeRepository.findById(initiativeId);
AppUser user = appUserRepository.findByC1Id(userId);
List<DecisionMaker> admins = decisionMakerRepository.findByGovernance_IdAndRole(initiative.getGovernance().getId(), DecisionMakerRole.ADMIN);
for (DecisionMaker admin : admins) {
WantToContributeNotification notification = new WantToContributeNotification();
notification.setInitiative(initiative);
notification.setAdmin(admin.getUser());
notification.setUser(user);
notification.setEmailState(NotificationEmailState.PENDING);
wantToContributeRepository.save(notification);
}
return new PostResult("success", "notifications recorded for sending", null);
}
Aggregations