Implement RSS feed parsing
This commit is contained in:
parent
a943be6c97
commit
7ecfedbf9a
10
Podfile.lock
10
Podfile.lock
|
@ -36,6 +36,7 @@ PODS:
|
|||
- Curve25519Kit/Tests (2.1.0):
|
||||
- CocoaLumberjack
|
||||
- SignalCoreKit
|
||||
- FeedKit (8.1.1)
|
||||
- GCDWebServer (3.5.2):
|
||||
- GCDWebServer/Core (= 3.5.2)
|
||||
- GCDWebServer/Core (3.5.2)
|
||||
|
@ -198,6 +199,7 @@ DEPENDENCIES:
|
|||
- CryptoSwift
|
||||
- Curve25519Kit (from `https://github.com/signalapp/Curve25519Kit`)
|
||||
- Curve25519Kit/Tests (from `https://github.com/signalapp/Curve25519Kit`)
|
||||
- FeedKit (~> 8.1)
|
||||
- GCDWebServer (~> 3.0)
|
||||
- GRKOpenSSLFramework (from `https://github.com/signalapp/GRKOpenSSLFramework`)
|
||||
- HKDFKit (from `https://github.com/signalapp/HKDFKit.git`)
|
||||
|
@ -224,6 +226,7 @@ SPEC REPOS:
|
|||
- AFNetworking
|
||||
- CocoaLumberjack
|
||||
- CryptoSwift
|
||||
- FeedKit
|
||||
- GCDWebServer
|
||||
- IGIdenticon
|
||||
- libPhoneNumber-iOS
|
||||
|
@ -297,6 +300,7 @@ SPEC CHECKSUMS:
|
|||
CocoaLumberjack: 2f44e60eb91c176d471fdba43b9e3eae6a721947
|
||||
CryptoSwift: d81eeaa59dc5a8d03720fe919a6fd07b51f7439f
|
||||
Curve25519Kit: b3e77b7152ebe95fee2b3fb6c955449492bc14f7
|
||||
FeedKit: 3418eed25f0b493b205b4de1b8511ac21d413fa9
|
||||
GCDWebServer: ead88cd14596dd4eae4f5830b8877c87c8728990
|
||||
GRKOpenSSLFramework: 8a3735ad41e7dc1daff460467bccd32ca5d6ae3e
|
||||
HKDFKit: 3b6dbbb9d59c221cc6c52c3aa915700cbf24e376
|
||||
|
@ -309,7 +313,7 @@ SPEC CHECKSUMS:
|
|||
SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c
|
||||
SignalCoreKit: c2d8132cdedb95d35eb2f8ae7eac0957695d0a8b
|
||||
SignalMetadataKit: 6fa5e9a53c7f104568662521a2f3874672ff7a02
|
||||
SignalServiceKit: 5c5b63a39d5054201ab59ef6daf0fa0a1a0c7887
|
||||
SignalServiceKit: 102576f58e17a5fe3093899adce7e7c192a7bee0
|
||||
SQLCipher: efbdb52cdbe340bcd892b1b14297df4e07241b7f
|
||||
SSZipArchive: 8e859da2520142e09166bc9161967db296e9d02f
|
||||
Starscream: ef3ece99d765eeccb67de105bfa143f929026cf5
|
||||
|
@ -317,6 +321,6 @@ SPEC CHECKSUMS:
|
|||
YapDatabase: b418a4baa6906e8028748938f9159807fd039af4
|
||||
YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54
|
||||
|
||||
PODFILE CHECKSUM: 10152a1fffafd51206b62fdd8cac86a5de8cf083
|
||||
PODFILE CHECKSUM: 95f41137d4fe8c5b8a27de951b328f8c9531d166
|
||||
|
||||
COCOAPODS: 1.7.2
|
||||
COCOAPODS: 1.5.3
|
||||
|
|
|
@ -3276,12 +3276,13 @@
|
|||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Signal/Pods-Signal-frameworks.sh",
|
||||
"${SRCROOT}/Pods/Target Support Files/Pods-Signal/Pods-Signal-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/AxolotlKit/AxolotlKit.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/CocoaLumberjack/CocoaLumberjack.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/Curve25519Kit/Curve25519Kit.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/FeedKit/FeedKit.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/GCDWebServer/GCDWebServer.framework",
|
||||
"${PODS_ROOT}/GRKOpenSSLFramework/OpenSSL-iOS/bin/openssl.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/HKDFKit/HKDFKit.framework",
|
||||
|
@ -3309,6 +3310,7 @@
|
|||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CocoaLumberjack.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Curve25519Kit.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FeedKit.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GCDWebServer.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HKDFKit.framework",
|
||||
|
@ -3331,7 +3333,7 @@
|
|||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Signal/Pods-Signal-frameworks.sh\"\n";
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Signal/Pods-Signal-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
6565655F4068F9E5CDC5687F /* [CP] Check Pods Manifest.lock */ = {
|
||||
|
@ -3358,7 +3360,7 @@
|
|||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-SignalTests/Pods-SignalTests-frameworks.sh",
|
||||
"${SRCROOT}/Pods/Target Support Files/Pods-SignalTests/Pods-SignalTests-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/AxolotlKit/AxolotlKit.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/CocoaLumberjack/CocoaLumberjack.framework",
|
||||
|
@ -3409,7 +3411,7 @@
|
|||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SignalTests/Pods-SignalTests-frameworks.sh\"\n";
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SignalTests/Pods-SignalTests-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
F4C416F20E3CB0B25DC10C56 /* [CP] Check Pods Manifest.lock */ = {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import FeedKit
|
||||
|
||||
@objc(LKGroupChatPoller)
|
||||
public final class LokiGroupChatPoller : NSObject {
|
||||
|
@ -9,7 +10,7 @@ public final class LokiGroupChatPoller : NSObject {
|
|||
private lazy var pollForNewMessagesInterval: TimeInterval = {
|
||||
switch group.kind {
|
||||
case .publicChat(_): return 4
|
||||
case .rss(_): return 4//8 * 60
|
||||
case .rss(_): return 8 * 60
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -72,12 +73,31 @@ public final class LokiGroupChatPoller : NSObject {
|
|||
}
|
||||
case .rss(_):
|
||||
let url = URL(string: group.server)!
|
||||
let parser = LokiRSSFeedParser(url: url)
|
||||
parser.parse { items in
|
||||
FeedParser(URL: url).parseAsync { wrapper in
|
||||
guard case .rss(let feed) = wrapper, let items = feed.items else { return print("[Loki] Failed to parse RSS feed for: \(group.server)") }
|
||||
items.reversed().forEach { item in
|
||||
print("Loki", "\(item.title ?? "nil"), \(item.description ?? "nil"), \(item.dateAsString ?? "nil")")
|
||||
let id = group.id.data(using: String.Encoding.utf8)!
|
||||
let x1 = SSKProtoGroupContext.builder(id: id, type: .deliver)
|
||||
x1.setName(group.displayName)
|
||||
let x2 = SSKProtoDataMessage.builder()
|
||||
guard let date = item.pubDate else { return }
|
||||
let timestamp = UInt64(date.timeIntervalSince1970 * 1000)
|
||||
x2.setTimestamp(timestamp)
|
||||
x2.setGroup(try! x1.build())
|
||||
guard let title = item.title, let description = item.description else { return }
|
||||
x2.setBody("\(title) ... \(description)")
|
||||
let x3 = SSKProtoContent.builder()
|
||||
x3.setDataMessage(try! x2.build())
|
||||
let x4 = SSKProtoEnvelope.builder(type: .ciphertext, timestamp: timestamp)
|
||||
x4.setSource(NSLocalizedString("Loki", comment: ""))
|
||||
x4.setSourceDevice(OWSDevicePrimaryDeviceId)
|
||||
x4.setContent(try! x3.build().serializedData())
|
||||
OWSPrimaryStorage.shared().dbReadWriteConnection.readWrite { transaction in
|
||||
SSKEnvironment.shared.messageManager.throws_processEnvelope(try! x4.build(), plaintextData: try! x3.build().serializedData(), wasReceivedByUD: false, transaction: transaction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2616,3 +2616,4 @@
|
|||
"You can enable camera access in your device settings." = "You can enable camera access in your device settings.";
|
||||
"Scan the QR code of the person you'd like to securely message. They can find their QR code by going into Loki Messenger's in-app settings and clicking \"Show QR Code\"." = "Scan the QR code of the person you'd like to securely message. They can find their QR code by going into Loki Messenger's in-app settings and clicking \"Show QR Code\".";
|
||||
"Scan QR Code" = "Scan QR Code";
|
||||
"Loki" = "Loki";
|
||||
|
|
Loading…
Reference in New Issue