This commit is contained in:
ryanzhao 2020-04-06 12:02:55 +10:00
parent c8f5172cdc
commit 6aec747709
4 changed files with 4 additions and 13 deletions

View File

@ -45,7 +45,7 @@ class NotificationService: UNNotificationServiceExtension {
let contentProto = try? SSKProtoContent.parseData(result.plaintextData!) let contentProto = try? SSKProtoContent.parseData(result.plaintextData!)
var thread: TSThread var thread: TSThread
var newNotificationBody = "" var newNotificationBody = ""
let masterHexEncodedPublicKey: String = LokiDatabaseUtilities.objc_getMasterHexEncodedPublicKey(for: result.source, in: transaction) ?? result.source let masterHexEncodedPublicKey: String = OWSPrimaryStorage.shared().getMasterHexEncodedPublicKey(for: result.source, in: transaction) ?? result.source
var displayName = masterHexEncodedPublicKey var displayName = masterHexEncodedPublicKey
if let groupId = contentProto?.dataMessage?.group?.id { if let groupId = contentProto?.dataMessage?.group?.id {
thread = TSGroupThread.getOrCreateThread(withGroupId: groupId, groupType: .closedGroup, transaction: transaction) thread = TSGroupThread.getOrCreateThread(withGroupId: groupId, groupType: .closedGroup, transaction: transaction)

View File

@ -271,7 +271,7 @@ public final class LokiAPI : NSObject {
if let lastMessage = rawMessages.last, let hashValue = lastMessage["hash"] as? String, let expirationDate = lastMessage["expiration"] as? Int { if let lastMessage = rawMessages.last, let hashValue = lastMessage["hash"] as? String, let expirationDate = lastMessage["expiration"] as? Int {
setLastMessageHashValue(for: target, hashValue: hashValue, expirationDate: UInt64(expirationDate)) setLastMessageHashValue(for: target, hashValue: hashValue, expirationDate: UInt64(expirationDate))
if UserDefaults.standard[.isUsingFullAPNs] { if UserDefaults.standard[.isUsingFullAPNs] {
LokiPushNotificationManager.acknowledgeDeliveryForMessage(with: hashValue, expiration: expirationDate, hexEncodedPublicKey: userHexEncodedPublicKey) LokiPushNotificationManager.acknowledgeDelivery(forMessageWithHash: hashValue, expiration: expirationDate, hexEncodedPublicKey: userHexEncodedPublicKey)
} }
} else if (!rawMessages.isEmpty) { } else if (!rawMessages.isEmpty) {
print("[Loki] Failed to update last message hash value from: \(rawMessages).") print("[Loki] Failed to update last message hash value from: \(rawMessages).")

View File

@ -75,8 +75,8 @@ final class LokiPushNotificationManager : NSObject {
} }
@objc(acknowledgeDeliveryForMessageWithHash:expiration:hexEncodedPublicKey:) @objc(acknowledgeDeliveryForMessageWithHash:expiration:hexEncodedPublicKey:)
static func acknowledgeDeliveryForMessage(with hash: String, expiration:Int, hexEncodedPublicKey: String) { static func acknowledgeDelivery(forMessageWithHash hash: String, expiration:Int, hexEncodedPublicKey: String) {
let parameters: [String : Any] = [ "lastHash" : hash, let parameters: JSON = [ "lastHash" : hash,
"pubKey" : hexEncodedPublicKey, "pubKey" : hexEncodedPublicKey,
"expiration": expiration] "expiration": expiration]
let url = URL(string: server + "acknowledge_message_delivery")! let url = URL(string: server + "acknowledge_message_delivery")!

View File

@ -1884,15 +1884,6 @@ NS_ASSUME_NONNULL_BEGIN
if (incomingMessage.isFriendRequest) { if (incomingMessage.isFriendRequest) {
[thread removeOldIncomingFriendRequestMessagesIfNeededWithTransaction:transaction]; [thread removeOldIncomingFriendRequestMessagesIfNeededWithTransaction:transaction];
} }
//
// if (!CurrentAppContext().isMainApp) {
// dispatch_async(dispatch_get_main_queue(), ^{
// [self.typingIndicators didReceiveIncomingMessageInThread:masterThread
// recipientId:(masterThread.contactIdentifier ?: envelope.source)
// deviceId:envelope.sourceDevice];
// });
// return;
// }
// Any messages sent from the current user - from this device or another - should be automatically marked as read. // Any messages sent from the current user - from this device or another - should be automatically marked as read.
if ([(masterThread.contactIdentifier ?: envelope.source) isEqualToString:self.tsAccountManager.localNumber]) { if ([(masterThread.contactIdentifier ?: envelope.source) isEqualToString:self.tsAccountManager.localNumber]) {