Add group chat authorization endpoint

pull/37/head
Niels Andriesse 6 years ago
parent 130b9a70e5
commit 0130950050

@ -152,7 +152,7 @@ public class OnboardingController: NSObject {
// from the "code verification" view. The "Captcha" view should always appear
// immediately after the "phone number" view.
while navigationController.viewControllers.count > 1 &&
!(navigationController.topViewController is OnboardingAccountDetailsViewController) {
!(navigationController.topViewController is AccountDetailsViewController) {
navigationController.popViewController(animated: false)
}

@ -18,7 +18,18 @@ public final class LokiGroupChatAPI : NSObject {
}
public enum Error : Swift.Error {
case messageParsingFailed
case tokenParsingFailed, messageParsingFailed
}
public static func getEncryptedToken() -> Promise<String> {
print("[Loki] Getting group chat auth token.")
let url = URL(string: "\(serverURL)/loki/v1/getToken")!
let parameters = [ "pubKey" : userHexEncodedPublicKey ]
let request = TSRequest(url: url, method: "POST", parameters: parameters)
return TSNetworkManager.shared().makePromise(request: request).map { $0.responseObject }.map { rawResponse in
guard let json = rawResponse as? JSON, let encryptedToken = json["cipherText64"] as? String else { throw Error.tokenParsingFailed }
return encryptedToken
}
}
public static func getMessages(for group: UInt) -> Promise<[LokiGroupMessage]> {

Loading…
Cancel
Save