mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Animated emoji
This commit is contained in:
@@ -57,6 +57,7 @@ public enum EngineConfiguration {
|
||||
public let maxFolderChatsCount: Int32
|
||||
public let maxCaptionLengthCount: Int32
|
||||
public let maxUploadFileParts: Int32
|
||||
public let maxAnimatedEmojisInText: Int32
|
||||
|
||||
public static var defaultValue: UserLimits {
|
||||
return UserLimits(UserLimitsConfiguration.defaultValue)
|
||||
@@ -71,7 +72,8 @@ public enum EngineConfiguration {
|
||||
maxFoldersCount: Int32,
|
||||
maxFolderChatsCount: Int32,
|
||||
maxCaptionLengthCount: Int32,
|
||||
maxUploadFileParts: Int32
|
||||
maxUploadFileParts: Int32,
|
||||
maxAnimatedEmojisInText: Int32
|
||||
) {
|
||||
self.maxPinnedChatCount = maxPinnedChatCount
|
||||
self.maxChannelsCount = maxChannelsCount
|
||||
@@ -82,6 +84,7 @@ public enum EngineConfiguration {
|
||||
self.maxFolderChatsCount = maxFolderChatsCount
|
||||
self.maxCaptionLengthCount = maxCaptionLengthCount
|
||||
self.maxUploadFileParts = maxUploadFileParts
|
||||
self.maxAnimatedEmojisInText = maxAnimatedEmojisInText
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,7 +108,7 @@ extension EngineConfiguration.Limits {
|
||||
}
|
||||
}
|
||||
|
||||
extension EngineConfiguration.UserLimits {
|
||||
public extension EngineConfiguration.UserLimits {
|
||||
init(_ userLimitsConfiguration: UserLimitsConfiguration) {
|
||||
self.init(
|
||||
maxPinnedChatCount: userLimitsConfiguration.maxPinnedChatCount,
|
||||
@@ -116,7 +119,8 @@ extension EngineConfiguration.UserLimits {
|
||||
maxFoldersCount: userLimitsConfiguration.maxFoldersCount,
|
||||
maxFolderChatsCount: userLimitsConfiguration.maxFolderChatsCount,
|
||||
maxCaptionLengthCount: userLimitsConfiguration.maxCaptionLengthCount,
|
||||
maxUploadFileParts: userLimitsConfiguration.maxUploadFileParts
|
||||
maxUploadFileParts: userLimitsConfiguration.maxUploadFileParts,
|
||||
maxAnimatedEmojisInText: userLimitsConfiguration.maxAnimatedEmojisInText
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,10 +322,14 @@ public extension TelegramEngine {
|
||||
return _internal_translate(network: self.account.network, text: text, fromLang: fromLang, toLang: toLang)
|
||||
}
|
||||
|
||||
public func transcribeAudio(messageId: MessageId) -> Signal<EngineAudioTranscriptionResult?, NoError> {
|
||||
public func transcribeAudio(messageId: MessageId) -> Signal<EngineAudioTranscriptionResult, NoError> {
|
||||
return _internal_transcribeAudio(postbox: self.account.postbox, network: self.account.network, messageId: messageId)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
public func requestWebView(peerId: PeerId, botId: PeerId, url: String?, payload: String?, themeParams: [String: Any]?, fromMenu: Bool, replyToMessageId: MessageId?) -> Signal<RequestWebViewResult, RequestWebViewError> {
|
||||
return _internal_requestWebView(postbox: self.account.postbox, network: self.account.network, stateManager: self.account.stateManager, peerId: peerId, botId: botId, url: url, payload: payload, themeParams: themeParams, fromMenu: fromMenu, replyToMessageId: replyToMessageId)
|
||||
}
|
||||
|
||||
@@ -29,32 +29,70 @@ func _internal_translate(network: Network, text: String, fromLang: String?, toLa
|
||||
}
|
||||
}
|
||||
|
||||
public struct EngineAudioTranscriptionResult {
|
||||
public var id: Int64
|
||||
public var text: String
|
||||
public enum EngineAudioTranscriptionResult {
|
||||
public struct Success {
|
||||
public var id: Int64
|
||||
public var text: String
|
||||
|
||||
public init(id: Int64, text: String) {
|
||||
self.id = id
|
||||
self.text = text
|
||||
}
|
||||
}
|
||||
|
||||
case success(Success)
|
||||
case error
|
||||
}
|
||||
|
||||
func _internal_transcribeAudio(postbox: Postbox, network: Network, messageId: MessageId) -> Signal<EngineAudioTranscriptionResult?, NoError> {
|
||||
func _internal_transcribeAudio(postbox: Postbox, network: Network, messageId: MessageId) -> Signal<EngineAudioTranscriptionResult, NoError> {
|
||||
return postbox.transaction { transaction -> Api.InputPeer? in
|
||||
return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer)
|
||||
}
|
||||
|> mapToSignal { inputPeer -> Signal<EngineAudioTranscriptionResult?, NoError> in
|
||||
|> mapToSignal { inputPeer -> Signal<EngineAudioTranscriptionResult, NoError> in
|
||||
guard let inputPeer = inputPeer else {
|
||||
return .single(nil)
|
||||
return .single(.error)
|
||||
}
|
||||
return network.request(Api.functions.messages.transcribeAudio(peer: inputPeer, msgId: messageId.id))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.messages.TranscribedAudio?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { result -> Signal<EngineAudioTranscriptionResult?, NoError> in
|
||||
|> mapToSignal { result -> Signal<EngineAudioTranscriptionResult, NoError> in
|
||||
guard let result = result else {
|
||||
return .single(nil)
|
||||
return .single(.error)
|
||||
}
|
||||
switch result {
|
||||
case let .transcribedAudio(transcriptionId, text):
|
||||
return .single(EngineAudioTranscriptionResult(id: transcriptionId, text: text))
|
||||
|
||||
return postbox.transaction { transaction -> EngineAudioTranscriptionResult in
|
||||
switch result {
|
||||
case let .transcribedAudio(transcriptionId, text):
|
||||
transaction.updateMessage(messageId, update: { currentMessage in
|
||||
let storeForwardInfo = currentMessage.forwardInfo.flatMap(StoreMessageForwardInfo.init)
|
||||
var attributes = currentMessage.attributes.filter { !($0 is AudioTranscriptionMessageAttribute) }
|
||||
|
||||
attributes.append(AudioTranscriptionMessageAttribute(id: transcriptionId, text: text))
|
||||
|
||||
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))
|
||||
})
|
||||
|
||||
return .success(EngineAudioTranscriptionResult.Success(id: transcriptionId, text: text))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_rateAudioTranscription(postbox: Postbox, network: Network, messageId: MessageId, id: Int64, isGood: Bool) -> Signal<Never, NoError> {
|
||||
return postbox.transaction { transaction -> Api.InputPeer? in
|
||||
return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer)
|
||||
}
|
||||
|> mapToSignal { inputPeer -> Signal<Never, NoError> in
|
||||
guard let inputPeer = inputPeer else {
|
||||
return .complete()
|
||||
}
|
||||
return network.request(Api.functions.messages.rateTranscribedAudio(peer: inputPeer, msgId: messageId.id, transcriptionId: id, good: isGood ? .boolTrue : .boolFalse))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,8 +348,6 @@ extension ChatListFilter {
|
||||
}
|
||||
)
|
||||
)
|
||||
case .dialogFilterDefault:
|
||||
preconditionFailure()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,8 +484,6 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net
|
||||
}
|
||||
}
|
||||
}
|
||||
case .dialogFilterDefault:
|
||||
break
|
||||
}
|
||||
}
|
||||
return (filters, missingPeers, missingChats)
|
||||
|
||||
Reference in New Issue
Block a user