Update Pods

pull/272/head
nielsandriesse 5 years ago
parent 3977f058a9
commit 0fd1b5c3d7

@ -1 +1 @@
Subproject commit 06051dd2a8aeb819363f6e77de58a038c1ad705e Subproject commit 6f712e2f01bf9a32fb6a9736c09f06ba4e13d852

@ -1,10 +1,10 @@
import SwiftCSV //import SwiftCSV
final class IP2Country { final class IP2Country {
var countryNamesCache: [String:String] = [:] var countryNamesCache: [String:String] = [:]
private lazy var ipv4Table = try! CSV(name: "GeoLite2-Country-Blocks-IPv4", extension: "csv", bundle: .main, delimiter: ",", encoding: .utf8, loadColumns: true)! // private lazy var ipv4Table = try! CSV(name: "GeoLite2-Country-Blocks-IPv4", extension: "csv", bundle: .main, delimiter: ",", encoding: .utf8, loadColumns: true)!
private lazy var countryNamesTable = try! CSV(name: "GeoLite2-Country-Locations-English", extension: "csv", bundle: .main, delimiter: ",", encoding: .utf8, loadColumns: true)! // private lazy var countryNamesTable = try! CSV(name: "GeoLite2-Country-Locations-English", extension: "csv", bundle: .main, delimiter: ",", encoding: .utf8, loadColumns: true)!
private static let workQueue = DispatchQueue(label: "IP2Country.workQueue", qos: .utility) // It's important that this is a serial queue private static let workQueue = DispatchQueue(label: "IP2Country.workQueue", qos: .utility) // It's important that this is a serial queue
@ -25,22 +25,23 @@ final class IP2Country {
private func cacheCountry(for ip: String) -> String { private func cacheCountry(for ip: String) -> String {
var truncatedIP = ip var truncatedIP = ip
func getCountryInternal() -> String { func getCountryInternal() -> String {
if let country = countryNamesCache[ip] { return country } return "Mars"
if let ipv4TableIndex = ipv4Table.namedColumns["network"]!.firstIndex(where: { $0.starts(with: truncatedIP) }) { // if let country = countryNamesCache[ip] { return country }
let countryID = ipv4Table.namedColumns["registered_country_geoname_id"]![ipv4TableIndex] // if let ipv4TableIndex = ipv4Table.namedColumns["network"]!.firstIndex(where: { $0.starts(with: truncatedIP) }) {
if let countryNamesTableIndex = countryNamesTable.namedColumns["geoname_id"]!.firstIndex(of: countryID) { // let countryID = ipv4Table.namedColumns["registered_country_geoname_id"]![ipv4TableIndex]
let country = countryNamesTable.namedColumns["country_name"]![countryNamesTableIndex] // if let countryNamesTableIndex = countryNamesTable.namedColumns["geoname_id"]!.firstIndex(of: countryID) {
countryNamesCache[ip] = country // let country = countryNamesTable.namedColumns["country_name"]![countryNamesTableIndex]
return country // countryNamesCache[ip] = country
} // return country
} // }
if truncatedIP.contains(".") && !truncatedIP.hasSuffix(".") { // The fuzziest we want to go is xxx.x // }
truncatedIP.removeLast() // if truncatedIP.contains(".") && !truncatedIP.hasSuffix(".") { // The fuzziest we want to go is xxx.x
if truncatedIP.hasSuffix(".") { truncatedIP.removeLast() } // truncatedIP.removeLast()
return getCountryInternal() // if truncatedIP.hasSuffix(".") { truncatedIP.removeLast() }
} else { // return getCountryInternal()
return "Unknown Country" // } else {
} // return "Unknown Country"
// }
} }
return getCountryInternal() return getCountryInternal()
} }

@ -12,7 +12,7 @@ import PromiseKit
/// See [the documentation](https://github.com/loki-project/session-protocol-docs/wiki/Medium-Size-Groups) for more information. /// See [the documentation](https://github.com/loki-project/session-protocol-docs/wiki/Medium-Size-Groups) for more information.
@objc(LKClosedGroupsProtocol) @objc(LKClosedGroupsProtocol)
public final class ClosedGroupsProtocol : NSObject { public final class ClosedGroupsProtocol : NSObject {
public static let isSharedSenderKeysEnabled = false public static let isSharedSenderKeysEnabled = true
public static let groupSizeLimit = 10 public static let groupSizeLimit = 10
// MARK: - Sending // MARK: - Sending

@ -75,7 +75,6 @@ NS_ASSUME_NONNULL_BEGIN
[unreadMessages enumerateKeysAndObjectsInGroup:groupID [unreadMessages enumerateKeysAndObjectsInGroup:groupID
usingBlock:^(NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) { usingBlock:^(NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) {
if (![object conformsToProtocol:@protocol(OWSReadTracking)]) { if (![object conformsToProtocol:@protocol(OWSReadTracking)]) {
OWSFailDebug(@"Unexpected object in unread messages: %@", [object class]);
return; return;
} }
id<OWSReadTracking> unread = (id<OWSReadTracking>)object; id<OWSReadTracking> unread = (id<OWSReadTracking>)object;

Loading…
Cancel
Save