use of org.collectiveone.modules.users.AppUser 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);
}
use of org.collectiveone.modules.users.AppUser in project CollectiveOneWebapp by CollectiveOne.
the class InitiativeService method createNewToken.
@Transactional
public PostResult createNewToken(UUID initiativeId, AssetsDto tokenDto, UUID userId) {
Initiative initiative = initiativeRepository.findById(initiativeId);
TokenType token = tokenService.create(tokenDto.getAssetName(), "T");
initiative.getTokenTypes().add(token);
initiative = initiativeRepository.save(initiative);
tokenService.mintToHolder(token.getId(), initiative.getId(), tokenDto.getOwnedByThisHolder(), TokenHolderType.INITIATIVE);
AppUser orderedBy = appUserRepository.findByC1Id(userId);
TokenMint mint = new TokenMint();
mint.setToken(token);
mint.setOrderedBy(orderedBy);
mint.setToHolder(initiativeId);
mint.setMotive("Token creation.");
mint.setNotes("");
mint.setValue(tokenDto.getOwnedByThisHolder());
mint = tokenMintRespository.save(mint);
activityService.newTokenCreated(initiative, orderedBy, token, mint);
return new PostResult("success", "initiative created and tokens created", initiative.getId().toString());
}
use of org.collectiveone.modules.users.AppUser in project CollectiveOneWebapp by CollectiveOne.
the class MessageService method postMessage.
@Transactional
public PostResult postMessage(MessageDto messageDto, UUID authorId, MessageThreadContextType contextType, UUID elementId) {
AppUser author = appUserRepository.findByC1Id(authorId);
Message message = messageDto.toEntity(messageDto, author);
message = messageRepository.save(message);
MessageThread thread = getOrCreateThreadFromElementId(contextType, elementId);
thread.getMessages().add(message);
message.setThread(thread);
message = messageRepository.save(message);
thread = messageThreadRepository.save(thread);
activityService.messagePosted(message, author, contextType, elementId);
return new PostResult("success", "message posted", message.getId().toString());
}
use of org.collectiveone.modules.users.AppUser in project CollectiveOneWebapp by CollectiveOne.
the class TokenTransferService method transferFromInitiativeToUser.
@Transactional
public PostResult transferFromInitiativeToUser(UUID initiativeId, UUID receiverId, UUID assetId, double value) {
AppUser receiver = appUserRepository.findByC1Id(receiverId);
TokenType tokenType = tokenService.getTokenType(assetId);
String result = tokenService.transfer(tokenType.getId(), initiativeId, receiver.getC1Id(), value, TokenHolderType.USER);
if (result.equals("success")) {
/* register the transfer to the contributor */
Member member = initiativeService.getOrAddMember(initiativeId, receiver.getC1Id());
MemberTransfer thisTransfer = new MemberTransfer();
thisTransfer.setMember(member);
thisTransfer.setTokenType(tokenType);
thisTransfer.setValue(value);
thisTransfer.setStatus(MemberTransferStatus.DONE);
thisTransfer = memberTransferRepository.save(thisTransfer);
member.getTokensTransfers().add(thisTransfer);
memberRepository.save(member);
return new PostResult("success", "assets transferred successfully", thisTransfer.getId().toString());
} else {
return new PostResult("error", "error transferring assets: " + result, "");
}
}
use of org.collectiveone.modules.users.AppUser in project CollectiveOneWebapp by CollectiveOne.
the class TokenTransferService method mintToInitiative.
@Transactional
public String mintToInitiative(UUID tokenId, UUID initiativeId, UUID orderByUserId, TokenMintDto mintDto) {
String result = tokenService.mintToHolder(tokenId, initiativeId, mintDto.getValue(), TokenHolderType.INITIATIVE);
if (result.equals("success")) {
AppUser orderedBy = appUserRepository.findByC1Id(orderByUserId);
TokenMint mint = new TokenMint();
mint.setToken(tokenService.getTokenType(tokenId));
mint.setOrderedBy(orderedBy);
mint.setToHolder(initiativeId);
mint.setMotive(mintDto.getMotive());
mint.setNotes(mintDto.getNotes());
mint.setValue(mintDto.getValue());
mint = tokenMintRespository.save(mint);
activityService.tokensMinted(initiativeRepository.findById(initiativeId), mint);
}
return result;
}
Aggregations