diff --git a/src/libs/github/models/issue.py b/src/libs/github/models/issue.py index 02f8200..e16f8e3 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-05-16 22:47:53 +@LastEditTime : 2021-05-21 01:02:36 @Description : None @GitHub : https://github.com/yanyongyu """ @@ -22,8 +22,8 @@ from .label import Label from .comment import Comment from .timeline import (TimelineEvent, TimelineEventCommited, TimelineEventCommented, TimelineEventReviewed, - TimelineEventRenamed, TimelineEventMerged, - TimelineEventClosed) + TimelineEventReviewRequested, TimelineEventRenamed, + TimelineEventMerged, TimelineEventClosed) class IssuePullRequest(_BaseModel): @@ -92,9 +92,10 @@ class Issue(BaseModel): } return PaginatedList(Union[TimelineEventCommited, TimelineEventCommented, - TimelineEventReviewed, TimelineEventRenamed, - TimelineEventMerged, TimelineEventClosed, - TimelineEvent], + TimelineEventReviewed, + TimelineEventReviewRequested, + TimelineEventRenamed, TimelineEventMerged, + TimelineEventClosed, TimelineEvent], self.requester, "GET", self.timeline_url, diff --git a/src/libs/github/models/timeline.py b/src/libs/github/models/timeline.py index aabc21b..231fe81 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-05-17 18:53:05 +@LastEditTime : 2021-05-21 02:24:18 @Description : None @GitHub : https://github.com/yanyongyu """ @@ -106,6 +106,19 @@ class TimelineEventReviewed(TimelineEvent): links: TimelineEventReviewedLinks = Field(alias="_links") +class TimelineEventReviewRequested(TimelineEvent): + event: Literal["review_requested"] + id: int + node_id: str + url: str + actor: User + commit_id: Optional[str] + commit_url: Optional[str] + created_at: datetime + review_requester: User + requested_reviewer: User + + class TimelineEventRenamedDetail(_BaseModel): to: str from_: str = Field(alias="from") @@ -134,6 +147,23 @@ class TimelineEventMerged(TimelineEvent): created_at: datetime +class TimelineEventLabeledInfo(_BaseModel): + name: str + color: str + + +class TimelineEventLabeled(TimelineEvent): + event: Literal["labeled"] + id: int + node_id: str + url: str + actor: User + commit_id: Optional[str] + commit_url: Optional[str] + created_at: datetime + label: TimelineEventLabeledInfo + + class TimelineEventClosed(TimelineEvent): event: Literal["closed"] id: int diff --git a/src/plugins/github/libs/issue/templates/comment.html b/src/plugins/github/libs/issue/templates/comment.html index 2682cd6..a1ce497 100644 --- a/src/plugins/github/libs/issue/templates/comment.html +++ b/src/plugins/github/libs/issue/templates/comment.html @@ -2,7 +2,7 @@ * @Author : yanyongyu * @Date : 2021-05-15 15:08:50 * @LastEditors : yanyongyu - * @LastEditTime : 2021-05-16 12:21:39 + * @LastEditTime : 2021-05-21 01:22:12 * @Description : None * @GitHub : https://github.com/yanyongyu --> @@ -76,7 +76,8 @@ - {{event.body_html|default(event.body_text)|default(event.body)}} + {{event.body_html or (event.body_text|escape) or + (event.body|escape) or ("No description provided.")}} diff --git a/src/plugins/github/libs/issue/templates/issue.html b/src/plugins/github/libs/issue/templates/issue.html index f93b19a..c81483e 100644 --- a/src/plugins/github/libs/issue/templates/issue.html +++ b/src/plugins/github/libs/issue/templates/issue.html @@ -37,6 +37,9 @@ {% elif event|classname == "TimelineEventReviewed" -%} {% include "review.html" %} + {% elif event|classname == "TimelineEventReviewRequested" -%} + {% include "review_request.html" %} + {% elif event|classname == "TimelineEventRenamed" -%} {% include "rename.html" %} @@ -54,7 +57,7 @@ {% include "close.html" %} {%- endif %} - {% else %} + {%- else -%} {%- endif %} diff --git a/src/plugins/github/libs/issue/templates/review_request.html b/src/plugins/github/libs/issue/templates/review_request.html new file mode 100644 index 0000000..fcb4415 --- /dev/null +++ b/src/plugins/github/libs/issue/templates/review_request.html @@ -0,0 +1,52 @@ + + +
+
+ +
+
+ {% set self_request = event.review_requester.login == + event.requested_reviewer.login %} + + + + + {{ event.review_requester.login }} + + + {% if self_request -%} + self-requested a review + {%- else -%} + requested a review from + + {{ event.requested_reviewer.login }} + + + {%- endif %} + {{event.created_at|relative_time}} +
+