Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7215207

Browse filesBrowse files
authored
Merge pull request hub4j#1423 from gsmet/remove-reaction
Switch to the new delete reaction API
2 parents d226125 + 575039a commit 7215207
Copy full SHA for 7215207

File tree

Expand file treeCollapse file tree

154 files changed

+3396
-2894
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

154 files changed

+3396
-2894
lines changed

‎src/main/java/org/kohsuke/github/GHCommitComment.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHCommitComment.java
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ public GHReaction createReaction(ReactionContent content) throws IOException {
134134
.fetch(GHReaction.class);
135135
}
136136

137+
public void deleteReaction(GHReaction reaction) throws IOException {
138+
owner.root()
139+
.createRequest()
140+
.method("DELETE")
141+
.withUrlPath(getApiTail(), "reactions", String.valueOf(reaction.getId()))
142+
.send();
143+
}
144+
137145
@Preview(SQUIRREL_GIRL)
138146
public PagedIterable<GHReaction> listReactions() {
139147
return owner.root()

‎src/main/java/org/kohsuke/github/GHIssue.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHIssue.java
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,14 @@ public GHReaction createReaction(ReactionContent content) throws IOException {
501501
.fetch(GHReaction.class);
502502
}
503503

504+
public void deleteReaction(GHReaction reaction) throws IOException {
505+
owner.root()
506+
.createRequest()
507+
.method("DELETE")
508+
.withUrlPath(getApiRoute(), "reactions", String.valueOf(reaction.getId()))
509+
.send();
510+
}
511+
504512
@Preview(SQUIRREL_GIRL)
505513
public PagedIterable<GHReaction> listReactions() {
506514
return root().createRequest()

‎src/main/java/org/kohsuke/github/GHIssueComment.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHIssueComment.java
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ public GHReaction createReaction(ReactionContent content) throws IOException {
141141
.fetch(GHReaction.class);
142142
}
143143

144+
public void deleteReaction(GHReaction reaction) throws IOException {
145+
owner.root()
146+
.createRequest()
147+
.method("DELETE")
148+
.withUrlPath(getApiRoute(), "reactions", String.valueOf(reaction.getId()))
149+
.send();
150+
}
151+
144152
@Preview(SQUIRREL_GIRL)
145153
public PagedIterable<GHReaction> listReactions() {
146154
return owner.root()

‎src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ public GHReaction createReaction(ReactionContent content) throws IOException {
225225
.fetch(GHReaction.class);
226226
}
227227

228+
public void deleteReaction(GHReaction reaction) throws IOException {
229+
owner.root()
230+
.createRequest()
231+
.method("DELETE")
232+
.withUrlPath(getApiRoute(), "reactions", String.valueOf(reaction.getId()))
233+
.send();
234+
}
235+
228236
@Preview(SQUIRREL_GIRL)
229237
public PagedIterable<GHReaction> listReactions() {
230238
return owner.root()

‎src/main/java/org/kohsuke/github/GHReaction.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHReaction.java
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ public URL getHtmlUrl() {
5151
*
5252
* @throws IOException
5353
* the io exception
54+
* @deprecated this API is no longer supported by GitHub, keeping it as is for old versions of GitHub Enterprise
55+
* @see <a href="https://github.blog/changelog/2022-02-11-legacy-delete-reactions-rest-api-removed/">Legacy Delete
56+
* reactions REST API removed</a>
5457
*/
58+
@Deprecated
5559
public void delete() throws IOException {
56-
root().createRequest().method("DELETE").withPreview(SQUIRREL_GIRL).withUrlPath("/reactions/" + getId()).send();
60+
throw new UnsupportedOperationException(
61+
"This method is not supported anymore. Please use Reactable#deleteReaction(GHReaction).");
5762
}
5863
}

‎src/main/java/org/kohsuke/github/Reactable.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/Reactable.java
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,14 @@ public interface Reactable {
3030
*/
3131
@Preview(SQUIRREL_GIRL)
3232
GHReaction createReaction(ReactionContent content) throws IOException;
33+
34+
/**
35+
* Delete a reaction from this object.
36+
*
37+
* @param reaction
38+
* the reaction to delete
39+
* @throws IOException
40+
* the io exception
41+
*/
42+
void deleteReaction(GHReaction reaction) throws IOException;
3343
}

‎src/test/java/org/kohsuke/github/AppTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/AppTest.java
+27-7Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,21 @@ public void testIssueWithComment() throws IOException {
183183
ReactionContent.HOORAY,
184184
ReactionContent.ROCKET));
185185

186-
reaction.delete();
186+
// test retired delete reaction API throws UnsupportedOperationException
187+
final GHReaction reactionToDelete = reaction;
188+
assertThrows(UnsupportedOperationException.class, () -> reactionToDelete.delete());
189+
190+
// test new delete reaction API
191+
v.get(1).deleteReaction(reaction);
187192
reaction = null;
188193
v = i.getComments();
189194
reactions = v.get(1).listReactions().toList();
190195
assertThat(reactions.stream().map(item -> item.getContent()).collect(Collectors.toList()),
191196
containsInAnyOrder(ReactionContent.EYES, ReactionContent.HOORAY, ReactionContent.ROCKET));
192197
} finally {
193198
if (reaction != null) {
194-
reaction.delete();
199+
v.get(1).deleteReaction(reaction);
200+
reaction = null;
195201
}
196202
}
197203
}
@@ -683,6 +689,20 @@ public void testCreateCommitComment() throws Exception {
683689

684690
assertThat(commit.getCommitShortInfo().getCommentCount(), equalTo(31));
685691

692+
// testing reactions
693+
List<GHReaction> reactions = c.listReactions().toList();
694+
assertThat(reactions, is(empty()));
695+
696+
GHReaction reaction = c.createReaction(ReactionContent.CONFUSED);
697+
assertThat(reaction.getContent(), equalTo(ReactionContent.CONFUSED));
698+
699+
reactions = c.listReactions().toList();
700+
assertThat(reactions.size(), equalTo(1));
701+
702+
c.deleteReaction(reaction);
703+
704+
reactions = c.listReactions().toList();
705+
assertThat(reactions.size(), equalTo(0));
686706
} finally {
687707
c.delete();
688708
}
@@ -1273,7 +1293,7 @@ public void reactions() throws Exception {
12731293
a = i.createReaction(ReactionContent.HOORAY);
12741294
assertThat(a.getUser().getLogin(), is(gitHub.getMyself().getLogin()));
12751295
assertThat(a.getContent(), is(ReactionContent.HOORAY));
1276-
a.delete();
1296+
i.deleteReaction(a);
12771297

12781298
l = i.listReactions().toList();
12791299
assertThat(l.size(), equalTo(1));
@@ -1307,10 +1327,10 @@ public void reactions() throws Exception {
13071327
assertThat(l.get(4).getUser().getLogin(), is(gitHub.getMyself().getLogin()));
13081328
assertThat(l.get(4).getContent(), is(ReactionContent.ROCKET));
13091329

1310-
l.get(1).delete();
1311-
l.get(2).delete();
1312-
l.get(3).delete();
1313-
l.get(4).delete();
1330+
i.deleteReaction(l.get(1));
1331+
i.deleteReaction(l.get(2));
1332+
i.deleteReaction(l.get(3));
1333+
i.deleteReaction(l.get(4));
13141334

13151335
l = i.listReactions().toList();
13161336
assertThat(l.size(), equalTo(1));

‎src/test/java/org/kohsuke/github/GHPullRequestTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHPullRequestTest.java
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ public void pullRequestReviewComments() throws Exception {
146146
reactions = comment.listReactions().toList();
147147
assertThat(reactions.size(), equalTo(1));
148148

149+
comment.deleteReaction(reaction);
150+
151+
reactions = comment.listReactions().toList();
152+
assertThat(reactions.size(), equalTo(0));
153+
149154
GHPullRequestReviewComment reply = comment.reply("This is a reply.");
150155
assertThat(reply.getInReplyToId(), equalTo(comment.getId()));
151156
comments = p.listReviewComments().toList();
+30-20Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"login": "hub4j",
99
"id": 54909825,
1010
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
11-
"avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
11+
"avatar_url": "https://avatars.githubusercontent.com/u/54909825?v=4",
1212
"gravatar_id": "",
1313
"url": "https://api.github.com/users/hub4j",
1414
"html_url": "https://github.com/hub4j",
@@ -65,53 +65,63 @@
6565
"releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
6666
"deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
6767
"created_at": "2010-04-19T04:13:03Z",
68-
"updated_at": "2020-02-23T02:42:15Z",
69-
"pushed_at": "2020-02-23T02:48:53Z",
68+
"updated_at": "2022-04-05T15:53:55Z",
69+
"pushed_at": "2022-04-08T04:02:11Z",
7070
"git_url": "git://github.com/hub4j/github-api.git",
7171
"ssh_url": "git@github.com:hub4j/github-api.git",
7272
"clone_url": "https://github.com/hub4j/github-api.git",
7373
"svn_url": "https://github.com/hub4j/github-api",
7474
"homepage": "https://github-api.kohsuke.org/",
75-
"size": 19552,
76-
"stargazers_count": 613,
77-
"watchers_count": 613,
75+
"size": 39875,
76+
"stargazers_count": 878,
77+
"watchers_count": 878,
7878
"language": "Java",
7979
"has_issues": true,
8080
"has_projects": true,
8181
"has_downloads": true,
8282
"has_wiki": true,
8383
"has_pages": true,
84-
"forks_count": 456,
84+
"forks_count": 601,
8585
"mirror_url": null,
8686
"archived": false,
8787
"disabled": false,
88-
"open_issues_count": 57,
88+
"open_issues_count": 99,
8989
"license": {
9090
"key": "mit",
9191
"name": "MIT License",
9292
"spdx_id": "MIT",
9393
"url": "https://api.github.com/licenses/mit",
9494
"node_id": "MDc6TGljZW5zZTEz"
9595
},
96-
"forks": 456,
97-
"open_issues": 57,
98-
"watchers": 613,
96+
"allow_forking": true,
97+
"is_template": false,
98+
"topics": [
99+
"api",
100+
"client-library",
101+
"github",
102+
"github-api",
103+
"github-api-v3",
104+
"java",
105+
"java-api"
106+
],
107+
"visibility": "public",
108+
"forks": 601,
109+
"open_issues": 99,
110+
"watchers": 878,
99111
"default_branch": "main",
100112
"permissions": {
101-
"admin": true,
102-
"push": true,
113+
"admin": false,
114+
"maintain": false,
115+
"push": false,
116+
"triage": false,
103117
"pull": true
104118
},
105119
"temp_clone_token": "",
106-
"allow_squash_merge": true,
107-
"allow_merge_commit": true,
108-
"allow_rebase_merge": true,
109-
"delete_branch_on_merge": false,
110120
"organization": {
111121
"login": "hub4j",
112122
"id": 54909825,
113123
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
114-
"avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
124+
"avatar_url": "https://avatars.githubusercontent.com/u/54909825?v=4",
115125
"gravatar_id": "",
116126
"url": "https://api.github.com/users/hub4j",
117127
"html_url": "https://github.com/hub4j",
@@ -127,6 +137,6 @@
127137
"type": "Organization",
128138
"site_admin": false
129139
},
130-
"network_count": 456,
131-
"subscribers_count": 47
140+
"network_count": 601,
141+
"subscribers_count": 48
132142
}
+19-4Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"login": "kohsuke",
1414
"id": 50003,
1515
"node_id": "MDQ6VXNlcjUwMDAz",
16-
"avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4",
16+
"avatar_url": "https://avatars.githubusercontent.com/u/50003?v=4",
1717
"gravatar_id": "",
1818
"url": "https://api.github.com/users/kohsuke",
1919
"html_url": "https://github.com/kohsuke",
@@ -39,13 +39,14 @@
3939
"created_at": "2016-11-17T02:40:08Z",
4040
"updated_at": "2016-11-17T02:40:11Z",
4141
"closed_at": "2016-11-17T02:40:11Z",
42-
"author_association": "MEMBER",
42+
"author_association": "COLLABORATOR",
43+
"active_lock_reason": null,
4344
"body": "",
4445
"closed_by": {
4546
"login": "kohsuke",
4647
"id": 50003,
4748
"node_id": "MDQ6VXNlcjUwMDAz",
48-
"avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4",
49+
"avatar_url": "https://avatars.githubusercontent.com/u/50003?v=4",
4950
"gravatar_id": "",
5051
"url": "https://api.github.com/users/kohsuke",
5152
"html_url": "https://github.com/kohsuke",
@@ -60,5 +61,19 @@
6061
"received_events_url": "https://api.github.com/users/kohsuke/received_events",
6162
"type": "User",
6263
"site_admin": false
63-
}
64+
},
65+
"reactions": {
66+
"url": "https://api.github.com/repos/hub4j/github-api/issues/311/reactions",
67+
"total_count": 1,
68+
"+1": 0,
69+
"-1": 0,
70+
"laugh": 0,
71+
"hooray": 0,
72+
"confused": 0,
73+
"heart": 1,
74+
"rocket": 0,
75+
"eyes": 0
76+
},
77+
"timeline_url": "https://api.github.com/repos/hub4j/github-api/issues/311/timeline",
78+
"performed_via_github_app": null
6479
}
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
{
2-
"id": 63220306,
3-
"node_id": "MDg6UmVhY3Rpb242MzIyMDMwNg==",
2+
"id": 158437739,
3+
"node_id": "REA_lAHOAAlq-s4LUe0lzglxkWs",
44
"user": {
5-
"login": "bitwiseman",
6-
"id": 1958953,
7-
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
8-
"avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4",
5+
"login": "gsmet",
6+
"id": 1279749,
7+
"node_id": "MDQ6VXNlcjEyNzk3NDk=",
8+
"avatar_url": "https://avatars.githubusercontent.com/u/1279749?v=4",
99
"gravatar_id": "",
10-
"url": "https://api.github.com/users/bitwiseman",
11-
"html_url": "https://github.com/bitwiseman",
12-
"followers_url": "https://api.github.com/users/bitwiseman/followers",
13-
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
14-
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
15-
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
16-
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
17-
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
18-
"repos_url": "https://api.github.com/users/bitwiseman/repos",
19-
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
20-
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
10+
"url": "https://api.github.com/users/gsmet",
11+
"html_url": "https://github.com/gsmet",
12+
"followers_url": "https://api.github.com/users/gsmet/followers",
13+
"following_url": "https://api.github.com/users/gsmet/following{/other_user}",
14+
"gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}",
15+
"starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}",
16+
"subscriptions_url": "https://api.github.com/users/gsmet/subscriptions",
17+
"organizations_url": "https://api.github.com/users/gsmet/orgs",
18+
"repos_url": "https://api.github.com/users/gsmet/repos",
19+
"events_url": "https://api.github.com/users/gsmet/events{/privacy}",
20+
"received_events_url": "https://api.github.com/users/gsmet/received_events",
2121
"type": "User",
2222
"site_admin": false
2323
},
2424
"content": "eyes",
25-
"created_at": "2020-02-23T03:15:56Z"
25+
"created_at": "2022-04-08T17:54:36Z"
2626
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.