mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-17 19:09:56 +00:00
24 lines
981 B
Swift
24 lines
981 B
Swift
import Foundation
|
|
#if os(macOS)
|
|
import PostboxMac
|
|
import SwiftSignalKitMac
|
|
#else
|
|
import Postbox
|
|
import SwiftSignalKit
|
|
#endif
|
|
|
|
public func enqueueMessage(account: Account, peerId: PeerId, text: String, replyMessageId: MessageId?) -> Signal<Void, NoError> {
|
|
return account.postbox.modify { modifier -> Void in
|
|
if let peer = modifier.getPeer(peerId) {
|
|
var attributes: [MessageAttribute] = []
|
|
if let replyMessageId = replyMessageId {
|
|
attributes.append(ReplyMessageAttribute(messageId: replyMessageId))
|
|
}
|
|
var flags = StoreMessageFlags()
|
|
flags.insert(.Unsent)
|
|
|
|
modifier.addMessages([StoreMessage(peerId: peerId, namespace: Namespaces.Message.Local, timestamp: Int32(account.network.context.globalTime()), flags: flags, tags: [], forwardInfo: nil, authorId: account.peerId, text: text, attributes: attributes, media: [])], location: .Random)
|
|
}
|
|
}
|
|
}
|