Switch all postings to JSON for consistency and betterness

Even though everything *except* status worked just fine the 'wrong' way!
This commit is contained in:
benjamin melançon 2023-10-04 22:17:34 -04:00
parent 32583205b6
commit 1df3f14ecd

View file

@ -49,7 +49,7 @@ def move_issue(source_owner, source_repo, issue_number, destination_owner, desti
create_issue_url = API_CREATE_ISSUE.format(instance=FORGEJO_INSTANCE, owner=destination_owner, repo=destination_repo)
# print(create_issue_url)
headers = {"Authorization": f"token {FORGEJO_API_TOKEN}"}
created_response = requests.post(create_issue_url, headers=headers, data=json_response)
created_response = requests.post(create_issue_url, headers=headers, json=json_response)
json_response = created_response.json()
message = json_response.pop('message', False)
@ -72,7 +72,7 @@ def move_issue(source_owner, source_repo, issue_number, destination_owner, desti
json_comments = comments.json()
for comment in json_comments:
new_comment = requests.post(create_comment_url, headers=headers, data=comment)
new_comment = requests.post(create_comment_url, headers=headers, json=comment)
json_new_comment = new_comment.json()
message = json_new_comment.pop('message', False)
if message:
@ -85,10 +85,10 @@ def move_issue(source_owner, source_repo, issue_number, destination_owner, desti
moved_from_message = {
'body': f"*Issue moved here from:* {old_issue_url}"
}
new_comment = requests.post(create_comment_url, headers=headers, data=moved_from_message)
new_comment = requests.post(create_comment_url, headers=headers, json=moved_from_message)
create_old_comment_url = API_CREATE_COMMENT.format(instance=FORGEJO_INSTANCE, owner=source_owner, repo=source_repo, index=issue_number)
new_old_comment = requests.post(create_old_comment_url, headers=headers, data=moved_to_message)
new_old_comment = requests.post(create_old_comment_url, headers=headers, json=moved_to_message)
# And finally, close the old issue.
# If we are confident the API is remaining stabel we can just use the same path