This commit is contained in:
Isaac
2025-01-21 21:08:44 +04:00
parent 8a0643eb53
commit 40828e9037
58 changed files with 1473 additions and 220 deletions

View File

@@ -589,6 +589,28 @@ public extension TelegramEngine {
|> ignoreValues
}
public func updateLocallyDerivedData(messageId: MessageId, update: @escaping ([String: CodableEntry]) -> [String: CodableEntry]) -> Signal<Never, NoError> {
return self.account.postbox.transaction { transaction -> Void in
transaction.updateMessage(messageId, update: { currentMessage in
let storeForwardInfo = currentMessage.forwardInfo.flatMap(StoreMessageForwardInfo.init)
var attributes = currentMessage.attributes
var data: [String: CodableEntry] = [:]
if let index = attributes.firstIndex(where: { $0 is DerivedDataMessageAttribute }) {
data = (attributes[index] as? DerivedDataMessageAttribute)?.data ?? [:]
attributes.remove(at: index)
}
data = update(data)
if !data.isEmpty {
attributes.append(DerivedDataMessageAttribute(data: data))
}
return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, threadId: currentMessage.threadId, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: attributes, media: currentMessage.media))
})
}
|> ignoreValues
}
public func rateAudioTranscription(messageId: MessageId, id: Int64, isGood: Bool) -> Signal<Never, NoError> {
return _internal_rateAudioTranscription(postbox: self.account.postbox, network: self.account.network, messageId: messageId, id: id, isGood: isGood)
}