|
21 | 21 | from webcompat.webhooks.helpers import make_request
|
22 | 22 | from webcompat.webhooks.helpers import msg_log
|
23 | 23 | from webcompat.webhooks.helpers import oops
|
| 24 | +from webcompat.webhooks.helpers import prepare_invalid_issue |
24 | 25 | from webcompat.webhooks.helpers import prepare_rejected_issue
|
25 | 26 | from webcompat.webhooks.helpers import repo_scope
|
26 | 27 |
|
@@ -143,6 +144,14 @@ def prepare_public_comment(self):
|
143 | 144 | # prepare the payload
|
144 | 145 | return f'[Original issue {public_number}]({self.public_url})'
|
145 | 146 |
|
| 147 | + def reject_invalid_issue(self): |
| 148 | + """Send a passed-moderation-yet-invalid PATCH to the public issue.""" |
| 149 | + payload_request = prepare_invalid_issue(self.title) |
| 150 | + public_number = self.get_public_issue_number() |
| 151 | + # Preparing the proxy request |
| 152 | + path = f'repos/{PUBLIC_REPO}/{public_number}' |
| 153 | + make_request('patch', path, payload_request) |
| 154 | + |
146 | 155 | def reject_private_issue(self):
|
147 | 156 | """Send a rejected moderation PATCH on the public issue."""
|
148 | 157 | payload_request = prepare_rejected_issue()
|
@@ -237,6 +246,19 @@ def process_issue_action(self):
|
237 | 246 | # we didn't get exceptions, so it's safe to close it
|
238 | 247 | self.close_private_issue()
|
239 | 248 | return make_response('Moderated issue accepted', 200)
|
| 249 | + elif (self.action == 'milestoned' and scope == 'private' and |
| 250 | + self.milestoned_with == 'accepted: invalid'): |
| 251 | + try: |
| 252 | + self.reject_invalid_issue() |
| 253 | + except HTTPError as e: |
| 254 | + msg_log( |
| 255 | + 'private:closing public issue as invalid failed', |
| 256 | + self.number) |
| 257 | + return oops() |
| 258 | + else: |
| 259 | + # we didn't get exceptions, so it's safe to close it |
| 260 | + self.close_private_issue() |
| 261 | + return make_response('Moderated issue closed as invalid', 200) |
240 | 262 | elif (scope == 'private' and self.state == 'closed' and
|
241 | 263 | not self.milestone == 'accepted'):
|
242 | 264 | # private issue has been closed. It is rejected
|
|
0 commit comments