From 8b0c4618c7d3490f9df9046d5c3666bc2e35c6ca Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Fri, 20 Aug 2021 23:41:13 +0800 Subject: [PATCH] :alembic: add assigned event Fix QQ-GITHUB-BOT-1Q --- src/libs/github/models/issue.py | 19 +++---- src/libs/github/models/timeline.py | 16 +++++- .../github/libs/issue/templates/assigned.html | 52 +++++++++++++++++++ .../github/libs/issue/templates/issue.html | 5 +- 4 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 src/plugins/github/libs/issue/templates/assigned.html diff --git a/src/libs/github/models/issue.py b/src/libs/github/models/issue.py index 855395f..9c82bd6 100644 --- a/src/libs/github/models/issue.py +++ b/src/libs/github/models/issue.py @@ -4,7 +4,7 @@ @Author : yanyongyu @Date : 2021-03-11 16:57:04 @LastEditors : yanyongyu -@LastEditTime : 2021-08-20 23:24:08 +@LastEditTime : 2021-08-20 23:32:41 @Description : None @GitHub : https://github.com/yanyongyu """ @@ -23,7 +23,7 @@ from .comment import Comment from .timeline import ( TimelineEvent, TimelineEventCommited, TimelineEventForcePushed, TimelineEventHeadDeleted, TimelineEventReferenced, TimelineEventCommented, - TimelineEventCommentDeleted, TimelineEventMentioned, + TimelineEventCommentDeleted, TimelineEventAssigned, TimelineEventMentioned, TimelineEventSubscribed, TimelineEventUnsubscribed, TimelineEventReviewed, TimelineEventReviewRequested, TimelineEventReviewRemoved, TimelineEventReviewDismissed, TimelineEventRenamed, TimelineEventLabeled, @@ -102,13 +102,14 @@ class Issue(BaseModel): Union[TimelineEventCommited, TimelineEventForcePushed, TimelineEventHeadDeleted, TimelineEventReferenced, TimelineEventCommented, TimelineEventCommentDeleted, - TimelineEventMentioned, TimelineEventSubscribed, - TimelineEventUnsubscribed, TimelineEventReviewed, - TimelineEventReviewRequested, TimelineEventReviewRemoved, - TimelineEventReviewDismissed, TimelineEventRenamed, - TimelineEventLabeled, TimelineEventUnlabeled, - TimelineEventMerged, TimelineEventDeployed, - TimelineEventClosed, TimelineEventAddedToProject, + TimelineEventAssigned, TimelineEventMentioned, + TimelineEventSubscribed, TimelineEventUnsubscribed, + TimelineEventReviewed, TimelineEventReviewRequested, + TimelineEventReviewRemoved, TimelineEventReviewDismissed, + TimelineEventRenamed, TimelineEventLabeled, + TimelineEventUnlabeled, TimelineEventMerged, + TimelineEventDeployed, TimelineEventClosed, + TimelineEventAddedToProject, TimelineEventMovedColumnsInProject, TimelineEventRemovedFromProject, TimelineEventMilestoned, TimelineEventDemilestoned, TimelineEvent], diff --git a/src/libs/github/models/timeline.py b/src/libs/github/models/timeline.py index fe959dd..1933c60 100644 --- a/src/libs/github/models/timeline.py +++ b/src/libs/github/models/timeline.py @@ -4,7 +4,7 @@ @Author : yanyongyu @Date : 2021-05-14 00:57:33 @LastEditors : yanyongyu -@LastEditTime : 2021-08-20 23:23:33 +@LastEditTime : 2021-08-20 23:31:52 @Description : None @GitHub : https://github.com/yanyongyu """ @@ -131,6 +131,20 @@ class TimelineEventCommentDeleted(TimelineEvent): created_at: datetime +# Issue assigned to Person +class TimelineEventAssigned(TimelineEvent): + type: Literal["assigned"] + id: int + node_id: str + url: str + actor: Actor + commit_id: Optional[str] + commit_url: Optional[str] + created_at: datetime + assignee: Actor + assigner: Actor + + # Issue Mentioned Person class TimelineEventMentioned(TimelineEvent): event: Literal["mentioned"] diff --git a/src/plugins/github/libs/issue/templates/assigned.html b/src/plugins/github/libs/issue/templates/assigned.html new file mode 100644 index 0000000..3a8989a --- /dev/null +++ b/src/plugins/github/libs/issue/templates/assigned.html @@ -0,0 +1,52 @@ + + +
+
+ +
+
+ {% set self_request = event.assigner.login == event.assignee.login %} + + + + + {{ event.assigner.login|escape }} + + + {% if self_request -%} + self-assigned this + {%- else -%} + assigned + + {{ event.assignee.login|escape }} + + + {%- endif %} + {{ event.created_at|relative_time }} +
+
diff --git a/src/plugins/github/libs/issue/templates/issue.html b/src/plugins/github/libs/issue/templates/issue.html index 0beb683..6977149 100644 --- a/src/plugins/github/libs/issue/templates/issue.html +++ b/src/plugins/github/libs/issue/templates/issue.html @@ -2,7 +2,7 @@ * @Author : yanyongyu * @Date : 2021-05-14 17:11:26 * @LastEditors : yanyongyu - * @LastEditTime : 2021-08-20 23:25:47 + * @LastEditTime : 2021-08-20 23:33:11 * @Description : None * @GitHub : https://github.com/yanyongyu --> @@ -36,6 +36,9 @@ {% elif event|classname == "TimelineEventCommentDeleted" -%} {% include "comment-delete.html" %} + {% elif event|classname == "TimelineEventAssigned" -%} + {% include "assigned.html" %} + {% elif event|classname == "TimelineEventCommited" -%} {% include "commit.html" %}