This repository was archived by the owner on Jul 31, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed
main/java/org/kohsuke/github
test/java/org/kohsuke/github Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ GHThread fetch() {
141141 long nt = n .getUpdatedAt ().getTime ();
142142 if (nt >= lastUpdated ) {
143143 lastUpdated = nt ;
144- return n ;
144+ return n . wrap ( root ) ;
145145 }
146146 }
147147
Original file line number Diff line number Diff line change 11package org .kohsuke .github ;
22
3+ import java .io .IOException ;
34import java .util .Date ;
45
56/**
67 * A conversation in the notification API.
78 *
8- *
99 * @see <a href="https://developer.github.com/v3/activity/notifications/">documentation</a>
10+ * @see GHNotificationStream
1011 * @author Kohsuke Kawaguchi
1112 */
1213public class GHThread extends GHObject {
14+ private GitHub root ;
1315 private GHRepository repository ;
1416 private Subject subject ;
1517 private String reason ;
1618 private boolean unread ;
1719 private String last_read_at ;
20+ private String url ;
1821
1922 static class Subject {
2023 String title ;
@@ -54,4 +57,18 @@ public String getTitle() {
5457 public String getType () {
5558 return subject .type ;
5659 }
60+
61+ /*package*/ GHThread wrap (GitHub root ) {
62+ this .root = root ;
63+ if (this .repository !=null )
64+ this .repository .wrap (root );
65+ return this ;
66+ }
67+
68+ /**
69+ * Marks this thread as read.
70+ */
71+ public void markAsRead () throws IOException {
72+ new Requester (root ).method ("PATCH" ).to (url );
73+ }
5774}
Original file line number Diff line number Diff line change @@ -811,7 +811,10 @@ public void searchContent() throws Exception {
811811 public void notifications () throws Exception {
812812 boolean found =false ;
813813 for (GHThread t : gitHub .listNotifications ().nonBlocking (true ).read (true )) {
814- found = true ;
814+ if (!found ) {
815+ found = true ;
816+ t .markAsRead (); // test this by calling it once on old nofication
817+ }
815818 assertNotNull (t .getTitle ());
816819 assertNotNull (t .getReason ());
817820
You can’t perform that action at this time.
0 commit comments