package com.atlassian.stash.internal.notification.pull.handlers;

import com.atlassian.bitbucket.comment.Comment;
import com.atlassian.stash.internal.notification.handlers.AbstractMentionNotificationHandler;
import com.atlassian.stash.internal.notification.handlers.AbstractNotificationHandler;
import com.atlassian.stash.internal.notification.handlers.NotificationHelper;
import com.atlassian.stash.internal.notification.mention.MentionHelper;
import com.atlassian.stash.internal.notification.usersettings.SendMode;
import com.atlassian.bitbucket.notification.pull.PullRequestCommentNotification;

import java.util.Set;

/**
 * Handles mentions in email, and also wraps the default {@link AbstractPullRequestNotificationHandler},
 * which will be invoked with a filtered set of recipients that haven't been mentioned.
 * These handlers need to be removed from atlassian-plugin.xml so they not invoked directly.
 */
public abstract class AbstractPullRequestMentionNotificationHandler<T extends PullRequestCommentNotification>
        extends AbstractMentionNotificationHandler<T> {

    private static final String TEMPLATE = "bitbucket.internal.notification.email.pullRequest.mention";

    protected AbstractPullRequestMentionNotificationHandler(NotificationHelper helper,
                                                            MentionHelper mentionHelper,
                                                            AbstractNotificationHandler<T> handler) {
        super(helper, mentionHelper, handler, TEMPLATE);
    }

    @Override
    protected Comment getComment(T notification) {
        return notification.getComment();
    }

    @Override
    protected Set<SendMode> getEnabledSendModes() {
        return SendMode.immediateSet();
    }
}
