package cn.axzo.msg.center.inside.notices.config;

import cn.axzo.im.center.common.enums.AppTypeEnum;
import com.google.common.collect.Sets;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.Objects;
import java.util.Set;

import static java.util.stream.Collectors.toList;

/**
 * @author yanglin
 */
@Data
@RefreshScope
@Configuration
@ConfigurationProperties(prefix = "im")
public class ImMessageProps {

    private String controllerToken = "123442";
    private Set<String> todoPollTerminals = Sets.newHashSet("cm");

    public List<AppTypeEnum> getPollTerminals() {
        return todoPollTerminals.stream()
                .map(AppTypeEnum::isValidAppType)
                .filter(Objects::nonNull)
                .distinct()
                .collect(toList());
    }

}