63 lines
1.8 KiB
Java
63 lines
1.8 KiB
Java
package com.myoa.engineering.crawl.ppomppu.sender.dto;
|
|
|
|
import java.util.List;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
import com.myoa.engineering.crawl.ppomppu.support.dto.BlockMessageDTO;
|
|
import com.myoa.engineering.crawl.ppomppu.support.dto.BlockMessageDTO.Block;
|
|
|
|
import lombok.Builder;
|
|
import lombok.Getter;
|
|
import lombok.NoArgsConstructor;
|
|
|
|
/**
|
|
* SlackMessageDTO
|
|
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
|
* @since 2021-11-14
|
|
*
|
|
*/
|
|
@Getter
|
|
@NoArgsConstructor
|
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
public class SlackMessageDTO implements MessageDTO {
|
|
|
|
private final static long serialVersionUID = 4737608709660494713L;
|
|
|
|
private String text;
|
|
private String channel;
|
|
private String username;
|
|
private List<SlackMessageBlock> blocks;
|
|
|
|
@JsonProperty("icon_emoji")
|
|
private String iconEmoji;
|
|
|
|
@Builder
|
|
public SlackMessageDTO(String text, String channel, String username,
|
|
List<SlackMessageBlock> blocks, String iconEmoji) {
|
|
this.text = text;
|
|
this.channel = channel;
|
|
this.username = username;
|
|
this.blocks = blocks;
|
|
this.iconEmoji = iconEmoji;
|
|
}
|
|
|
|
public void applyText(String text) {
|
|
this.text = text;
|
|
}
|
|
|
|
public void addSectionBlock(BlockMessageDTO.Block block) {
|
|
SlackSectionMessageBlock slackSectionMessageBlock = SlackSectionMessageBlock.ofMarkDown(block.getText());
|
|
slackSectionMessageBlock.applyImageaccessory(block.getImageUrl(), block.getAltText());
|
|
addBlock(slackSectionMessageBlock);
|
|
}
|
|
public void addSectionBlock(String rawBlockMessage) {
|
|
addBlock(SlackSectionMessageBlock.ofMarkDown(rawBlockMessage));
|
|
}
|
|
|
|
public void addBlock(SlackMessageBlock block) {
|
|
blocks.add(block);
|
|
}
|
|
|
|
}
|