use of org.signal.storageservice.protos.groups.GroupChanges in project Signal-Android by WhisperSystems.
the class PushServiceSocket method getGroupsV2GroupHistory.
public GroupHistory getGroupsV2GroupHistory(int fromVersion, GroupsV2AuthorizationString authorization, int highestKnownEpoch, boolean includeFirstState) throws IOException {
Response response = makeStorageRequestResponse(authorization.toString(), String.format(Locale.US, GROUPSV2_GROUP_CHANGES, fromVersion, highestKnownEpoch, includeFirstState), "GET", null, GROUPS_V2_GET_LOGS_HANDLER);
if (response.body() == null) {
throw new PushNetworkException("No body!");
}
GroupChanges groupChanges;
try (InputStream input = response.body().byteStream()) {
groupChanges = GroupChanges.parseFrom(input);
} catch (IOException e) {
throw new PushNetworkException(e);
}
if (response.code() == 206) {
String contentRangeHeader = response.header("Content-Range");
Optional<ContentRange> contentRange = ContentRange.parse(contentRangeHeader);
if (contentRange.isPresent()) {
Log.i(TAG, "Additional logs for group: " + contentRangeHeader);
return new GroupHistory(groupChanges, contentRange);
} else {
Log.w(TAG, "Unable to parse Content-Range header: " + contentRangeHeader);
throw new MalformedResponseException("Unable to parse content range header on 206");
}
}
return new GroupHistory(groupChanges, Optional.absent());
}
use of org.signal.storageservice.protos.groups.GroupChanges in project Signal-Android by signalapp.
the class PushServiceSocket method getGroupsV2GroupHistory.
public GroupHistory getGroupsV2GroupHistory(int fromVersion, GroupsV2AuthorizationString authorization, int highestKnownEpoch, boolean includeFirstState) throws IOException {
Response response = makeStorageRequestResponse(authorization.toString(), String.format(Locale.US, GROUPSV2_GROUP_CHANGES, fromVersion, highestKnownEpoch, includeFirstState), "GET", null, GROUPS_V2_GET_LOGS_HANDLER);
if (response.body() == null) {
throw new PushNetworkException("No body!");
}
GroupChanges groupChanges;
try (InputStream input = response.body().byteStream()) {
groupChanges = GroupChanges.parseFrom(input);
} catch (IOException e) {
throw new PushNetworkException(e);
}
if (response.code() == 206) {
String contentRangeHeader = response.header("Content-Range");
Optional<ContentRange> contentRange = ContentRange.parse(contentRangeHeader);
if (contentRange.isPresent()) {
Log.i(TAG, "Additional logs for group: " + contentRangeHeader);
return new GroupHistory(groupChanges, contentRange);
} else {
Log.w(TAG, "Unable to parse Content-Range header: " + contentRangeHeader);
throw new MalformedResponseException("Unable to parse content range header on 206");
}
}
return new GroupHistory(groupChanges, Optional.absent());
}
Aggregations