Modify MessageFetcherJob to handle incoming UD messages.

pull/1/head
Matthew Chen 7 years ago
parent 745abb672d
commit 1ac74cfb81

@ -9,11 +9,10 @@ import SignalServiceKit
@objc(OWSMessageFetcherJob) @objc(OWSMessageFetcherJob)
public class MessageFetcherJob: NSObject { public class MessageFetcherJob: NSObject {
private var timer : Timer? private var timer: Timer?
@objc @objc
public override init() public override init() {
{
super.init() super.init()
SwiftSingletons.register(self) SwiftSingletons.register(self)
@ -30,8 +29,7 @@ public class MessageFetcherJob: NSObject {
} }
private private
var signalService : OWSSignalService var signalService: OWSSignalService {
{
return OWSSignalService.sharedInstance() return OWSSignalService.sharedInstance()
} }
@ -139,24 +137,20 @@ private
throw ParamParser.ParseError.invalidFormat("type") throw ParamParser.ParseError.invalidFormat("type")
} }
guard let source: String = try params.required(key: "source") else {
Logger.error("`source` was invalid: \(typeInt)")
throw ParamParser.ParseError.invalidFormat("source")
}
guard let timestamp: UInt64 = try params.required(key: "timestamp") else { guard let timestamp: UInt64 = try params.required(key: "timestamp") else {
Logger.error("`timestamp` was invalid: \(typeInt)") Logger.error("`timestamp` was invalid: \(typeInt)")
throw ParamParser.ParseError.invalidFormat("timestamp") throw ParamParser.ParseError.invalidFormat("timestamp")
} }
guard let sourceDevice: UInt32 = try params.required(key: "sourceDevice") else { let builder = SSKProtoEnvelope.builder(type: type, timestamp: timestamp)
Logger.error("`sourceDevice` was invalid: \(typeInt)")
throw ParamParser.ParseError.invalidFormat("sourceDevice") if let source: String = try params.optional(key: "source") {
builder.setSource(source)
} }
let builder = SSKProtoEnvelope.builder(type: type, timestamp: timestamp) if let sourceDevice: UInt32 = try params.optional(key: "sourceDevice") {
builder.setSource(source) builder.setSourceDevice(sourceDevice)
builder.setSourceDevice(sourceDevice) }
if let legacyMessage = try params.optionalBase64EncodedData(key: "message") { if let legacyMessage = try params.optionalBase64EncodedData(key: "message") {
builder.setLegacyMessage(legacyMessage) builder.setLegacyMessage(legacyMessage)

Loading…
Cancel
Save