mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
minor refactoring
- extract method to register device at proxy - rename method Signed-off-by: Marcel Hibbe <dev@mhibbe.de> Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
0880a792a8
commit
bd4208f709
@ -283,7 +283,7 @@ public interface NcApi {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST
|
||||
Observable<Void> registerDeviceForNotificationsWithProxy(@Url String url,
|
||||
Observable<Void> registerDeviceForNotificationsWithPushProxy(@Url String url,
|
||||
@FieldMap Map<String, String> fields);
|
||||
|
||||
|
||||
|
@ -284,7 +284,33 @@ public class PushUtils {
|
||||
proxyMap.put("userPublicKey", pushRegistrationOverall.getOcs()
|
||||
.getData().getPublicKey());
|
||||
|
||||
ncApi.registerDeviceForNotificationsWithProxy(
|
||||
registerDeviceWithPushProxy(pushRegistrationOverall, proxyMap, token, userEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
eventBus.post(new EventStatus(userEntity.getId(),
|
||||
EventStatus.EventType.PUSH_REGISTRATION, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
// unused atm
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerDeviceWithPushProxy(
|
||||
@androidx.annotation.NonNull PushRegistrationOverall pushRegistrationOverall,
|
||||
Map<String, String> proxyMap,
|
||||
String token,
|
||||
UserEntity userEntity) {
|
||||
ncApi.registerDeviceForNotificationsWithPushProxy(
|
||||
ApiUtils.getUrlPushProxy(), proxyMap)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new Observer<Void>() {
|
||||
@ -357,24 +383,6 @@ public class PushUtils {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
eventBus.post(new EventStatus(userEntity.getId(),
|
||||
EventStatus.EventType.PUSH_REGISTRATION, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
// unused atm
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Key readKeyFromString(boolean readPublicKey, String keyString) {
|
||||
if (readPublicKey) {
|
||||
keyString = keyString.replaceAll("\\n", "").replace("-----BEGIN PUBLIC KEY-----",
|
||||
|
Loading…
Reference in New Issue
Block a user