package com.atlassian.stash.internal.notification.commit.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.commit.CommitDiscussionCommentNotification;

import java.util.Set;

public class AbstractCommitDiscussionMentionNotificationHandler<T extends CommitDiscussionCommentNotification>
        extends AbstractMentionNotificationHandler<T> {

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

    public AbstractCommitDiscussionMentionNotificationHandler(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() {
        // Commit discussion notifications are not batched yet, so send them right away regardless of preference
        return SendMode.batchedAndImmediateSet();
    }
}
