mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 22:29:09 +00:00
Use injected capabilities
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
2fd0933383
commit
01813d4165
@ -176,13 +176,44 @@ public class OperationsMenuController extends BaseController {
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(baseUrl) && !baseUrl.equals(currentUser.getBaseUrl())) {
|
||||
fetchCapabilitiesForGuest();
|
||||
if (serverCapabilities != null) {
|
||||
try {
|
||||
useBundledCapabilitiesForGuest();
|
||||
} catch (IOException e) {
|
||||
// Fall back to fetching capabilities again
|
||||
fetchCapabilitiesForGuest();
|
||||
}
|
||||
} else {
|
||||
fetchCapabilitiesForGuest();
|
||||
}
|
||||
} else {
|
||||
processOperation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
private void useBundledCapabilitiesForGuest() throws IOException {
|
||||
currentUser = new UserEntity();
|
||||
currentUser.setBaseUrl(baseUrl);
|
||||
currentUser.setUserId("?");
|
||||
try {
|
||||
currentUser.setCapabilities(LoganSquare.serialize(serverCapabilities));
|
||||
} catch (IOException e) {
|
||||
Log.e("OperationsMenu", "Failed to serialize capabilities");
|
||||
throw e;
|
||||
}
|
||||
|
||||
try {
|
||||
checkCapabilities(currentUser);
|
||||
processOperation();
|
||||
} catch (NoSupportedApiException e) {
|
||||
showResultImage(false, false);
|
||||
Log.d(TAG, "No supported server version found", e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
private void fetchCapabilitiesForGuest() {
|
||||
ncApi.getCapabilities(null, ApiUtils.getUrlForCapabilities(baseUrl))
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
Loading…
Reference in New Issue
Block a user