All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.noear.water.protocol.solution.HeiheiAgentImp Maven / Gradle / Ivy

There is a newer version: 2.14.2
Show newest version
package org.noear.water.protocol.solution;

import org.noear.water.model.ConfigM;
import org.noear.water.model.PropertiesM;
import org.noear.water.protocol.Heihei;
import org.noear.water.protocol.HeiheiAgent;
import org.noear.water.utils.TextUtils;

import java.util.*;

public class HeiheiAgentImp implements HeiheiAgent {
    private Heihei real;

    public HeiheiAgentImp(ConfigM cfg) {
        updateConfig(cfg);
    }


    @Override
    public void updateConfig(ConfigM cfg) {
        if (cfg == null || TextUtils.isEmpty(cfg.value)) {
            real = new HeiheiDefaultImp();
            return;
        }

        PropertiesM props = cfg.getProp();
        String url = props.getProperty("url");
        String accessSecret = props.getProperty("accessSecret");

        if (TextUtils.isNotEmpty(url)) {
            real = new HeiheiWebhookImp(url, accessSecret);
        } else {
            real = new HeiheiDefaultImp();
        }
    }

    @Override
    public String push(String tag, Collection alias, String content) {
        if (TextUtils.isEmpty(content)) {
            return null;
        }

        return real.push(tag, alias, content);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy