Minor refactoring

pull/254/head
nielsandriesse 5 years ago
parent 57d8d9bc69
commit 833b8aa18a

@ -131,7 +131,7 @@ public final class PublicChatAPI : DotNetAPI {
print("[Loki] Couldn't parse message for public chat channel with ID: \(channel) on server: \(server) from: \(message).")
return nil
}
let servertTimestamp = UInt64(date.timeIntervalSince1970) * 1000
let serverTimestamp = UInt64(date.timeIntervalSince1970) * 1000
var profilePicture: PublicChatMessage.ProfilePicture? = nil
let displayName = user["name"] as? String ?? NSLocalizedString("Anonymous", comment: "")
if let userAnnotations = user["annotations"] as? [JSON], let profilePictureAnnotation = userAnnotations.first(where: { $0["type"] as? String == profilePictureType }),
@ -171,7 +171,7 @@ public final class PublicChatAPI : DotNetAPI {
width: width, height: height, caption: caption, url: url, linkPreviewURL: linkPreviewURL, linkPreviewTitle: linkPreviewTitle)
}
let result = PublicChatMessage(serverID: serverID, senderPublicKey: hexEncodedPublicKey, displayName: displayName, profilePicture: profilePicture,
body: body, type: publicChatMessageType, timestamp: timestamp, quote: quote, attachments: attachments, signature: signature, serverTimestamp: servertTimestamp)
body: body, type: publicChatMessageType, timestamp: timestamp, quote: quote, attachments: attachments, signature: signature, serverTimestamp: serverTimestamp)
guard result.hasValidSignature() else {
print("[Loki] Ignoring public chat message with invalid signature.")
return nil

@ -13,8 +13,7 @@ public final class PublicChatMessage : NSObject {
public let quote: Quote?
public var attachments: [Attachment] = []
public let signature: Signature?
// MARK: Server Timestamp (use for sorting)
/// - Note: Used for sorting.
public let serverTimestamp: UInt64
@objc(serverID)

@ -189,14 +189,13 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
{
OWSAssertDebug(other);
// Loki: Sort the messages by the sender's timestamp (Signal uses sortId)
// Sort the messages by the sender's timestamp (Signal uses sortId)
uint64_t sortId1 = self.timestamp;
uint64_t sortId2 = other.timestamp;
// Loki: In open groups, we use the server time to sort the messages
// SortId represents the order that a message is processed
// Since we have sorted the messages in the poller using server time
// SortId can represent the order by server time.
// In open groups messages should be sorted by their server timestamp. `sortId` represents the order in which messages
// were processed. Since in the open group poller we sort messages by their server timestamp, sorting by `sortId` is
// effectively the same as sorting by server timestamp.
if (self.thread.isGroupThread) {
TSGroupThread *thread = (TSGroupThread *)self.thread;
if (thread.isPublicChat) {

Loading…
Cancel
Save