Merge commit '3ca08f7aae8e4c108730926be5954d371b4d5ef7'

# Conflicts:
#	TelegramCore/StoreMessage_Telegram.swift
This commit is contained in:
Peter 2017-03-14 17:22:32 +03:00
commit 652832e32b
10 changed files with 1714 additions and 10 deletions

View File

@ -22,6 +22,9 @@
C251D7431E65E50500283EDE /* StickerSetInstallation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C251D7421E65E50500283EDE /* StickerSetInstallation.swift */; };
C251D7441E65E50500283EDE /* StickerSetInstallation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C251D7421E65E50500283EDE /* StickerSetInstallation.swift */; };
C26A37EF1E5E0C41006977AC /* ChannelParticipants.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BB7C591E5C8074001527C3 /* ChannelParticipants.swift */; };
C27982511E72C97800262BFD /* MacosLegacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C27982501E72C97800262BFD /* MacosLegacy.swift */; };
C27982531E73077800262BFD /* SecretChatStateBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = C27982521E73077800262BFD /* SecretChatStateBridge.swift */; };
C27982541E73078400262BFD /* SecretChatStateBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = C27982521E73077800262BFD /* SecretChatStateBridge.swift */; };
C2A315C01E2E776A00D89000 /* RequestStartBot.swift in Sources */ = {isa = PBXBuildFile; fileRef = D01749581E1092BC0057C89A /* RequestStartBot.swift */; };
C2FD33E11E680E9E008D13D4 /* RequestUserPhotos.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2FD33E01E680E9E008D13D4 /* RequestUserPhotos.swift */; };
C2FD33E21E680E9E008D13D4 /* RequestUserPhotos.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2FD33E01E680E9E008D13D4 /* RequestUserPhotos.swift */; };
@ -466,6 +469,8 @@
C239BE961E62EE1E00C2C453 /* LoadMessagesIfNecessary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadMessagesIfNecessary.swift; sourceTree = "<group>"; };
C239BE9B1E630CA700C2C453 /* UpdatePinnedMessage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdatePinnedMessage.swift; sourceTree = "<group>"; };
C251D7421E65E50500283EDE /* StickerSetInstallation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StickerSetInstallation.swift; sourceTree = "<group>"; };
C27982501E72C97800262BFD /* MacosLegacy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MacosLegacy.swift; sourceTree = "<group>"; };
C27982521E73077800262BFD /* SecretChatStateBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecretChatStateBridge.swift; sourceTree = "<group>"; };
C2FD33E01E680E9E008D13D4 /* RequestUserPhotos.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestUserPhotos.swift; sourceTree = "<group>"; };
C2FD33E31E687BF1008D13D4 /* PeerPhotoUpdater.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PeerPhotoUpdater.swift; sourceTree = "<group>"; };
C2FD33EA1E696C78008D13D4 /* GroupsInCommon.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GroupsInCommon.swift; sourceTree = "<group>"; };
@ -737,6 +742,14 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
C279824F1E72C96B00262BFD /* legacy */ = {
isa = PBXGroup;
children = (
C27982501E72C97800262BFD /* MacosLegacy.swift */,
);
name = legacy;
sourceTree = "<group>";
};
D01B27A01E394D7B0022A4C0 /* Settings */ = {
isa = PBXGroup;
children = (
@ -1113,6 +1126,7 @@
D09D8C031D4FAB1D0081DBEC /* TelegramCore */ = {
isa = PBXGroup;
children = (
C279824F1E72C96B00262BFD /* legacy */,
D03B0C791D62153400955575 /* third-party */,
D03B0CB71D62232000955575 /* Utils */,
D03B0CCF1D62242200955575 /* Objects */,
@ -1208,6 +1222,7 @@
D0FA8BA91E1FB76E001E855B /* ManagedSecretChatOutgoingOperations.swift */,
D019B1CB1E2E3B6A00F80DB3 /* SecretChatRekeySession.swift */,
D00C7CEA1E37A8540080C3D5 /* SetSecretChatMessageAutoremoveTimeoutInteractively.swift */,
C27982521E73077800262BFD /* SecretChatStateBridge.swift */,
);
name = "Secret Chats";
sourceTree = "<group>";
@ -1565,6 +1580,7 @@
D0BC38701E40853E0044D6FE /* UpdatePeers.swift in Sources */,
D03B0CE21D62249B00955575 /* InlineBotMessageAttribute.swift in Sources */,
D0AB0B9A1D666520002C78E7 /* ManagedSynchronizePeerReadStates.swift in Sources */,
C27982531E73077800262BFD /* SecretChatStateBridge.swift in Sources */,
D03B0D5B1D631A6900955575 /* Buffer.swift in Sources */,
D0B843891DA7AB96005F29E1 /* ExportedInvitation.swift in Sources */,
D03B0E441D631E6600955575 /* NetworkLogging.m in Sources */,
@ -1609,6 +1625,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C27982541E73078400262BFD /* SecretChatStateBridge.swift in Sources */,
D00DBBD81E64E41100DB5485 /* CreateSecretChat.swift in Sources */,
C2FD33EC1E696C79008D13D4 /* GroupsInCommon.swift in Sources */,
C239BE9D1E630CB300C2C453 /* UpdatePinnedMessage.swift in Sources */,
@ -1765,6 +1782,7 @@
D0B8442C1DAB91E0005F29E1 /* NBMetadataCoreMapper.m in Sources */,
D0FA8BB71E223C16001E855B /* SecretApiLayer8.swift in Sources */,
D073CE6A1DCBCF17007511FD /* ViewCountMessageAttribute.swift in Sources */,
C27982511E72C97800262BFD /* MacosLegacy.swift in Sources */,
D0B418AB1D7E0597004562A4 /* MultipartFetch.swift in Sources */,
D0B418B71D7E05A6004562A4 /* Phonebook.swift in Sources */,
D03C53741DAD5CA9004C17B3 /* CachedChannelData.swift in Sources */,

View File

@ -204,6 +204,7 @@ private var declaredEncodables: Void = {
declareEncodable(GlobalNotificationSettings.self, f: { GlobalNotificationSettings(decoder: $0) })
declareEncodable(CloudChatRemoveChatOperation.self, f: { CloudChatRemoveChatOperation(decoder: $0) })
declareEncodable(SynchronizePinnedChatsOperation.self, f: { SynchronizePinnedChatsOperation(decoder: $0) })
declareEncodable(SynchronizeConsumeMessageContentsOperation.self, f: { SynchronizeConsumeMessageContentsOperation(decoder: $0) })
declareEncodable(RecentMediaItem.self, f: { RecentMediaItem(decoder: $0) })
declareEncodable(RecentPeerItem.self, f: { RecentPeerItem(decoder: $0) })
declareEncodable(LoggedOutAccountAttribute.self, f: { LoggedOutAccountAttribute(decoder: $0) })
@ -529,6 +530,8 @@ public class Account {
self.managedOperationsDisposable.add(managedRecentGifs(postbox: self.postbox, network: self.network).start())
self.managedOperationsDisposable.add(managedRecentlyUsedInlineBots(postbox: self.postbox, network: self.network).start())
self.managedOperationsDisposable.add(managedLocalTypingActivities(activities: self.localInputActivityManager.allActivities(), postbox: self.postbox, network: self.network).start())
self.managedOperationsDisposable.add(managedSynchronizeConsumeMessageContentOperations(postbox: self.postbox, network: self.network, stateManager : self.stateManager).start())
let updatedPresence = self.shouldKeepOnlinePresence.get()
|> distinctUntilChanged

View File

@ -289,14 +289,14 @@ public final class AccountViewTracker {
if let existingContext = self.cachedDataContexts[peerId] {
context = existingContext
context.referenceData = referenceData
if context.timestamp == nil || abs(CFAbsoluteTimeGetCurrent() - context.timestamp!) > 60.0 * 60.0 {
if context.timestamp == nil || abs(CFAbsoluteTimeGetCurrent() - context.timestamp!) > 60.0 * 5 {
dataUpdated = true
}
} else {
context = PeerCachedDataContext()
context.referenceData = referenceData
self.cachedDataContexts[peerId] = context
if context.referenceData == nil || context.timestamp == nil || abs(CFAbsoluteTimeGetCurrent() - context.timestamp!) > 60.0 * 60.0 {
if context.referenceData == nil || context.timestamp == nil || abs(CFAbsoluteTimeGetCurrent() - context.timestamp!) > 60.0 * 5 {
context.timestamp = CFAbsoluteTimeGetCurrent()
dataUpdated = true
}

View File

@ -15,7 +15,7 @@ public class AutoremoveTimeoutMessageAttribute: MessageAttribute {
public var associatedMessageIds: [MessageId] = []
init(timeout: Int32, countdownBeginTime: Int32?) {
public init(timeout: Int32, countdownBeginTime: Int32?) {
self.timeout = timeout
self.countdownBeginTime = countdownBeginTime
}

View File

@ -189,9 +189,16 @@ func enqueueMessages(modifier: Modifier, account: Account, peerId: PeerId, messa
}
}
storeMessages.append(StoreMessage(peerId: peerId, namespace: Namespaces.Message.Local, globallyUniqueId: randomId, timestamp: timestamp, flags: flags, tags: tagsForStoreMessage(media: mediaList, textEntities: entitiesAttribute?.entities), forwardInfo: nil, authorId: account.peerId, text: text, attributes: attributes, media: mediaList))
let authorId:PeerId?
if let peer = peer as? TelegramChannel, case let .broadcast(info) = peer.info, !info.flags.contains(.messagesShouldHaveSignatures) {
authorId = nil
} else {
authorId = account.peerId
}
storeMessages.append(StoreMessage(peerId: peerId, namespace: Namespaces.Message.Local, globallyUniqueId: randomId, timestamp: timestamp, flags: flags, tags: tagsForStoreMessage(media: mediaList, textEntities: entitiesAttribute?.entities), forwardInfo: nil, authorId: authorId, text: text, attributes: attributes, media: mediaList))
case let .forward(source):
if let sourceMessage = modifier.getMessage(source), let author = sourceMessage.author {
if let sourceMessage = modifier.getMessage(source), let author = sourceMessage.author ?? sourceMessage.peers[sourceMessage.id.peerId] {
if let peer = peer as? TelegramSecretChat {
var isAction = false
for media in sourceMessage.media {

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,8 @@ import Foundation
import Postbox
#endif
extension MemoryBuffer {
convenience init(_ buffer: Buffer) {
public extension MemoryBuffer {
public convenience init(_ buffer: Buffer) {
let memory = malloc(Int(buffer.size))!
memcpy(memory, buffer.data, Int(buffer.size))
self.init(memory: memory, capacity: Int(buffer.size), length: Int(buffer.size), freeWhenDone: true)

View File

@ -0,0 +1,29 @@
import Foundation
#if os(macOS)
import PostboxMac
#else
import Postbox
#endif
public enum SecretChatBridgeRole: Int32 {
case creator
case participant
}
public struct SecretChatStateBridge {
public let role:SecretChatBridgeRole
public init(role: SecretChatBridgeRole) {
self.role = role
}
public var state: PeerChatState {
return SecretChatState(role: SecretChatRole(rawValue: role.rawValue)!, embeddedState: .terminated, keychain: SecretChatKeychain(keys: []), keyFingerprint: nil, messageAutoremoveTimeout: nil)
}
}
public func terminateLegacySecretChat(modifier: Modifier, peerId: PeerId, state: SecretChatStateBridge) -> PeerChatState {
return addSecretChatOutgoingOperation(modifier: modifier, peerId: peerId, operation: SecretChatOutgoingOperationContents.terminate, state: state.state as! SecretChatState).withUpdatedEmbeddedState(.terminated)
}

View File

@ -5,7 +5,7 @@ import Foundation
import Postbox
#endif
func tagsForStoreMessage(media: [Media], textEntities: [MessageTextEntity]?) -> MessageTags {
public func tagsForStoreMessage(media: [Media], textEntities: [MessageTextEntity]?) -> MessageTags {
var tags = MessageTags()
for attachment in media {
if let _ = attachment as? TelegramMediaImage {
@ -348,7 +348,7 @@ extension StoreMessage {
for case let file as TelegramMediaFile in medias {
if peerId.namespace == Namespaces.Peer.CloudUser || peerId.namespace == Namespaces.Peer.CloudGroup {
if file.isVoice {
attributes.append(ConsumableContentMessageAttribute(consumed: (flags & (1 << 5)) != 0))
attributes.append(ConsumableContentMessageAttribute(consumed: (flags & (1 << 5)) == 0))
break
}
}

View File

@ -20,7 +20,7 @@ public final class TelegramSecretChat: Peer {
public let associatedPeerIds: [PeerId]?
public let notificationSettingsPeerId: PeerId?
init(id: PeerId, creationDate: Int32, regularPeerId: PeerId, accessHash: Int64, embeddedState: SecretChatEmbeddedPeerState, messageAutoremoveTimeout: Int32?) {
public init(id: PeerId, creationDate: Int32, regularPeerId: PeerId, accessHash: Int64, embeddedState: SecretChatEmbeddedPeerState, messageAutoremoveTimeout: Int32?) {
self.id = id
self.regularPeerId = regularPeerId
self.accessHash = accessHash