package com.atlassian.stash.internal.notification.batch;

import com.atlassian.stash.internal.notification.batch.dao.UserNotification;
import com.atlassian.bitbucket.user.ApplicationUser;
import com.google.common.collect.Multimap;

import javax.annotation.Nonnull;
import java.util.Collection;

/**
 * Handles the sending for a batch type.
 */
public interface BatchSender {

    /**
     * @return the ID of this batch sender, used for matching notifications to this batch sender
     */
    @Nonnull
    String getId();

    /**
     * Send the batched notifications.
     * <p>
     * Implementations must add all notifications that are sent to {@code sentNotifications}. Notifications that are
     * not added are assumed to have not been sent and will be sent again.
     *
     * @param batchId           the batch ID
     * @param notifications     the notifications of the batch, grouped by user
     * @param sentNotifications where the implementation must add processed notifications to mark them as sent
     */
    void send(@Nonnull String batchId, @Nonnull Multimap<ApplicationUser, UserNotification> notifications,
              @Nonnull Collection<UserNotification> sentNotifications);

}
