✨Feat: 接收解析 WebHook 信息
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package cn.hezhaohui.webhook.service;
|
||||
|
||||
import cn.hezhaohui.lark.entity.CardData;
|
||||
import cn.hezhaohui.lark.util.Lark;
|
||||
import cn.hezhaohui.webhook.entity.GiteaPushEvent;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class HookService {
|
||||
|
||||
public void handlePush(GiteaPushEvent event) {
|
||||
List<String> commitMsgList = event.getCommits().stream()
|
||||
.map(GiteaPushEvent.Commit::getMessage)
|
||||
.toList();
|
||||
CardData cardData = CardData.builder()
|
||||
.title("[Gitea] 仓库状态变化")
|
||||
.repo(event.getRepository().getName())
|
||||
.link(event.getRepository().getHtml_url())
|
||||
.msg(String.join("\n", commitMsgList))
|
||||
.tag("PUSH")
|
||||
.subtitle("Ciallo~(∠・ω< )⌒★")
|
||||
.ai("待开发")
|
||||
.build();
|
||||
|
||||
try {
|
||||
Lark.sendCardMessage(cardData);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user