Skip to content

Commit 45ad1ae

Browse files
authored
Adapting to GH api changes, revert to origin text (#45)
For pull request related events, make another API call to get PR info.
1 parent eb39b72 commit 45ad1ae

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

app/model/devel_feed.py

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ def new(d: dict):
5858
]
5959
)
6060

61-
elif d["type"] == "PullRequestEvent" and d["payload"]["action"] in (
62-
"opened",
63-
"closed",
64-
"reopened",
65-
):
61+
elif d["type"].startswith("PullRequest"):
6662
target_url = d["payload"]["pull_request"]["url"]
6763
response = (
6864
cache.get(
@@ -77,15 +73,36 @@ def new(d: dict):
7773
return
7874

7975
pr_data = json.loads(response)
80-
text = " ".join(
81-
[
82-
_render_url(d["actor"]["login"], d["actor"]["url"]),
83-
d["payload"]["action"],
84-
"a pull request",
85-
"at",
86-
_render_url(d["repo"]["name"], d["repo"]["url"]),
87-
]
88-
)
76+
if d["type"] == "PullRequestEvent" and d["payload"]["action"] in ("opened", "closed", "reopened"):
77+
text = " ".join(
78+
[
79+
_render_url(d["actor"]["login"], d["actor"]["url"]),
80+
d["payload"]["action"],
81+
"a pull request",
82+
"“" + _render_url(pr_data["title"], pr_data["html_url"]) + "”",
83+
"at",
84+
_render_url(d["repo"]["name"], d["repo"]["url"]),
85+
]
86+
)
87+
elif d["type"] == "PullRequestReviewCommentEvent" and d["payload"]["action"] == "created":
88+
is_high_priority = False
89+
target_url = _prepare_url(d["payload"]["comment"]["html_url"])
90+
text = " ".join(
91+
[
92+
_render_url(d["actor"]["login"], d["actor"]["url"]),
93+
"commented on a pull request",
94+
"“"
95+
+ _render_url(
96+
pr_data["title"],
97+
pr_data["url"],
98+
)
99+
+ "”",
100+
"at",
101+
_render_url(d["repo"]["name"], d["repo"]["url"]),
102+
]
103+
)
104+
else:
105+
return
89106
elif d["type"] == "IssuesEvent" and d["payload"]["action"] in (
90107
"opened",
91108
"closed",
@@ -161,24 +178,6 @@ def new(d: dict):
161178
]
162179
)
163180

164-
elif d["type"] == "PullRequestReviewCommentEvent" and d["payload"]["action"] == "created":
165-
is_high_priority = False
166-
target_url = _prepare_url(d["payload"]["comment"]["html_url"])
167-
text = " ".join(
168-
[
169-
_render_url(d["actor"]["login"], d["actor"]["url"]),
170-
"commented on a pull request",
171-
"“"
172-
+ _render_url(
173-
d["payload"]["pull_request"]["title"],
174-
d["payload"]["pull_request"]["html_url"],
175-
)
176-
+ "”",
177-
"at",
178-
_render_url(d["repo"]["name"], d["repo"]["url"]),
179-
]
180-
)
181-
182181
elif d["type"] == "IssueCommentEvent" and d["payload"]["action"] == "created":
183182
is_high_priority = False
184183
target_url = _prepare_url(d["payload"]["comment"]["html_url"])

0 commit comments

Comments
 (0)