package com.wecloud.im.sdk.sample;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;

import com.wecloud.im.sdk.WecloudIm;
import com.wecloud.im.sdk.WecloudImClientBuilder;
import com.wecloud.im.sdk.model.PrivateChatStatusMessage;

/**
 * 发布单聊消息
 * @Author luozh
 * @Date 2022年05月06日 01:37:29
 * @Version 1.0
 */
public class PublishPrivateChatMessageStatusSample {

    public static void main(String[] args) {
//        WecloudIm im = new WecloudImClientBuilder().build("http://139.159.136.86:8082",
//                "QizKVHcILRWp6Td2",
//                "287d04828099fb7de871e9dda845fa8b6b2302faf2ab3737");
        WecloudIm im = new WecloudImClientBuilder().build("http://127.0.0.1:8082",
                "QizKVHcILRWp6Td2",
                "287d04828099fb7de871e9dda845fa8b6b2302faf2ab3737");

        String senderId = "1519984635566845952";
        String toGroupIds = "1513691265777217536";
        String messageType = "-1";

        Map<String, Object> content = new HashMap<>();
        content.put("toConversation", "1519985463165931520");
        content.put("type", -1);
        content.put("text", "这是测试消息: " + DateUtil.formatDateTime(new Date()));
        content.put("attrs", new HashMap<String, String>() {
            {
                put("test1", "");
            }
        });

        PrivateChatStatusMessage privateChatMessage = new PrivateChatStatusMessage();
        privateChatMessage.setFromUserId(senderId);
        privateChatMessage.setToUserIds(toGroupIds);
        privateChatMessage.setMessageType(messageType);
        privateChatMessage.setContent(JSONUtil.toJsonStr(content));
        privateChatMessage.setIncludeBlacklist(false);
        privateChatMessage.setIncludeSender(false);


        Boolean result = im.publishPrivateStatusMessage(privateChatMessage);
    }


}
