use of org.moera.node.model.event.StoryAddedEvent in project moera-node by MoeraOrg.
the class CommentInstants method addingFailed.
public void addingFailed(String postingId, PostingInfo postingInfo) {
String postingOwnerName = postingInfo != null ? postingInfo.getOwnerName() : "";
String postingOwnerFullName = postingInfo != null ? postingInfo.getOwnerFullName() : null;
AvatarImage postingOwnerAvatar = postingInfo != null ? postingInfo.getOwnerAvatar() : null;
String postingHeading = postingInfo != null ? postingInfo.getHeading() : "";
Story story = new Story(UUID.randomUUID(), nodeId(), StoryType.COMMENT_POST_TASK_FAILED);
story.setFeedName(Feed.INSTANT);
story.setRemoteNodeName(postingOwnerName);
story.setRemoteFullName(postingOwnerFullName);
if (postingOwnerAvatar != null) {
story.setRemoteOwnerAvatarMediaFile(postingOwnerAvatar.getMediaFile());
story.setRemoteOwnerAvatarShape(postingOwnerAvatar.getShape());
}
story.setRemotePostingId(postingId);
story.setSummary(buildAddingFailedSummary(postingOwnerName, postingOwnerFullName, postingHeading));
story.setPublishedAt(Util.now());
updateMoment(story);
story = storyRepository.save(story);
send(new StoryAddedEvent(story, true));
sendPush(story);
feedStatusUpdated();
}
use of org.moera.node.model.event.StoryAddedEvent in project moera-node by MoeraOrg.
the class CommentMediaReactionInstants method updated.
private void updated(Story story, boolean isNew, boolean isAdded) {
List<Story> stories = story.getSubstories().stream().sorted(Comparator.comparing(Story::getCreatedAt).reversed()).collect(Collectors.toList());
if (stories.size() == 0) {
storyRepository.delete(story);
if (!isNew) {
send(new StoryDeletedEvent(story, true));
}
deletePush(story.getId());
return;
}
story.setSummary(buildAddedSummary(story, stories));
story.setRemoteOwnerName(stories.get(0).getRemoteOwnerName());
story.setRemoteOwnerFullName(stories.get(0).getRemoteOwnerFullName());
story.setRemoteOwnerAvatarMediaFile(stories.get(0).getRemoteOwnerAvatarMediaFile());
story.setRemoteOwnerAvatarShape(stories.get(0).getRemoteOwnerAvatarShape());
story.setPublishedAt(Util.now());
if (isAdded) {
story.setRead(false);
story.setViewed(false);
}
storyOperations.updateMoment(story);
send(isNew ? new StoryAddedEvent(story, true) : new StoryUpdatedEvent(story, true));
sendPush(story);
}
use of org.moera.node.model.event.StoryAddedEvent in project moera-node by MoeraOrg.
the class CommentReactionInstants method addingFailed.
public void addingFailed(String postingId, PostingInfo postingInfo, String commentId, CommentInfo commentInfo) {
String postingOwnerName = postingInfo != null ? postingInfo.getOwnerName() : "";
String postingOwnerFullName = postingInfo != null ? postingInfo.getOwnerFullName() : null;
AvatarImage postingOwnerAvatar = postingInfo != null ? postingInfo.getOwnerAvatar() : null;
String postingHeading = postingInfo != null ? postingInfo.getHeading() : "";
String commentOwnerName = commentInfo != null ? commentInfo.getOwnerName() : "";
String commentOwnerFullName = commentInfo != null ? commentInfo.getOwnerFullName() : null;
AvatarImage commentOwnerAvatar = commentInfo != null ? commentInfo.getOwnerAvatar() : null;
String commentHeading = commentInfo != null ? commentInfo.getHeading() : "";
Story story = new Story(UUID.randomUUID(), nodeId(), StoryType.COMMENT_REACTION_TASK_FAILED);
story.setFeedName(Feed.INSTANT);
story.setRemoteNodeName(postingOwnerName);
story.setRemoteFullName(postingOwnerFullName);
if (postingOwnerAvatar != null) {
story.setRemoteAvatarMediaFile(postingOwnerAvatar.getMediaFile());
story.setRemoteAvatarShape(postingOwnerAvatar.getShape());
}
story.setRemotePostingId(postingId);
story.setRemoteOwnerName(commentOwnerName);
story.setRemoteOwnerFullName(commentOwnerFullName);
if (commentOwnerAvatar != null) {
story.setRemoteOwnerAvatarMediaFile(commentOwnerAvatar.getMediaFile());
story.setRemoteOwnerAvatarShape(commentOwnerAvatar.getShape());
}
story.setRemoteCommentId(commentId);
story.setSummary(buildAddingFailedSummary(postingOwnerName, postingOwnerFullName, postingHeading, commentOwnerName, commentOwnerFullName, commentHeading));
story.setPublishedAt(Util.now());
updateMoment(story);
story = storyRepository.save(story);
send(new StoryAddedEvent(story, true));
sendPush(story);
feedStatusUpdated();
}
use of org.moera.node.model.event.StoryAddedEvent in project moera-node by MoeraOrg.
the class MentionCommentInstants method added.
public void added(String remoteNodeName, String remoteFullName, AvatarImage remoteAvatar, String remotePostingId, String remotePostingHeading, String remoteOwnerName, String remoteOwnerFullName, AvatarImage remoteOwnerAvatar, String remoteCommentId, String remoteCommentHeading) {
Story story = findStory(remoteNodeName, remotePostingId, remoteCommentId);
if (story != null) {
return;
}
story = new Story(UUID.randomUUID(), nodeId(), StoryType.MENTION_COMMENT);
story.setFeedName(Feed.INSTANT);
story.setRemoteNodeName(remoteNodeName);
story.setRemoteFullName(remoteFullName);
if (remoteAvatar != null) {
story.setRemoteAvatarMediaFile(remoteAvatar.getMediaFile());
story.setRemoteAvatarShape(remoteAvatar.getShape());
}
story.setRemotePostingId(remotePostingId);
story.setRemoteOwnerName(remoteOwnerName);
story.setRemoteOwnerFullName(remoteOwnerFullName);
if (remoteOwnerAvatar != null) {
story.setRemoteOwnerAvatarMediaFile(remoteOwnerAvatar.getMediaFile());
story.setRemoteOwnerAvatarShape(remoteOwnerAvatar.getShape());
}
story.setRemoteCommentId(remoteCommentId);
story.setSummary(buildSummary(story, remotePostingHeading, remoteCommentHeading));
storyOperations.updateMoment(story);
story = storyRepository.saveAndFlush(story);
send(new StoryAddedEvent(story, true));
sendPush(story);
feedStatusUpdated();
}
use of org.moera.node.model.event.StoryAddedEvent in project moera-node by MoeraOrg.
the class MentionPostingInstants method added.
public void added(String remoteNodeName, String remoteFullName, AvatarImage remoteAvatar, String remotePostingId, String remotePostingHeading) {
Story story = findStory(remoteNodeName, remotePostingId);
if (story != null) {
return;
}
story = new Story(UUID.randomUUID(), nodeId(), StoryType.MENTION_POSTING);
story.setFeedName(Feed.INSTANT);
story.setRemoteNodeName(remoteNodeName);
story.setRemoteFullName(remoteFullName);
if (remoteAvatar != null) {
story.setRemoteAvatarMediaFile(remoteAvatar.getMediaFile());
story.setRemoteAvatarShape(remoteAvatar.getShape());
}
story.setRemotePostingId(remotePostingId);
story.setSummary(buildSummary(story, remotePostingHeading));
storyOperations.updateMoment(story);
story = storyRepository.saveAndFlush(story);
send(new StoryAddedEvent(story, true));
sendPush(story);
feedStatusUpdated();
}
Aggregations