This repository was archived by the owner on Jul 31, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
main/java/org/kohsuke/github
test/java/org/kohsuke/github Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -189,5 +189,19 @@ public void remove() {
189189 };
190190 }
191191
192+ public void markAsRead () throws IOException {
193+ markAsRead (-1 );
194+ }
195+
196+ /**
197+ * Marks all the notifications as read.
198+ */
199+ public void markAsRead (long timestamp ) throws IOException {
200+ final Requester req = new Requester (root ).method ("PUT" );
201+ if (timestamp >=0 )
202+ req .with ("last_read_at" , GitHub .printDate (new Date (timestamp )));
203+ req .asHttpStatusCode (apiUrl );
204+ }
205+
192206 private static final GHThread [] EMPTY_ARRAY = new GHThread [0 ];
193207}
Original file line number Diff line number Diff line change @@ -810,7 +810,7 @@ public void searchContent() throws Exception {
810810 @ Test
811811 public void notifications () throws Exception {
812812 boolean found =false ;
813- for (GHThread t : gitHub .listNotifications ().nonBlocking (true )) {
813+ for (GHThread t : gitHub .listNotifications ().nonBlocking (true ). read ( true ) ) {
814814 found = true ;
815815 assertNotNull (t .getTitle ());
816816 assertNotNull (t .getReason ());
@@ -821,6 +821,7 @@ public void notifications() throws Exception {
821821 System .out .println ();
822822 }
823823 assertTrue (found );
824+ gitHub .listNotifications ().markAsRead ();
824825 }
825826
826827 private void kohsuke () {
You can’t perform that action at this time.
0 commit comments