mirror of
https://github.com/nextcloud/talk-android
synced 2025-01-31 19:42:34 +00:00
Fix old APIs
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
68369873f4
commit
f32b25c455
@ -155,19 +155,32 @@ public class ApiUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Integer getApiVersion(UserEntity capabilities, String apiName, int[] versions) {
|
public static Integer getApiVersion(UserEntity capabilities, String apiName, int[] versions) {
|
||||||
boolean checkedConversationV4 = !apiName.equals("conversation");
|
if (apiName.equals("conversation")) {
|
||||||
|
boolean hasApiV4 = false;
|
||||||
|
for (int version : versions) {
|
||||||
|
hasApiV4 |= version == 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasApiV4) {
|
||||||
|
Exception e = new Exception("Api call did not try conversation-v4 api");
|
||||||
|
Log.d(TAG, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int version : versions) {
|
for (int version : versions) {
|
||||||
checkedConversationV4 |= version == 4;
|
|
||||||
|
|
||||||
if (capabilities.hasSpreedFeatureCapability(apiName + "-v" + version)) {
|
if (capabilities.hasSpreedFeatureCapability(apiName + "-v" + version)) {
|
||||||
if (!checkedConversationV4) {
|
|
||||||
Exception e = new Exception("Api call did not try conversation-v4 api");
|
|
||||||
Log.e(TAG, e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback for old API versions
|
||||||
|
if (apiName.equals("conversation") && (version == 1 || version == 2)) {
|
||||||
|
if (capabilities.hasSpreedFeatureCapability(apiName + "-v2")) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
if (version == 1 && capabilities.hasSpreedFeatureCapability(apiName)) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user