forgejo-hooks: Add IssueAction::Edited

Signed-off-by: pep <pep@bouah.net>
This commit is contained in:
pep 2024-09-04 22:45:38 +02:00
parent f50a6dab52
commit 0ec50d7d74
3 changed files with 209 additions and 0 deletions

View file

@ -202,6 +202,20 @@ pub struct RemovedBranch {
#[serde(rename_all = "snake_case")]
pub enum IssueAction {
Opened,
Edited,
}
#[derive(Deserialize, Debug, PartialEq)]
pub struct ChangesFromPayload {
pub from: String,
}
#[derive(Deserialize, Debug, PartialEq)]
pub struct Changes {
pub title: Option<ChangesFromPayload>,
pub body: Option<ChangesFromPayload>,
#[serde(rename(deserialize = "ref"))]
pub ref_: Option<ChangesFromPayload>,
}
#[derive(Deserialize, Debug, PartialEq)]
@ -251,6 +265,7 @@ pub struct IssueAttrs {
pub struct Issue {
pub action: IssueAction,
pub number: u64,
pub changes: Option<Changes>,
pub issue: IssueAttrs,
pub repository: Repository,
}

View file

@ -0,0 +1,188 @@
{
"action": "edited",
"number": 9,
"changes": {
"title": {
"from": "If voting changed,"
}
},
"issue": {
"id": 12,
"url": "https://code.bouah.net/api/v1/repos/pep/webhook-test/issues/9",
"html_url": "https://code.bouah.net/pep/webhook-test/issues/9",
"number": 9,
"user": {
"id": 1,
"login": "pep",
"login_name": "",
"source_id": 0,
"full_name": "",
"email": "pep@bouah.net",
"avatar_url": "https://code.bouah.net/avatars/7897535c1d4a7ed71eb7b9bc8773bed6",
"html_url": "https://code.bouah.net/pep",
"language": "en-US",
"is_admin": true,
"last_login": "2024-09-04T19:40:50Z",
"created": "2023-01-02T21:57:48Z",
"restricted": false,
"active": true,
"prohibit_login": false,
"location": "",
"pronouns": "",
"website": "https://bouah.net",
"description": "",
"visibility": "public",
"followers_count": 0,
"following_count": 0,
"starred_repos_count": 0,
"username": "pep"
},
"original_author": "",
"original_author_id": 0,
"title": "If voting changed anything,",
"body": "They'd make it illegal.",
"ref": "",
"assets": [],
"labels": [],
"milestone": null,
"assignee": null,
"assignees": null,
"state": "open",
"is_locked": false,
"comments": 0,
"created_at": "2024-09-04T19:57:20Z",
"updated_at": "2024-09-04T20:31:16Z",
"closed_at": null,
"due_date": null,
"pull_request": null,
"repository": {
"id": 20,
"name": "webhook-test",
"owner": "pep",
"full_name": "pep/webhook-test"
},
"pin_order": 0
},
"repository": {
"id": 20,
"owner": {
"id": 1,
"login": "pep",
"login_name": "",
"source_id": 0,
"full_name": "",
"email": "pep@bouah.net",
"avatar_url": "https://code.bouah.net/avatars/7897535c1d4a7ed71eb7b9bc8773bed6",
"html_url": "https://code.bouah.net/pep",
"language": "",
"is_admin": false,
"last_login": "0001-01-01T00:00:00Z",
"created": "2023-01-02T21:57:48Z",
"restricted": false,
"active": false,
"prohibit_login": false,
"location": "",
"pronouns": "",
"website": "https://bouah.net",
"description": "",
"visibility": "public",
"followers_count": 0,
"following_count": 0,
"starred_repos_count": 0,
"username": "pep"
},
"name": "webhook-test",
"full_name": "pep/webhook-test",
"description": "",
"empty": false,
"private": false,
"fork": false,
"template": false,
"parent": null,
"mirror": false,
"size": 33,
"language": "",
"languages_url": "https://code.bouah.net/api/v1/repos/pep/webhook-test/languages",
"html_url": "https://code.bouah.net/pep/webhook-test",
"url": "https://code.bouah.net/api/v1/repos/pep/webhook-test",
"link": "",
"ssh_url": "forgejo@code.bouah.net:pep/webhook-test.git",
"clone_url": "https://code.bouah.net/pep/webhook-test.git",
"original_url": "",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 9,
"open_pr_counter": 0,
"release_counter": 0,
"default_branch": "main",
"archived": false,
"created_at": "2024-04-23T11:49:34Z",
"updated_at": "2024-09-01T22:47:17Z",
"archived_at": "1970-01-01T00:00:00Z",
"permissions": {
"admin": true,
"push": true,
"pull": true
},
"has_issues": true,
"internal_tracker": {
"enable_time_tracker": false,
"allow_only_contributors_to_track_time": true,
"enable_issue_dependencies": true
},
"has_wiki": true,
"wiki_branch": "master",
"globally_editable_wiki": false,
"has_pull_requests": true,
"has_projects": true,
"has_releases": true,
"has_packages": true,
"has_actions": false,
"ignore_whitespace_conflicts": false,
"allow_merge_commits": true,
"allow_rebase": true,
"allow_rebase_explicit": true,
"allow_squash_merge": true,
"allow_fast_forward_only_merge": false,
"allow_rebase_update": true,
"default_delete_branch_after_merge": false,
"default_merge_style": "rebase",
"default_allow_maintainer_edit": false,
"avatar_url": "",
"internal": false,
"mirror_interval": "",
"object_format_name": "sha1",
"mirror_updated": "0001-01-01T00:00:00Z",
"repo_transfer": null,
"topics": null
},
"sender": {
"id": 1,
"login": "pep",
"login_name": "",
"source_id": 0,
"full_name": "",
"email": "pep@forgejo-noreply",
"avatar_url": "https://code.bouah.net/avatars/7897535c1d4a7ed71eb7b9bc8773bed6",
"html_url": "https://code.bouah.net/pep",
"language": "",
"is_admin": false,
"last_login": "0001-01-01T00:00:00Z",
"created": "2023-01-02T21:57:48Z",
"restricted": false,
"active": false,
"prohibit_login": false,
"location": "",
"pronouns": "",
"website": "https://bouah.net",
"description": "",
"visibility": "public",
"followers_count": 0,
"following_count": 0,
"starred_repos_count": 0,
"username": "pep"
},
"commit_id": ""
}

View file

@ -64,3 +64,9 @@ fn issue_with_assignee() {
let payload = std::fs::read_to_string("src/tests/issue-with-assignee.json").unwrap();
let _ = parse_roundtrip::<Issue>(&payload);
}
#[test]
fn issue_edited() {
let payload = std::fs::read_to_string("src/tests/issue-edited.json").unwrap();
let _ = parse_roundtrip::<Issue>(&payload);
}