优化webhook返回消息格式

This commit is contained in:
San Liy 2023-12-21 00:21:41 +08:00
parent 958c94b811
commit 6df0e82420

View File

@ -69,25 +69,25 @@ async def receive(rqt: Request):
match (rqt.headers['X-Gitea-Event']):
case GiteaEvent.issues.value:
data = WebHookIssue(**rqt.json)
rsp_sender = f"{data.sender.username}"
rsp_title = f"[{data.repository.full_name}][{data.action}] {data.issue.title} (Issue #{data.issue.id})"
rsp_sender = f"By {data.sender.username}"
rsp_ctx = f"{data.issue.body}"
rsp_link = f"View it: {data.issue.html_url}"
cancel_subscribe = f"unsubscribe: {data.repository.html_url}"
rsp = f"{rsp_title}\n\n{rsp_sender}\n------\n{rsp_ctx}\n------\n{rsp_link}\n{cancel_subscribe}"
rsp = f"{rsp_sender}\n{rsp_title}\n------\n{rsp_ctx}\n------\n{rsp_link}\n{cancel_subscribe}"
case GiteaEvent.issue_comment.value:
data = WebHookIssueComment(**rqt.json)
rsp_sender = f"{data.sender.username}"
rsp_title = f"Re:[{data.repository.full_name}][{data.action}] {data.issue.title} (Issue #{data.issue.id})"
rsp_sender = f"By {data.sender.username}"
rsp_ctx = f"{data.comment.body}"
rsp_link = f"View it: {data.comment.html_url}"
cancel_subscribe = f"unsubscribe: {data.repository.html_url}"
rsp = f"{rsp_title}\n\n{rsp_sender}\n------\n{rsp_ctx}\n------\n{rsp_link}\n{cancel_subscribe}"
rsp = f"{rsp_sender}\n{rsp_title}\n------\n{rsp_ctx}\n------\n{rsp_link}\n{cancel_subscribe}"
case _:
rsp = "Unknown webhook type! Please contact the administrator."