Search in sources :

Example 1 with WantToContributeNotification

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);
}
Also used : WantToContributeNotification(org.collectiveone.modules.activity.WantToContributeNotification) PostResult(org.collectiveone.common.dto.PostResult) DecisionMaker(org.collectiveone.modules.governance.DecisionMaker) AppUser(org.collectiveone.modules.users.AppUser) Transactional(javax.transaction.Transactional)

Aggregations

Transactional (javax.transaction.Transactional)1 PostResult (org.collectiveone.common.dto.PostResult)1 WantToContributeNotification (org.collectiveone.modules.activity.WantToContributeNotification)1 DecisionMaker (org.collectiveone.modules.governance.DecisionMaker)1 AppUser (org.collectiveone.modules.users.AppUser)1