|
1 | 1 | package network.radicle.jetbrains.radiclejetbrainsplugin.services; |
2 | 2 |
|
3 | | -import com.fasterxml.jackson.core.type.TypeReference; |
4 | 3 | import com.fasterxml.jackson.databind.DeserializationFeature; |
5 | 4 | import com.fasterxml.jackson.databind.ObjectMapper; |
6 | 5 | import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; |
|
11 | 10 | import com.intellij.openapi.application.ApplicationManager; |
12 | 11 | import com.intellij.openapi.project.Project; |
13 | 12 | import com.intellij.serviceContainer.NonInjectable; |
14 | | -import git4idea.repo.GitRepository; |
15 | 13 | import network.radicle.jetbrains.radiclejetbrainsplugin.RadicleBundle; |
16 | 14 | import network.radicle.jetbrains.radiclejetbrainsplugin.actions.rad.RadSelf; |
17 | 15 | import network.radicle.jetbrains.radiclejetbrainsplugin.config.RadicleProjectSettingsHandler; |
@@ -93,55 +91,6 @@ public SeedNodeInfo checkApi(SeedNode node, boolean showNotif) { |
93 | 91 | } |
94 | 92 | } |
95 | 93 |
|
96 | | - public RadIssue editIssueComment(RadIssue issue, String comment, String id, List<Embed> embedList) { |
97 | | - var session = createAuthenticatedSession(); |
98 | | - if (session == null) { |
99 | | - return null; |
100 | | - } |
101 | | - try { |
102 | | - var issueReq = new HttpPatch(getHttpNodeUrl() + "/api/v1/projects/" + issue.projectId + "/issues/" + issue.id); |
103 | | - issueReq.setHeader("Authorization", "Bearer " + session.sessionId); |
104 | | - var patchIssueData = Map.of("type", "comment.edit", "id", id, "body", comment, "replyTo", issue.id, "embeds", embedList); |
105 | | - var json = MAPPER.writeValueAsString(patchIssueData); |
106 | | - issueReq.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON)); |
107 | | - var resp = makeRequest(issueReq, RadicleBundle.message("commentEditError"), RadicleBundle.message("commentDescError")); |
108 | | - if (!resp.isSuccess()) { |
109 | | - logger.warn("error editing comment: {} to issue:{} resp:{}", comment, issue, resp); |
110 | | - return null; |
111 | | - } |
112 | | - return issue; |
113 | | - } catch (Exception e) { |
114 | | - logger.warn("error editing issue comment: {}", issue, e); |
115 | | - } |
116 | | - return null; |
117 | | - } |
118 | | - |
119 | | - public String createPatch(String title, String description, List<String> labels, String baseOid, String patchOid, GitRepository repo, String projectId) { |
120 | | - var session = createAuthenticatedSession(); |
121 | | - if (session == null) { |
122 | | - return null; |
123 | | - } |
124 | | - try { |
125 | | - var patchReq = new HttpPost(getHttpNodeUrl() + "/api/v1/projects/" + projectId + "/patches"); |
126 | | - patchReq.setHeader("Authorization", "Bearer " + session.sessionId); |
127 | | - var patchIssueData = Map.of("title", title, "description", description, "oid", patchOid, "target", baseOid, "labels", labels); |
128 | | - var json = MAPPER.writeValueAsString(patchIssueData); |
129 | | - patchReq.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON)); |
130 | | - var resp = makeRequest(patchReq, RadicleBundle.message("createPatchError")); |
131 | | - if (!resp.isSuccess()) { |
132 | | - logger.warn("error creating new patch title:{} description:{} base_oid:{} patch_oid:{} repo:{} projectId:{}", |
133 | | - title, description, baseOid, patchOid, repo, projectId); |
134 | | - return null; |
135 | | - } |
136 | | - var map = (Map<String, String>) MAPPER.readValue(resp.body, new TypeReference<>() { }); |
137 | | - return map.get("id"); |
138 | | - } catch (Exception e) { |
139 | | - logger.warn("exception creating new patch title:{} description:{} base_oid:{} patch_oid:{} repo:{} projectId:{}", |
140 | | - title, description, baseOid, patchOid, repo, projectId, e); |
141 | | - } |
142 | | - return null; |
143 | | - } |
144 | | - |
145 | 94 | public RadPatch deleteRevisionComment(RadPatch patch, String revId, String commentId) { |
146 | 95 | var session = createAuthenticatedSession(); |
147 | 96 | if (session == null) { |
@@ -189,53 +138,6 @@ public RadPatch patchCommentReact(RadPatch patch, String commendId, String revId |
189 | 138 | return null; |
190 | 139 | } |
191 | 140 |
|
192 | | - public RadIssue issueCommentReact(RadIssue issue, String discussionId, String reaction, boolean active) { |
193 | | - var session = createAuthenticatedSession(); |
194 | | - if (session == null) { |
195 | | - return null; |
196 | | - } |
197 | | - try { |
198 | | - var issueReq = new HttpPatch(getHttpNodeUrl() + "/api/v1/projects/" + issue.projectId + "/issues/" + issue.id); |
199 | | - issueReq.setHeader("Authorization", "Bearer " + session.sessionId); |
200 | | - var issueData = Map.of("type", "comment.react", "id", discussionId, "reaction", reaction, "active", active); |
201 | | - var json = MAPPER.writeValueAsString(issueData); |
202 | | - issueReq.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON)); |
203 | | - var resp = makeRequest(issueReq, RadicleBundle.message("reactionError")); |
204 | | - if (!resp.isSuccess()) { |
205 | | - logger.warn("error reacting to discussion:{} resp:{}", discussionId, resp); |
206 | | - return null; |
207 | | - } |
208 | | - return issue; |
209 | | - } catch (Exception e) { |
210 | | - logger.warn("error reacting to discussion: {}", discussionId, e); |
211 | | - } |
212 | | - |
213 | | - return null; |
214 | | - } |
215 | | - |
216 | | - public RadIssue changeIssueTitle(RadIssue issue) { |
217 | | - var session = createAuthenticatedSession(); |
218 | | - if (session == null) { |
219 | | - return null; |
220 | | - } |
221 | | - try { |
222 | | - var issueReq = new HttpPatch(getHttpNodeUrl() + "/api/v1/projects/" + issue.projectId + "/issues/" + issue.id); |
223 | | - issueReq.setHeader("Authorization", "Bearer " + session.sessionId); |
224 | | - var patchEditData = Map.of("type", "edit", "title", issue.title); |
225 | | - var json = MAPPER.writeValueAsString(patchEditData); |
226 | | - issueReq.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON)); |
227 | | - var resp = makeRequest(issueReq, RadicleBundle.message("issueTitleError")); |
228 | | - if (!resp.isSuccess()) { |
229 | | - logger.warn("received invalid response with status:{} and body:{} while editing patch: {}", |
230 | | - resp.status, resp.body, issue); |
231 | | - } |
232 | | - return issue; |
233 | | - } catch (Exception e) { |
234 | | - logger.warn("error changing issue title: {}", issue, e); |
235 | | - } |
236 | | - return null; |
237 | | - } |
238 | | - |
239 | 141 | public RadPatch changePatchComment(String revisionId, String commentId, String body, RadPatch patch, List<Embed> embedList) { |
240 | 142 | var session = createAuthenticatedSession(); |
241 | 143 | if (session == null) { |
|
0 commit comments