mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-04 13:38:21 +00:00
Fix send when online
This commit is contained in:
parent
bab231a71f
commit
66f78760be
@ -43,7 +43,7 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let apiMessage = apiMessage, let id = apiMessage.id(namespace: message.scheduleTime != nil ? Namespaces.Message.ScheduledCloud : Namespaces.Message.Cloud) {
|
if let apiMessage = apiMessage, let id = apiMessage.id(namespace: message.scheduleTime != nil && message.scheduleTime == apiMessage.timestamp ? Namespaces.Message.ScheduledCloud : Namespaces.Message.Cloud) {
|
||||||
messageId = id.id
|
messageId = id.id
|
||||||
} else {
|
} else {
|
||||||
messageId = result.rawMessageIds.first
|
messageId = result.rawMessageIds.first
|
||||||
|
|||||||
@ -267,6 +267,8 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let peer = transaction.getPeer(peerId), let accountPeer = transaction.getPeer(account.peerId) {
|
if let peer = transaction.getPeer(peerId), let accountPeer = transaction.getPeer(account.peerId) {
|
||||||
|
let peerPresence = transaction.getPeerPresence(peerId: peerId)
|
||||||
|
|
||||||
var storeMessages: [StoreMessage] = []
|
var storeMessages: [StoreMessage] = []
|
||||||
var timestamp = Int32(account.network.context.globalTime())
|
var timestamp = Int32(account.network.context.globalTime())
|
||||||
switch peerId.namespace {
|
switch peerId.namespace {
|
||||||
@ -377,12 +379,20 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
|
|||||||
var effectiveTimestamp = timestamp
|
var effectiveTimestamp = timestamp
|
||||||
for attribute in attributes {
|
for attribute in attributes {
|
||||||
if let attribute = attribute as? OutgoingScheduleInfoMessageAttribute {
|
if let attribute = attribute as? OutgoingScheduleInfoMessageAttribute {
|
||||||
messageNamespace = Namespaces.Message.ScheduledLocal
|
if attribute.scheduleTime == scheduleWhenOnlineTimestamp, let presence = peerPresence as? TelegramUserPresence, case let .present(statusTimestamp) = presence.status, statusTimestamp >= timestamp {
|
||||||
effectiveTimestamp = attribute.scheduleTime
|
|
||||||
|
} else {
|
||||||
|
messageNamespace = Namespaces.Message.ScheduledLocal
|
||||||
|
effectiveTimestamp = attribute.scheduleTime
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if messageNamespace != Namespaces.Message.ScheduledLocal {
|
||||||
|
attributes.removeAll(where: { $0 is OutgoingScheduleInfoMessageAttribute })
|
||||||
|
}
|
||||||
|
|
||||||
if let peer = peer as? TelegramChannel {
|
if let peer = peer as? TelegramChannel {
|
||||||
switch peer.info {
|
switch peer.info {
|
||||||
case let .broadcast(info):
|
case let .broadcast(info):
|
||||||
@ -515,11 +525,19 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
|
|||||||
entitiesAttribute = attribute
|
entitiesAttribute = attribute
|
||||||
}
|
}
|
||||||
if let attribute = attribute as? OutgoingScheduleInfoMessageAttribute {
|
if let attribute = attribute as? OutgoingScheduleInfoMessageAttribute {
|
||||||
messageNamespace = Namespaces.Message.ScheduledLocal
|
if attribute.scheduleTime == scheduleWhenOnlineTimestamp, let presence = peerPresence as? TelegramUserPresence, case let .present(statusTimestamp) = presence.status, statusTimestamp >= timestamp {
|
||||||
effectiveTimestamp = attribute.scheduleTime
|
|
||||||
|
} else {
|
||||||
|
messageNamespace = Namespaces.Message.ScheduledLocal
|
||||||
|
effectiveTimestamp = attribute.scheduleTime
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if messageNamespace != Namespaces.Message.ScheduledLocal {
|
||||||
|
attributes.removeAll(where: { $0 is OutgoingScheduleInfoMessageAttribute })
|
||||||
|
}
|
||||||
|
|
||||||
let (tags, globalTags) = tagsForStoreMessage(incoming: false, attributes: attributes, media: sourceMessage.media, textEntities: entitiesAttribute?.entities)
|
let (tags, globalTags) = tagsForStoreMessage(incoming: false, attributes: attributes, media: sourceMessage.media, textEntities: entitiesAttribute?.entities)
|
||||||
|
|
||||||
let localGroupingKey: Int64?
|
let localGroupingKey: Int64?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user