Minor refactoring
This commit is contained in:
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) {
|
||||
|
|
|
@ -1043,7 +1043,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
}
|
||||
NSString *body = (message.body != nil && message.body.length > 0) ? message.body : [NSString stringWithFormat:@"%@", @(message.timestamp)]; // Workaround for the fact that the back-end doesn't accept messages without a body
|
||||
LKPublicChatMessage *groupMessage = [[LKPublicChatMessage alloc] initWithSenderPublicKey:userPublicKey displayName:displayName body:body type:LKPublicChatAPI.publicChatMessageType
|
||||
timestamp:message.timestamp quotedMessageTimestamp:quoteID quoteePublicKey:quoteePublicKey quotedMessageBody:quote.body quotedMessageServerID:quotedMessageServerID signatureData:nil signatureVersion:0 serverTimestamp:0];
|
||||
timestamp:message.timestamp quotedMessageTimestamp:quoteID quoteePublicKey:quoteePublicKey quotedMessageBody:quote.body quotedMessageServerID:quotedMessageServerID signatureData:nil signatureVersion:0 serverTimestamp:0];
|
||||
OWSLinkPreview *linkPreview = message.linkPreview;
|
||||
if (linkPreview != nil) {
|
||||
TSAttachmentStream *attachment = [TSAttachmentStream fetchObjectWithUniqueID:linkPreview.imageAttachmentId];
|
||||
|
|
Loading…
Reference in New Issue