package cn.axzo.msg.center.message.service.todo;

import cn.axzo.msg.center.inside.notices.config.PendingMessageBizConfig;
import com.google.common.collect.ImmutableSet;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @author yanglin
 */
@Component
@RequiredArgsConstructor
class AnalysisConfig {

    private final static Set<String> ENABLE_PROFILES = ImmutableSet.of("dev", "test", "pre");

    private final PendingMessageBizConfig cfg;
    @Value("${spring.profiles.active}")
    private String profile;

    boolean determineAnalysisEnable(String analysisToken) {
        return ENABLE_PROFILES.contains(profile) || cfg.getAnalysisToken().equals(analysisToken);
    }

}