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 0ef8b47

Browse filesBrowse files
committed
Added subscription related methods
1 parent 205950f commit 0ef8b47
Copy full SHA for 0ef8b47

File tree

Expand file treeCollapse file tree

2 files changed

+28
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+28
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHSubscription.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import java.util.Date;
55

66
/**
7-
* Represents your subscribing to a repository.
7+
* Represents your subscribing to a repository / conversation thread..
88
*
99
* @author Kohsuke Kawaguchi
10+
* @see GHRepository#getSubscription()
11+
* @see GHThread#getSubscription()
1012
*/
1113
public class GHSubscription {
1214
private String created_at, url, repository_url, reason;

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHThread.java
+25-1Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.kohsuke.github;
22

3+
import java.io.FileNotFoundException;
34
import java.io.IOException;
45
import java.util.Date;
56

@@ -17,7 +18,7 @@ public class GHThread extends GHObject {
1718
private String reason;
1819
private boolean unread;
1920
private String last_read_at;
20-
private String url;
21+
private String url,subscription_url;
2122

2223
static class Subject {
2324
String title;
@@ -71,4 +72,27 @@ public String getType() {
7172
public void markAsRead() throws IOException {
7273
new Requester(root).method("PATCH").to(url);
7374
}
75+
76+
/**
77+
* Subscribes to this conversation to get notifications.
78+
*/
79+
public GHSubscription subscribe(boolean subscribed, boolean ignored) throws IOException {
80+
return new Requester(root)
81+
.with("subscribed", subscribed)
82+
.with("ignored", ignored)
83+
.method("PUT").to(subscription_url, GHSubscription.class).wrapUp(root);
84+
}
85+
86+
/**
87+
* Returns the current subscription for this thread.
88+
*
89+
* @return null if no subscription exists.
90+
*/
91+
public GHSubscription getSubscription() throws IOException {
92+
try {
93+
return new Requester(root).to(subscription_url, GHSubscription.class).wrapUp(root);
94+
} catch (FileNotFoundException e) {
95+
return null;
96+
}
97+
}
7498
}

0 commit comments

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