Skip to content

Commit 0c8b8a3

Browse files
committed
Add followers back to friends list request options
1 parent b48d02e commit 0c8b8a3

5 files changed

Lines changed: 95 additions & 28 deletions

File tree

bootstrap/standalone/src/main/java/com/rtm516/mcxboxbroadcast/bootstrap/standalone/StandaloneMain.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public static void main(String[] args) throws Exception {
2121
sessionInfo.setIp("51.210.124.95");
2222
sessionInfo.setPort(19132);
2323

24+
logger.info("Creating session...");
25+
2426
sessionManager.createSession(sessionInfo);
2527

2628
logger.info("Created session!");

core/src/main/java/com/rtm516/mcxboxbroadcast/core/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ public class Constants {
2424
public static final URI CREATE_HANDLE = URI.create("https://sessiondirectory.xboxlive.com/handles");
2525

2626
public static final String PEOPLE = "https://social.xboxlive.com/users/me/people";
27+
public static final URI FOLLOWERS = URI.create("https://peoplehub.xboxlive.com/users/me/people/followers");
2728
}

core/src/main/java/com/rtm516/mcxboxbroadcast/core/SessionManager.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.rtm516.mcxboxbroadcast.core.exceptions.XboxFriendsException;
77
import com.rtm516.mcxboxbroadcast.core.models.CreateHandleRequest;
88
import com.rtm516.mcxboxbroadcast.core.models.CreateSessionRequest;
9-
import com.rtm516.mcxboxbroadcast.core.models.PeopleResponse;
9+
import com.rtm516.mcxboxbroadcast.core.models.FollowerResponse;
1010
import com.rtm516.mcxboxbroadcast.core.models.XboxTokenInfo;
1111

1212
import java.io.File;
@@ -260,28 +260,34 @@ public void checkConnection() {
260260
/**
261261
* Get a list of friends XUIDs
262262
*
263+
* @param includeFollowing Include users that are following us and not full friends
264+
* @param includeFollowedBy Include users that we are following and not full friends
263265
* @return A list of XUIDs of your friends
264266
* @throws XboxFriendsException If there was an error getting friends from Xbox Live
265267
*/
266-
public List<String> getXboxFriends() throws XboxFriendsException {
268+
public List<String> getXboxFriends(boolean includeFollowing, boolean includeFollowedBy) throws XboxFriendsException {
267269
List<String> xuids = new ArrayList<>();
268270

269271
// Create the request for getting the users friends
270-
HttpRequest xboxPeopleRequest = HttpRequest.newBuilder()
271-
.uri(URI.create(Constants.PEOPLE))
272+
HttpRequest xboxFollowerRequest = HttpRequest.newBuilder()
273+
.uri(Constants.FOLLOWERS)
272274
.header("Authorization", getTokenHeader())
275+
.header("x-xbl-contract-version", "5")
276+
.header("accept-language", "en-GB")
273277
.GET()
274278
.build();
275279

276280
try {
277281
// Get the list of friends from the api
278-
PeopleResponse xboxPeopleResponse = Constants.OBJECT_MAPPER.readValue(httpClient.send(xboxPeopleRequest, HttpResponse.BodyHandlers.ofString()).body(), PeopleResponse.class);
282+
FollowerResponse xboxFollowerResponse = Constants.OBJECT_MAPPER.readValue(httpClient.send(xboxFollowerRequest, HttpResponse.BodyHandlers.ofString()).body(), FollowerResponse.class);
279283

280284
// Parse through the returned list to make sure we are friends and
281285
// add them to the list to return
282-
for (PeopleResponse.Person person : xboxPeopleResponse.people) {
286+
for (FollowerResponse.Person person : xboxFollowerResponse.people) {
283287
// Make sure they are full friends
284-
if (person.isFollowedByCaller && person.isFollowingCaller) {
288+
if ((person.isFollowedByCaller && person.isFollowingCaller)
289+
|| (includeFollowing && person.isFollowingCaller)
290+
|| (includeFollowedBy && person.isFollowedByCaller)) {
285291
xuids.add(person.xuid);
286292
}
287293
}
@@ -292,6 +298,13 @@ public List<String> getXboxFriends() throws XboxFriendsException {
292298
return xuids;
293299
}
294300

301+
/**
302+
* @see #getXboxFriends(boolean, boolean)
303+
*/
304+
public List<String> getXboxFriends() throws XboxFriendsException {
305+
return getXboxFriends(false, false);
306+
}
307+
295308
/**
296309
* Add a friend from xbox live
297310
*
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.rtm516.mcxboxbroadcast.core.models;
2+
3+
import java.util.Date;
4+
import java.util.List;
5+
6+
public class FollowerResponse {
7+
public Object accountLinkDetails;
8+
public Object friendFinderState;
9+
public List<Person> people;
10+
public Object recommendationSummary;
11+
12+
public static class Follower {
13+
public Date followedDateTime;
14+
public String text;
15+
}
16+
17+
public static class LinkedAccount {
18+
public Object deeplink;
19+
public String displayName;
20+
public boolean isFamilyFriendly;
21+
public String networkName;
22+
public boolean showOnProfile;
23+
}
24+
25+
public static class Person {
26+
public Object addedDateTimeUtc;
27+
public Object avatar;
28+
public Object broadcast;
29+
public String colorTheme;
30+
public Object communityManagerTitles;
31+
public Object detail;
32+
public String displayName;
33+
public String displayPicRaw;
34+
public Follower follower;
35+
public String gamerScore;
36+
public String gamertag;
37+
public boolean isBroadcasting;
38+
public Object isCloaked;
39+
public boolean isFavorite;
40+
public boolean isFollowedByCaller;
41+
public boolean isFollowingCaller;
42+
public boolean isIdentityShared;
43+
public boolean isQuarantined;
44+
public boolean isXbox360Gamerpic;
45+
public Date lastSeenDateTimeUtc;
46+
public List<LinkedAccount> linkedAccounts;
47+
public String modernGamertag;
48+
public String modernGamertagSuffix;
49+
public Object multiplayerSummary;
50+
public Object preferredColor;
51+
public String preferredFlag;
52+
public List<String> preferredPlatforms;
53+
public Object presenceDetails;
54+
public Object presenceDevices;
55+
public String presenceState;
56+
public String presenceText;
57+
public Object presenceTitleIds;
58+
public String realName;
59+
public Object recentPlayer;
60+
public Object recommendation;
61+
public Object search;
62+
public String showUserAsAvatar;
63+
public Object socialManager;
64+
public Object suggestion;
65+
public Object titleHistory;
66+
public Object titlePresence;
67+
public Object titleSummaries;
68+
public String uniqueModernGamertag;
69+
public String xboxOneRep;
70+
public String xuid;
71+
}
72+
}

core/src/main/java/com/rtm516/mcxboxbroadcast/core/models/PeopleResponse.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)