|
|
@ -8,12 +8,14 @@ public final class FileServerAPI : DotNetAPI {
|
|
|
|
private static let attachmentType = "net.app.core.oembed"
|
|
|
|
private static let attachmentType = "net.app.core.oembed"
|
|
|
|
|
|
|
|
|
|
|
|
public static let maxFileSize = 10_000_000 // 10 MB
|
|
|
|
public static let maxFileSize = 10_000_000 // 10 MB
|
|
|
|
|
|
|
|
|
|
|
|
@objc public static let server = "https://file.getsession.org"
|
|
|
|
@objc public static let server = "https://file.getsession.org"
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Storage
|
|
|
|
// MARK: Storage
|
|
|
|
override internal class var authTokenCollection: String { return "LokiStorageAuthTokenCollection" }
|
|
|
|
override internal class var authTokenCollection: String { return "LokiStorageAuthTokenCollection" }
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Device Links
|
|
|
|
// MARK: Device Links
|
|
|
|
|
|
|
|
/// - Note: Deprecated.
|
|
|
|
@objc(getDeviceLinksAssociatedWithHexEncodedPublicKey:)
|
|
|
|
@objc(getDeviceLinksAssociatedWithHexEncodedPublicKey:)
|
|
|
|
public static func objc_getDeviceLinks(associatedWith hexEncodedPublicKey: String) -> AnyPromise {
|
|
|
|
public static func objc_getDeviceLinks(associatedWith hexEncodedPublicKey: String) -> AnyPromise {
|
|
|
|
return AnyPromise.from(getDeviceLinks(associatedWith: hexEncodedPublicKey))
|
|
|
|
return AnyPromise.from(getDeviceLinks(associatedWith: hexEncodedPublicKey))
|
|
|
@ -21,10 +23,13 @@ public final class FileServerAPI : DotNetAPI {
|
|
|
|
|
|
|
|
|
|
|
|
/// Gets the device links associated with the given hex encoded public key from the
|
|
|
|
/// Gets the device links associated with the given hex encoded public key from the
|
|
|
|
/// server and stores and returns the valid ones.
|
|
|
|
/// server and stores and returns the valid ones.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// - Note: Deprecated.
|
|
|
|
public static func getDeviceLinks(associatedWith hexEncodedPublicKey: String) -> Promise<Set<DeviceLink>> {
|
|
|
|
public static func getDeviceLinks(associatedWith hexEncodedPublicKey: String) -> Promise<Set<DeviceLink>> {
|
|
|
|
return getDeviceLinks(associatedWith: [ hexEncodedPublicKey ])
|
|
|
|
return getDeviceLinks(associatedWith: [ hexEncodedPublicKey ])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// - Note: Deprecated.
|
|
|
|
@objc(getDeviceLinksAssociatedWithHexEncodedPublicKeys:)
|
|
|
|
@objc(getDeviceLinksAssociatedWithHexEncodedPublicKeys:)
|
|
|
|
public static func objc_getDeviceLinks(associatedWith hexEncodedPublicKeys: Set<String>) -> AnyPromise {
|
|
|
|
public static func objc_getDeviceLinks(associatedWith hexEncodedPublicKeys: Set<String>) -> AnyPromise {
|
|
|
|
return AnyPromise.from(getDeviceLinks(associatedWith: hexEncodedPublicKeys))
|
|
|
|
return AnyPromise.from(getDeviceLinks(associatedWith: hexEncodedPublicKeys))
|
|
|
@ -32,6 +37,8 @@ public final class FileServerAPI : DotNetAPI {
|
|
|
|
|
|
|
|
|
|
|
|
/// Gets the device links associated with the given hex encoded public keys from the
|
|
|
|
/// Gets the device links associated with the given hex encoded public keys from the
|
|
|
|
/// server and stores and returns the valid ones.
|
|
|
|
/// server and stores and returns the valid ones.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// - Note: Deprecated.
|
|
|
|
public static func getDeviceLinks(associatedWith hexEncodedPublicKeys: Set<String>) -> Promise<Set<DeviceLink>> {
|
|
|
|
public static func getDeviceLinks(associatedWith hexEncodedPublicKeys: Set<String>) -> Promise<Set<DeviceLink>> {
|
|
|
|
let hexEncodedPublicKeysDescription = "[ \(hexEncodedPublicKeys.joined(separator: ", ")) ]"
|
|
|
|
let hexEncodedPublicKeysDescription = "[ \(hexEncodedPublicKeys.joined(separator: ", ")) ]"
|
|
|
|
print("[Loki] Getting device links for: \(hexEncodedPublicKeysDescription).")
|
|
|
|
print("[Loki] Getting device links for: \(hexEncodedPublicKeysDescription).")
|
|
|
@ -87,7 +94,8 @@ public final class FileServerAPI : DotNetAPI {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.handlingInvalidAuthTokenIfNeeded(for: server)
|
|
|
|
}.handlingInvalidAuthTokenIfNeeded(for: server)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// - Note: Deprecated.
|
|
|
|
public static func setDeviceLinks(_ deviceLinks: Set<DeviceLink>) -> Promise<Void> {
|
|
|
|
public static func setDeviceLinks(_ deviceLinks: Set<DeviceLink>) -> Promise<Void> {
|
|
|
|
print("[Loki] Updating device links.")
|
|
|
|
print("[Loki] Updating device links.")
|
|
|
|
return getAuthToken(for: server).then2 { token -> Promise<Void> in
|
|
|
|
return getAuthToken(for: server).then2 { token -> Promise<Void> in
|
|
|
@ -109,6 +117,8 @@ public final class FileServerAPI : DotNetAPI {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Adds the given device link to the user's device mapping on the server.
|
|
|
|
/// Adds the given device link to the user's device mapping on the server.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// - Note: Deprecated.
|
|
|
|
public static func addDeviceLink(_ deviceLink: DeviceLink) -> Promise<Void> {
|
|
|
|
public static func addDeviceLink(_ deviceLink: DeviceLink) -> Promise<Void> {
|
|
|
|
var deviceLinks: Set<DeviceLink> = []
|
|
|
|
var deviceLinks: Set<DeviceLink> = []
|
|
|
|
storage.dbReadConnection.read { transaction in
|
|
|
|
storage.dbReadConnection.read { transaction in
|
|
|
@ -121,6 +131,8 @@ public final class FileServerAPI : DotNetAPI {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Removes the given device link from the user's device mapping on the server.
|
|
|
|
/// Removes the given device link from the user's device mapping on the server.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// - Note: Deprecated.
|
|
|
|
public static func removeDeviceLink(_ deviceLink: DeviceLink) -> Promise<Void> {
|
|
|
|
public static func removeDeviceLink(_ deviceLink: DeviceLink) -> Promise<Void> {
|
|
|
|
var deviceLinks: Set<DeviceLink> = []
|
|
|
|
var deviceLinks: Set<DeviceLink> = []
|
|
|
|
storage.dbReadConnection.read { transaction in
|
|
|
|
storage.dbReadConnection.read { transaction in
|
|
|
|