Search in sources :

Example 1 with AvatarImage

use of org.moera.node.model.AvatarImage 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();
}
Also used : StoryAddedEvent(org.moera.node.model.event.StoryAddedEvent) AvatarImage(org.moera.node.model.AvatarImage) Story(org.moera.node.data.Story)

Example 2 with AvatarImage

use of org.moera.node.model.AvatarImage 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();
}
Also used : StoryAddedEvent(org.moera.node.model.event.StoryAddedEvent) AvatarImage(org.moera.node.model.AvatarImage) Story(org.moera.node.data.Story)

Example 3 with AvatarImage

use of org.moera.node.model.AvatarImage in project moera-node by MoeraOrg.

the class PostingReactionReceptor method updated.

private void updated(Liberin liberin, Posting posting, Reaction addedReaction, Reaction deletedReaction, ReactionTotalsInfo reactionTotals) {
    if (addedReaction != null && addedReaction.getSignature() != null) {
        AvatarImage ownerAvatar = new AvatarImage(addedReaction.getOwnerAvatarMediaFile(), addedReaction.getOwnerAvatarShape());
        if (posting.getParentMedia() == null) {
            send(Directions.single(liberin.getNodeId(), posting.getOwnerName()), new PostingReactionAddedNotification(null, null, null, null, posting.getId(), posting.getCurrentRevision().getHeading(), addedReaction.getOwnerName(), addedReaction.getOwnerFullName(), ownerAvatar, addedReaction.isNegative(), addedReaction.getEmoji()));
        } else {
            Set<Entry> entries = entryRepository.findByMediaId(posting.getParentMedia().getId());
            for (Entry entry : entries) {
                UUID parentPostingId = entry instanceof Comment ? ((Comment) entry).getPosting().getId() : entry.getId();
                UUID parentCommentId = entry instanceof Comment ? entry.getId() : null;
                send(Directions.single(liberin.getNodeId(), posting.getOwnerName()), new PostingReactionAddedNotification(parentPostingId, parentCommentId, posting.getParentMedia().getId(), entry.getCurrentRevision().getHeading(), posting.getId(), posting.getCurrentRevision().getHeading(), addedReaction.getOwnerName(), addedReaction.getOwnerFullName(), ownerAvatar, addedReaction.isNegative(), addedReaction.getEmoji()));
            }
        }
    }
    if (deletedReaction != null) {
        AvatarImage ownerAvatar = new AvatarImage(deletedReaction.getOwnerAvatarMediaFile(), deletedReaction.getOwnerAvatarShape());
        if (posting.getParentMedia() == null) {
            send(Directions.single(liberin.getNodeId(), posting.getOwnerName()), new PostingReactionDeletedNotification(null, null, null, posting.getId(), deletedReaction.getOwnerName(), deletedReaction.getOwnerFullName(), ownerAvatar, deletedReaction.isNegative()));
        } else {
            Set<Entry> entries = entryRepository.findByMediaId(posting.getParentMedia().getId());
            for (Entry entry : entries) {
                UUID parentPostingId = entry instanceof Comment ? ((Comment) entry).getPosting().getId() : entry.getId();
                UUID parentCommentId = entry instanceof Comment ? entry.getId() : null;
                send(Directions.single(liberin.getNodeId(), posting.getOwnerName()), new PostingReactionDeletedNotification(parentPostingId, parentCommentId, posting.getParentMedia().getId(), posting.getId(), deletedReaction.getOwnerName(), deletedReaction.getOwnerFullName(), ownerAvatar, deletedReaction.isNegative()));
            }
        }
    }
    send(liberin, new PostingReactionsChangedEvent(posting));
    send(Directions.postingSubscribers(posting.getNodeId(), posting.getId()), new PostingReactionsUpdatedNotification(posting.getId(), reactionTotals));
}
Also used : Comment(org.moera.node.data.Comment) Entry(org.moera.node.data.Entry) PostingReactionsUpdatedNotification(org.moera.node.model.notification.PostingReactionsUpdatedNotification) PostingReactionAddedNotification(org.moera.node.model.notification.PostingReactionAddedNotification) PostingReactionDeletedNotification(org.moera.node.model.notification.PostingReactionDeletedNotification) AvatarImage(org.moera.node.model.AvatarImage) UUID(java.util.UUID) PostingReactionsChangedEvent(org.moera.node.model.event.PostingReactionsChangedEvent)

Example 4 with AvatarImage

use of org.moera.node.model.AvatarImage in project moera-node by MoeraOrg.

the class CommentReceptor method added.

@LiberinMapping
public void added(CommentAddedLiberin liberin) {
    Comment comment = liberin.getComment();
    Posting posting = liberin.getPosting();
    if (comment.getCurrentRevision().getSignature() != null) {
        UUID repliedToId = comment.getRepliedTo() != null ? comment.getRepliedTo().getId() : null;
        send(Directions.postingCommentsSubscribers(posting.getNodeId(), posting.getId()), new PostingCommentAddedNotification(posting.getId(), posting.getCurrentRevision().getHeading(), comment.getId(), comment.getOwnerName(), comment.getOwnerFullName(), new AvatarImage(comment.getOwnerAvatarMediaFile(), comment.getOwnerAvatarShape()), comment.getCurrentRevision().getHeading(), repliedToId));
    }
    notifyReplyAdded(posting, comment);
    notifyMentioned(posting, comment.getId(), comment.getOwnerName(), comment.getOwnerFullName(), new AvatarImage(comment.getOwnerAvatarMediaFile(), comment.getOwnerAvatarShape()), comment.getCurrentRevision(), null);
    send(liberin, new CommentAddedEvent(comment));
    send(liberin, new PostingCommentsChangedEvent(posting));
    send(Directions.postingSubscribers(posting.getNodeId(), posting.getId()), new PostingCommentsUpdatedNotification(posting.getId(), posting.getTotalChildren()));
}
Also used : Comment(org.moera.node.data.Comment) CommentAddedEvent(org.moera.node.model.event.CommentAddedEvent) Posting(org.moera.node.data.Posting) PostingCommentsChangedEvent(org.moera.node.model.event.PostingCommentsChangedEvent) UUID(java.util.UUID) AvatarImage(org.moera.node.model.AvatarImage) PostingCommentAddedNotification(org.moera.node.model.notification.PostingCommentAddedNotification) PostingCommentsUpdatedNotification(org.moera.node.model.notification.PostingCommentsUpdatedNotification) LiberinMapping(org.moera.node.liberin.LiberinMapping)

Example 5 with AvatarImage

use of org.moera.node.model.AvatarImage in project moera-node by MoeraOrg.

the class CommentReceptor method updated.

@LiberinMapping
public void updated(CommentUpdatedLiberin liberin) {
    Comment comment = liberin.getComment();
    Posting posting = comment.getPosting();
    notifyReplyAdded(posting, comment);
    notifyMentioned(posting, comment.getId(), comment.getOwnerName(), comment.getOwnerFullName(), new AvatarImage(comment.getOwnerAvatarMediaFile(), comment.getOwnerAvatarShape()), comment.getCurrentRevision(), liberin.getLatestRevision());
    if (comment.getCurrentRevision().getSignature() != null) {
        UUID repliedToId = comment.getRepliedTo() != null ? comment.getRepliedTo().getId() : null;
        send(Directions.postingCommentsSubscribers(comment.getNodeId(), posting.getId()), new PostingCommentAddedNotification(posting.getId(), posting.getCurrentRevision().getHeading(), comment.getId(), comment.getOwnerName(), comment.getOwnerFullName(), new AvatarImage(comment.getOwnerAvatarMediaFile(), comment.getOwnerAvatarShape()), comment.getCurrentRevision().getHeading(), repliedToId));
    }
    send(liberin, new CommentUpdatedEvent(comment));
}
Also used : Comment(org.moera.node.data.Comment) Posting(org.moera.node.data.Posting) AvatarImage(org.moera.node.model.AvatarImage) UUID(java.util.UUID) CommentUpdatedEvent(org.moera.node.model.event.CommentUpdatedEvent) PostingCommentAddedNotification(org.moera.node.model.notification.PostingCommentAddedNotification) LiberinMapping(org.moera.node.liberin.LiberinMapping)

Aggregations

AvatarImage (org.moera.node.model.AvatarImage)21 Story (org.moera.node.data.Story)11 StoryAddedEvent (org.moera.node.model.event.StoryAddedEvent)9 Comment (org.moera.node.data.Comment)5 UUID (java.util.UUID)4 Posting (org.moera.node.data.Posting)4 Entry (org.moera.node.data.Entry)3 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 Transactional (javax.transaction.Transactional)2 Feed (org.moera.node.data.Feed)2 MediaFile (org.moera.node.data.MediaFile)2 PublicPage (org.moera.node.data.PublicPage)2 PublicPageRepository (org.moera.node.data.PublicPageRepository)2 StoryRepository (org.moera.node.data.StoryRepository)2 RequestContext (org.moera.node.global.RequestContext)2 LiberinMapping (org.moera.node.liberin.LiberinMapping)2