@@ -358,7 +358,7 @@ public List<FollowerResponse.Person> getXboxFriends() throws XboxFriendsExceptio
358358 */
359359 public boolean addXboxFriend (String xuid ) {
360360 HttpRequest xboxFriendRequest = HttpRequest .newBuilder ()
361- .uri (URI .create (Constants .PEOPLE + "/xuid(" + xuid + ")" ))
361+ .uri (URI .create (Constants .PEOPLE . formatted ( xuid ) ))
362362 .header ("Authorization" , getTokenHeader ())
363363 .PUT (HttpRequest .BodyPublishers .noBody ())
364364 .build ();
@@ -379,7 +379,7 @@ public boolean addXboxFriend(String xuid) {
379379 */
380380 public boolean removeXboxFriend (String xuid ) {
381381 HttpRequest xboxFriendRequest = HttpRequest .newBuilder ()
382- .uri (URI .create (Constants .PEOPLE + "/xuid(" + xuid + ")" ))
382+ .uri (URI .create (Constants .PEOPLE . formatted ( xuid ) ))
383383 .header ("Authorization" , getTokenHeader ())
384384 .DELETE ()
385385 .build ();
@@ -466,4 +466,24 @@ public void dumpSession() {
466466
467467 logger .info ("Dumped session responses to 'lastSessionResponse.json' and 'currentSessionResponse.json'" );
468468 }
469+
470+ public void updatePresence () {
471+ HttpRequest updatePresenceRequest = HttpRequest .newBuilder ()
472+ .uri (URI .create (Constants .USER_PRESENCE .formatted (getXboxToken ().userXUID )))
473+ .header ("Content-Type" , "application/json" )
474+ .header ("Authorization" , getTokenHeader ())
475+ .header ("x-xbl-contract-version" , "3" )
476+ .POST (HttpRequest .BodyPublishers .ofString ("{\" state\" : \" active\" }" ))
477+ .build ();
478+
479+ try {
480+ HttpResponse <Void > updatePresenceResponse = httpClient .send (updatePresenceRequest , HttpResponse .BodyHandlers .discarding ());
481+
482+ if (updatePresenceResponse .statusCode () != 200 ) {
483+ logger .error ("Failed to update presence, got status " + updatePresenceResponse .statusCode ());
484+ }
485+ } catch (IOException | InterruptedException e ) {
486+ throw new RuntimeException (e );
487+ }
488+ }
469489}
0 commit comments