This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit b1bbd56f8c8bf2ad336311d985d802c6d5cdb865 Author: Kevin Morin <morin@codelutin.com> Date: Fri Jun 2 17:39:57 2017 +0200 fixes #14 add the missing events in the feed --- .../pollen/services/service/ChoiceService.java | 1 + .../pollen/services/service/CommentService.java | 3 ++ .../pollen/services/service/FeedService.java | 45 +++++++++++++++++++--- .../pollen/services/service/PollService.java | 3 ++ .../i18n/pollen-services_en_GB.properties | 9 ++++- .../i18n/pollen-services_fr_FR.properties | 7 ++++ 6 files changed, 62 insertions(+), 6 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java index ef396dc0..a35790aa 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java @@ -107,6 +107,7 @@ public class ChoiceService extends PollenServiceSupport { commit(); getNotificationService().onChoiceAdded(poll, result); + getFeedService().onChoiceAdded(poll, result); return PollenEntityRef.of(result); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java index 9631fd69..eb2a2cd1 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java @@ -125,6 +125,7 @@ public class CommentService extends PollenServiceSupport { commit(); getNotificationService().onCommentAdded(poll, result); + getFeedService().onCommentAdded(poll, result); return PollenEntityRef.of(result); @@ -145,6 +146,7 @@ public class CommentService extends PollenServiceSupport { commit(); getNotificationService().onCommentEdited(poll, result); + getFeedService().onCommentEdited(poll, result); return toBean(CommentBean.class, result); @@ -164,6 +166,7 @@ public class CommentService extends PollenServiceSupport { commit(); getNotificationService().onCommentDeleted(poll, comment); + getFeedService().onCommentDeleted(poll, comment); } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/FeedService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/FeedService.java index f6570f63..5f94dcf5 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/FeedService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/FeedService.java @@ -9,6 +9,8 @@ import com.rometools.rome.feed.synd.SyndFeedImpl; import com.rometools.rome.io.FeedException; import com.rometools.rome.io.SyndFeedInput; import com.rometools.rome.io.SyndFeedOutput; +import org.chorem.pollen.persistence.entity.Choice; +import org.chorem.pollen.persistence.entity.Comment; import org.chorem.pollen.persistence.entity.Poll; import org.chorem.pollen.persistence.entity.Vote; import org.chorem.pollen.services.PollenTechnicalException; @@ -18,7 +20,9 @@ import java.io.StringReader; import java.text.DateFormat; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.List; +import java.util.Set; import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; @@ -60,6 +64,22 @@ public class FeedService extends PollenServiceSupport { saveFeed(poll, feed); } + public void onPollEdited(Poll poll, Set<String> newParticipants) { + addFeedEntry(poll, t("pollen.service.feed.pollEdited.title")); + } + + public void onPollClosed(Poll poll) { + addFeedEntry(poll, t("pollen.service.feed.pollClosed.title")); + } + + public void onPollReopened(Poll poll) { + addFeedEntry(poll, t("pollen.service.feed.pollReopened.title")); + } + + public void onChoiceAdded(Poll poll, Choice choice) { + addFeedEntry(poll, t("pollen.service.feed.choiceAdded.title")); + } + public void onVoteAdded(Poll poll, Vote vote) { addVoteFeedEntry(poll, vote, n("pollen.service.feed.voteAdded.title")); } @@ -72,6 +92,18 @@ public class FeedService extends PollenServiceSupport { addVoteFeedEntry(poll, vote, n("pollen.service.feed.voteDeleted.title")); } + public void onCommentAdded(Poll poll, Comment comment) { + addFeedEntry(poll, t("pollen.service.feed.commentAdded.title", comment.getAuthor())); + } + + public void onCommentEdited(Poll poll, Comment comment) { + addFeedEntry(poll, t("pollen.service.feed.commentEdited.title", comment.getAuthor())); + } + + public void onCommentDeleted(Poll poll, Comment comment) { + addFeedEntry(poll, t("pollen.service.feed.commentDeleted.title", comment.getAuthor())); + } + public SyndFeed getFeedForPoll(String pollId) { checkNotNull(pollId); checkPermission(PermissionVerb.readPoll, pollId); @@ -88,20 +120,23 @@ public class FeedService extends PollenServiceSupport { } private void addVoteFeedEntry(Poll poll, Vote vote, String messageKey) { - SyndFeed feed = getFeedForPoll(poll.getTopiaId()); - List<SyndEntry> entries = new ArrayList<>(feed.getEntries()); - String voterName; if (vote.isAnonymous()) { voterName = t("pollen.service.feed.anonymous"); } else { voterName = vote.getVoter().getName(); } + addFeedEntry(poll, t(messageKey, voterName)); + } + + private void addFeedEntry(Poll poll, String title) { + SyndFeed feed = getFeedForPoll(poll.getTopiaId()); + List<SyndEntry> entries = new ArrayList<>(feed.getEntries()); SyndEntry entry = new SyndEntryImpl(); - entry.setTitle(t(messageKey, voterName)); + entry.setTitle(title); entry.setLink(getPollVoteUrl(poll)); - entry.setPublishedDate(vote.getTopiaCreateDate()); + entry.setPublishedDate(new Date()); entries.add(entry); feed.setEntries(entries); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java index 45bf43df..4e572fa9 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java @@ -256,6 +256,7 @@ public class PollService extends PollenServiceSupport { commit(); getNotificationService().onPollEdited(savedPoll, newParticipants); + getFeedService().onPollEdited(savedPoll, newParticipants); return toBean(PollBean.class, savedPoll, pollBeanFunction); @@ -343,6 +344,7 @@ public class PollService extends PollenServiceSupport { commit(); getNotificationService().onPollClosed(poll); + getFeedService().onPollClosed(poll); } @@ -361,6 +363,7 @@ public class PollService extends PollenServiceSupport { commit(); getNotificationService().onPollReopened(poll); + getFeedService().onPollReopened(poll); } diff --git a/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties b/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties index 6293aeb4..7b86cbd5 100644 --- a/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties +++ b/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties @@ -102,9 +102,16 @@ pollen.error.voterList.member.weight.greaterThan0=member weight must be greater pollen.error.voterList.name.alreadyUsed=voterList name already used pollen.error.voterList.name.mandatory=voterList name can not be empty pollen.error.voterList.weight.greaterThan0=voterList weight must be greater than 0 -pollen.service.feed.anonymous= +pollen.service.feed.anonymous=Someone +pollen.service.feed.choiceAdded.title=A choice has been added to the poll +pollen.service.feed.commentAdded.title=A new comment has been published +pollen.service.feed.commentDeleted.title=A comment has been deleted +pollen.service.feed.commentEdited.title=A comment has been edited +pollen.service.feed.pollClosed.title=The poll is closed pollen.service.feed.pollCreated.description=On the %s, %s created the poll "%s". pollen.service.feed.pollCreated.title=%s created the poll "%s" +pollen.service.feed.pollEdited.title=The poll has been edited +pollen.service.feed.pollReopened.title=The poll has been reopened pollen.service.feed.voteAdded.title=%s voted pollen.service.feed.voteDeleted.title=%s deleted his vote pollen.service.feed.voteEdited.title=%s edited his vote diff --git a/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties b/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties index 5189223c..7d57b9bd 100644 --- a/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties +++ b/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties @@ -102,8 +102,15 @@ pollen.error.voterList.name.alreadyUsed=Le nom de la liste de votant existe déj pollen.error.voterList.name.mandatory=Nom de la liste de votant est obligatoire pollen.error.voterList.weight.greaterThan0=Poid de la liste de votant doit être supérieur à 0 pollen.service.feed.anonymous=Quelqu'un +pollen.service.feed.choiceAdded.title=Un choix a été ajouté au sondage +pollen.service.feed.commentAdded.title=Un nouveau commentaire a été publié +pollen.service.feed.commentDeleted.title=Un commentaire a été supprimé +pollen.service.feed.commentEdited.title=Un commentaire a été modifié +pollen.service.feed.pollClosed.title=Le sondage est clos pollen.service.feed.pollCreated.description=Le %s, %s a créé le sondage %s. pollen.service.feed.pollCreated.title=%s a créé le sondage "%s" +pollen.service.feed.pollEdited.title=Le sondage a été modifié +pollen.service.feed.pollReopened.title=Le sondage a été réouvert pollen.service.feed.voteAdded.title=%s a voté pollen.service.feed.voteDeleted.title=%s a supprimé son vote pollen.service.feed.voteEdited.title=%s a modifié son vote -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.