diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesClient.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesClient.java index 8b8f79c413ea2f2a5673a36e6c3405e1b9ca50a5..700898b990dec95e69b1ed6b25e44c93ca5ed8aa 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesClient.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesClient.java @@ -7,16 +7,9 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.WorkerThread; -import com.nextcloud.android.sso.api.ParsedResponse; import com.nextcloud.android.sso.model.SingleSignOnAccount; -import java.util.Map; - -import it.niedermann.owncloud.notes.persistence.sync.OcsAPI; import it.niedermann.owncloud.notes.shared.model.Capabilities; -import it.niedermann.owncloud.notes.shared.model.OcsResponse; -import it.niedermann.owncloud.notes.shared.model.OcsUser; -import retrofit2.Response; @WorkerThread public class CapabilitiesClient { @@ -53,7 +46,7 @@ public class CapabilitiesClient { public static String getDisplayName(@NonNull Context context, @NonNull SingleSignOnAccount ssoAccount, @NonNull ApiProvider apiProvider) { final var ocsAPI = apiProvider.getOcsAPI(context, ssoAccount); try { - final var userResponse = ocsAPI.getUser(ssoAccount.userId).execute(); + final var userResponse = ocsAPI.getUser(sanitizeUserId(ssoAccount.userId)).execute(); if (userResponse.isSuccessful()) { final var ocsResponse = userResponse.body(); if (ocsResponse != null) { @@ -69,4 +62,15 @@ public class CapabilitiesClient { } return null; } + + @NonNull + private static String sanitizeUserId(@NonNull String userId) { + int endIndex = userId.lastIndexOf("@"); + + if (endIndex < 0) { + return userId; + } + + return userId.substring(0, endIndex); + } }