mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-06-12 21:07:47 +02:00
Update Ghostgram features
This commit is contained in:
@@ -6,10 +6,12 @@ import TelegramApi
|
||||
extension UnauthorizedAccountTermsOfService {
|
||||
init?(apiTermsOfService: Api.help.TermsOfService) {
|
||||
switch apiTermsOfService {
|
||||
case let .termsOfService(_, id, text, entities, minAgeConfirm):
|
||||
case let .termsOfService(termsOfServiceData):
|
||||
let (_, id, text, entities, minAgeConfirm) = (termsOfServiceData.flags, termsOfServiceData.id, termsOfServiceData.text, termsOfServiceData.entities, termsOfServiceData.minAgeConfirm)
|
||||
let idData: String
|
||||
switch id {
|
||||
case let .dataJSON(data):
|
||||
case let .dataJSON(dataJSONData):
|
||||
let data = dataJSONData.data
|
||||
idData = data
|
||||
}
|
||||
self.init(id: idData, text: text, entities: messageTextEntitiesFromApiEntities(entities), ageConfirmation: minAgeConfirm)
|
||||
@@ -20,27 +22,38 @@ extension UnauthorizedAccountTermsOfService {
|
||||
extension SentAuthorizationCodeType {
|
||||
init(apiType: Api.auth.SentCodeType) {
|
||||
switch apiType {
|
||||
case let .sentCodeTypeApp(length):
|
||||
case let .sentCodeTypeApp(sentCodeTypeAppData):
|
||||
let length = sentCodeTypeAppData.length
|
||||
self = .otherSession(length: length)
|
||||
case let .sentCodeTypeSms(length):
|
||||
case let .sentCodeTypeSms(sentCodeTypeSmsData):
|
||||
let length = sentCodeTypeSmsData.length
|
||||
self = .sms(length: length)
|
||||
case let .sentCodeTypeCall(length):
|
||||
case let .sentCodeTypeCall(sentCodeTypeCallData):
|
||||
let length = sentCodeTypeCallData.length
|
||||
self = .call(length: length)
|
||||
case let .sentCodeTypeFlashCall(pattern):
|
||||
case let .sentCodeTypeFlashCall(sentCodeTypeFlashCallData):
|
||||
let pattern = sentCodeTypeFlashCallData.pattern
|
||||
self = .flashCall(pattern: pattern)
|
||||
case let .sentCodeTypeMissedCall(prefix, length):
|
||||
case let .sentCodeTypeMissedCall(sentCodeTypeMissedCallData):
|
||||
let (prefix, length) = (sentCodeTypeMissedCallData.prefix, sentCodeTypeMissedCallData.length)
|
||||
self = .missedCall(numberPrefix: prefix, length: length)
|
||||
case let .sentCodeTypeEmailCode(flags, emailPattern, length, resetAvailablePeriod, resetPendingDate):
|
||||
case let .sentCodeTypeEmailCode(sentCodeTypeEmailCodeData):
|
||||
let (flags, emailPattern, length, resetAvailablePeriod, resetPendingDate) = (sentCodeTypeEmailCodeData.flags, sentCodeTypeEmailCodeData.emailPattern, sentCodeTypeEmailCodeData.length, sentCodeTypeEmailCodeData.resetAvailablePeriod, sentCodeTypeEmailCodeData.resetPendingDate)
|
||||
self = .email(emailPattern: emailPattern, length: length, resetAvailablePeriod: resetAvailablePeriod, resetPendingDate: resetPendingDate, appleSignInAllowed: (flags & (1 << 0)) != 0, setup: false)
|
||||
case let .sentCodeTypeSetUpEmailRequired(flags):
|
||||
case let .sentCodeTypeSetUpEmailRequired(sentCodeTypeSetUpEmailRequiredData):
|
||||
let flags = sentCodeTypeSetUpEmailRequiredData.flags
|
||||
self = .emailSetupRequired(appleSignInAllowed: (flags & (1 << 0)) != 0)
|
||||
case let .sentCodeTypeFragmentSms(url, length):
|
||||
case let .sentCodeTypeFragmentSms(sentCodeTypeFragmentSmsData):
|
||||
let (url, length) = (sentCodeTypeFragmentSmsData.url, sentCodeTypeFragmentSmsData.length)
|
||||
self = .fragment(url: url, length: length)
|
||||
case let .sentCodeTypeFirebaseSms(_, _, _, _, _, pushTimeout, length):
|
||||
case let .sentCodeTypeFirebaseSms(sentCodeTypeFirebaseSmsData):
|
||||
let (pushTimeout, length) = (sentCodeTypeFirebaseSmsData.pushTimeout, sentCodeTypeFirebaseSmsData.length)
|
||||
self = .firebase(pushTimeout: pushTimeout, length: length)
|
||||
case let .sentCodeTypeSmsWord(_, beginning):
|
||||
case let .sentCodeTypeSmsWord(sentCodeTypeSmsWordData):
|
||||
let beginning = sentCodeTypeSmsWordData.beginning
|
||||
self = .word(startsWith: beginning)
|
||||
case let .sentCodeTypeSmsPhrase(_, beginning):
|
||||
case let .sentCodeTypeSmsPhrase(sentCodeTypeSmsPhraseData):
|
||||
let beginning = sentCodeTypeSmsPhraseData.beginning
|
||||
self = .phrase(startsWith: beginning)
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -925,7 +925,8 @@ public final class AccountStateManager {
|
||||
return postbox.transaction { transaction -> (difference: Api.updates.Difference?, finalStatte: AccountReplayedFinalState?, skipBecauseOfError: Bool, resetState: Bool) in
|
||||
if let currentState = transaction.getState() as? AuthorizedAccountState {
|
||||
switch state {
|
||||
case let .state(pts, qts, date, seq, _):
|
||||
case let .state(stateData):
|
||||
let (pts, qts, date, seq) = (stateData.pts, stateData.qts, stateData.date, stateData.seq)
|
||||
transaction.setState(currentState.changedState(AuthorizedAccountState.State(pts: pts, qts: qts, date: date, seq: seq)))
|
||||
}
|
||||
}
|
||||
@@ -1883,10 +1884,12 @@ public final class AccountStateManager {
|
||||
|
||||
if let updates = Api.parse(Buffer(data: rawData)) as? Api.Updates {
|
||||
switch updates {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
case let .updates(updatesData):
|
||||
let updates = updatesData.updates
|
||||
for update in updates {
|
||||
switch update {
|
||||
case let .updatePhoneCall(phoneCall):
|
||||
case let .updatePhoneCall(updatePhoneCallData):
|
||||
let phoneCall = updatePhoneCallData.phoneCall
|
||||
if let callSessionManager = self.callSessionManager {
|
||||
callSessionManager.updateSession(phoneCall, completion: { result in
|
||||
completion(result)
|
||||
@@ -2297,17 +2300,20 @@ public final class AccountStateManager {
|
||||
return nil
|
||||
}
|
||||
switch updates {
|
||||
case let .updates(updates, users, _, _, _):
|
||||
case let .updates(updatesData):
|
||||
let (updates, users) = (updatesData.updates, updatesData.users)
|
||||
var peers: [Peer] = []
|
||||
for user in users {
|
||||
peers.append(TelegramUser(user: user))
|
||||
}
|
||||
|
||||
|
||||
for update in updates {
|
||||
switch update {
|
||||
case let .updatePhoneCall(phoneCall):
|
||||
case let .updatePhoneCall(updatePhoneCallData):
|
||||
let phoneCall = updatePhoneCallData.phoneCall
|
||||
switch phoneCall {
|
||||
case let .phoneCallRequested(flags, id, accessHash, date, adminId, _, _, _):
|
||||
case let .phoneCallRequested(phoneCallRequestedData):
|
||||
let (flags, id, accessHash, date, adminId) = (phoneCallRequestedData.flags, phoneCallRequestedData.id, phoneCallRequestedData.accessHash, phoneCallRequestedData.date, phoneCallRequestedData.adminId)
|
||||
guard let peer = peers.first(where: { $0.id == PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(adminId)) }) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -87,10 +87,11 @@ private func fetchWebpage(account: Account, messageId: MessageId, threadId: Int6
|
||||
}
|
||||
} else {
|
||||
switch inputPeer {
|
||||
case let .inputPeerChannel(channelId, accessHash):
|
||||
messages = account.network.request(Api.functions.channels.getMessages(channel: Api.InputChannel.inputChannel(channelId: channelId, accessHash: accessHash), id: [Api.InputMessage.inputMessageID(id: messageId.id)]))
|
||||
case let .inputPeerChannel(inputPeerChannelData):
|
||||
let (channelId, accessHash) = (inputPeerChannelData.channelId, inputPeerChannelData.accessHash)
|
||||
messages = account.network.request(Api.functions.channels.getMessages(channel: Api.InputChannel.inputChannel(.init(channelId: channelId, accessHash: accessHash)), id: [Api.InputMessage.inputMessageID(.init(id: messageId.id))]))
|
||||
default:
|
||||
messages = account.network.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(id: messageId.id)]))
|
||||
messages = account.network.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(.init(id: messageId.id))]))
|
||||
}
|
||||
}
|
||||
return messages
|
||||
@@ -100,17 +101,20 @@ private func fetchWebpage(account: Account, messageId: MessageId, threadId: Int6
|
||||
let chats: [Api.Chat]
|
||||
let users: [Api.User]
|
||||
switch result {
|
||||
case let .messages(messages: apiMessages, topics: apiTopics, chats: apiChats, users: apiUsers):
|
||||
case let .messages(messagesData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (messagesData.messages, messagesData.topics, messagesData.chats, messagesData.users)
|
||||
let _ = apiTopics
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .messagesSlice(_, _, _, _, _, messages: apiMessages, topics: apiTopics, chats: apiChats, users: apiUsers):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (messagesSliceData.messages, messagesSliceData.topics, messagesSliceData.chats, messagesSliceData.users)
|
||||
let _ = apiTopics
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .channelMessages(_, _, _, _, apiMessages, apiTopics, apiChats, apiUsers):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (channelMessagesData.messages, channelMessagesData.topics, channelMessagesData.chats, channelMessagesData.users)
|
||||
messages = apiMessages
|
||||
let _ = apiTopics
|
||||
chats = apiChats
|
||||
@@ -719,10 +723,11 @@ public final class AccountViewTracker {
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { result -> Signal<[MessageId: ViewCountContextState], NoError> in
|
||||
guard case let .messageViews(viewCounts, chats, users)? = result else {
|
||||
guard case let .messageViews(messageViewsData)? = result else {
|
||||
return .complete()
|
||||
}
|
||||
|
||||
let (viewCounts, chats, users) = (messageViewsData.views, messageViewsData.chats, messageViewsData.users)
|
||||
|
||||
return account.postbox.transaction { transaction -> [MessageId: ViewCountContextState] in
|
||||
var resultStates: [MessageId: ViewCountContextState] = [:]
|
||||
|
||||
@@ -732,7 +737,8 @@ public final class AccountViewTracker {
|
||||
|
||||
for i in 0 ..< messageIds.count {
|
||||
if i < viewCounts.count {
|
||||
if case let .messageViews(_, views, forwards, replies) = viewCounts[i] {
|
||||
if case let .messageViews(messageViewsData) = viewCounts[i] {
|
||||
let (views, forwards, replies) = (messageViewsData.views, messageViewsData.forwards, messageViewsData.replies)
|
||||
transaction.updateMessage(messageIds[i], update: { currentMessage in
|
||||
let storeForwardInfo = currentMessage.forwardInfo.flatMap(StoreMessageForwardInfo.init)
|
||||
var attributes = currentMessage.attributes
|
||||
@@ -744,7 +750,8 @@ public final class AccountViewTracker {
|
||||
var repliesReadMaxId: Int32?
|
||||
if let replies = replies {
|
||||
switch replies {
|
||||
case let .messageReplies(_, repliesCountValue, _, recentRepliers, channelId, maxId, readMaxId):
|
||||
case let .messageReplies(messageRepliesData):
|
||||
let (repliesCountValue, recentRepliers, channelId, maxId, readMaxId) = (messageRepliesData.replies, messageRepliesData.recentRepliers, messageRepliesData.channelId, messageRepliesData.maxId, messageRepliesData.readMaxId)
|
||||
if let channelId = channelId {
|
||||
commentsChannelId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
}
|
||||
@@ -861,18 +868,22 @@ public final class AccountViewTracker {
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
let updateList: [Api.Update]
|
||||
switch updates {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
case let .updates(updatesData):
|
||||
let updates = updatesData.updates
|
||||
updateList = updates
|
||||
case let .updatesCombined(updates, _, _, _, _, _):
|
||||
case let .updatesCombined(updatesCombinedData):
|
||||
let updates = updatesCombinedData.updates
|
||||
updateList = updates
|
||||
case let .updateShort(update, _):
|
||||
case let .updateShort(updateShortData):
|
||||
let update = updateShortData.update
|
||||
updateList = [update]
|
||||
default:
|
||||
updateList = []
|
||||
}
|
||||
for update in updateList {
|
||||
switch update {
|
||||
case let .updateMessageReactions(_, peer, msgId, _, _, reactions):
|
||||
case let .updateMessageReactions(updateMessageReactionsData):
|
||||
let (peer, msgId, reactions) = (updateMessageReactionsData.peer, updateMessageReactionsData.msgId, updateMessageReactionsData.reactions)
|
||||
transaction.updateMessage(MessageId(peerId: peer.peerId, namespace: Namespaces.Message.Cloud, id: msgId), update: { currentMessage in
|
||||
var updatedReactions = ReactionsMessageAttribute(apiReactions: reactions)
|
||||
|
||||
@@ -949,8 +960,9 @@ public final class AccountViewTracker {
|
||||
case .inputPeerChat, .inputPeerSelf, .inputPeerUser:
|
||||
request = account.network.request(Api.functions.messages.readMessageContents(id: messageIds.map { $0.id }))
|
||||
|> map { _ in true }
|
||||
case let .inputPeerChannel(channelId, accessHash):
|
||||
request = account.network.request(Api.functions.channels.readMessageContents(channel: .inputChannel(channelId: channelId, accessHash: accessHash), id: messageIds.map { $0.id }))
|
||||
case let .inputPeerChannel(inputPeerChannelData):
|
||||
let (channelId, accessHash) = (inputPeerChannelData.channelId, inputPeerChannelData.accessHash)
|
||||
request = account.network.request(Api.functions.channels.readMessageContents(channel: .inputChannel(.init(channelId: channelId, accessHash: accessHash)), id: messageIds.map { $0.id }))
|
||||
|> map { _ in true }
|
||||
default:
|
||||
return .complete()
|
||||
@@ -1074,10 +1086,10 @@ public final class AccountViewTracker {
|
||||
fetchSignal = .never()
|
||||
}
|
||||
} else if peerIdAndThreadId.peerId.namespace == Namespaces.Peer.CloudUser || peerIdAndThreadId.peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
fetchSignal = account.network.request(Api.functions.messages.getMessages(id: messageIds.map { Api.InputMessage.inputMessageID(id: $0.id) }))
|
||||
fetchSignal = account.network.request(Api.functions.messages.getMessages(id: messageIds.map { Api.InputMessage.inputMessageID(.init(id: $0.id)) }))
|
||||
} else if peerIdAndThreadId.peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
if let inputChannel = apiInputChannel(peer) {
|
||||
fetchSignal = account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map { Api.InputMessage.inputMessageID(id: $0.id) }))
|
||||
fetchSignal = account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map { Api.InputMessage.inputMessageID(.init(id: $0.id)) }))
|
||||
}
|
||||
}
|
||||
guard let signal = fetchSignal else {
|
||||
@@ -1087,11 +1099,14 @@ public final class AccountViewTracker {
|
||||
return signal
|
||||
|> map { result -> (Peer, [Api.Message], [Api.Chat], [Api.User]) in
|
||||
switch result {
|
||||
case let .messages(messages, _, chats, users):
|
||||
case let .messages(messagesData):
|
||||
let (messages, chats, users) = (messagesData.messages, messagesData.chats, messagesData.users)
|
||||
return (peer, messages, chats, users)
|
||||
case let .messagesSlice(_, _, _, _, _, messages, _, chats, users):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let (messages, chats, users) = (messagesSliceData.messages, messagesSliceData.chats, messagesSliceData.users)
|
||||
return (peer, messages, chats, users)
|
||||
case let .channelMessages(_, _, _, _, messages, _, chats, users):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (messages, chats, users) = (channelMessagesData.messages, channelMessagesData.chats, channelMessagesData.users)
|
||||
return (peer, messages, chats, users)
|
||||
case .messagesNotModified:
|
||||
return (peer, [], [], [])
|
||||
@@ -1180,7 +1195,7 @@ public final class AccountViewTracker {
|
||||
var requests: [Signal<Api.messages.StickerSet?, NoError>] = []
|
||||
for reference in stickerPacks {
|
||||
if case let .id(id, accessHash) = reference {
|
||||
requests.append(account.network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(id: id, accessHash: accessHash), hash: 0))
|
||||
requests.append(account.network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(.init(id: id, accessHash: accessHash)), hash: 0))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.messages.StickerSet?, NoError> in
|
||||
return .single(nil)
|
||||
@@ -1196,7 +1211,8 @@ public final class AccountViewTracker {
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
for result in results {
|
||||
switch result {
|
||||
case let .stickerSet(_, _, _, documents)?:
|
||||
case let .stickerSet(stickerSetData)?:
|
||||
let documents = stickerSetData.documents
|
||||
for document in documents {
|
||||
if let file = telegramMediaFileFromApiDocument(document, altDocuments: []) {
|
||||
if transaction.getMedia(file.fileId) != nil {
|
||||
@@ -1440,7 +1456,8 @@ public final class AccountViewTracker {
|
||||
if i < slice.count {
|
||||
let value = result[i]
|
||||
switch value {
|
||||
case let .recentStory(flags, maxId):
|
||||
case let .recentStory(recentStoryData):
|
||||
let (flags, maxId) = (recentStoryData.flags, recentStoryData.maxId)
|
||||
if let maxId {
|
||||
transaction.setStoryItemsInexactMaxId(peerId: slice[i].0, id: maxId, hasLiveItems: (flags & (1 << 0)) != 0)
|
||||
} else {
|
||||
@@ -1552,7 +1569,8 @@ public final class AccountViewTracker {
|
||||
case .requirementToContactPremium:
|
||||
flags.insert(.premiumRequired)
|
||||
sendPaidMessageStars = nil
|
||||
case let .requirementToContactPaidMessages(starsAmount):
|
||||
case let .requirementToContactPaidMessages(requirementToContactPaidMessagesData):
|
||||
let starsAmount = requirementToContactPaidMessagesData.starsAmount
|
||||
flags.remove(.premiumRequired)
|
||||
sendPaidMessageStars = StarsAmount(value: starsAmount, nanos: 0)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public func currentAppConfiguration(transaction: Transaction) -> AppConfiguratio
|
||||
}
|
||||
}
|
||||
|
||||
func updateAppConfiguration(transaction: Transaction, _ f: (AppConfiguration) -> AppConfiguration) {
|
||||
public func updateAppConfiguration(transaction: Transaction, _ f: (AppConfiguration) -> AppConfiguration) {
|
||||
let current = currentAppConfiguration(transaction: transaction)
|
||||
let updated = f(current)
|
||||
if updated != current {
|
||||
|
||||
@@ -22,7 +22,8 @@ public struct AppUpdateInfo: Equatable {
|
||||
extension AppUpdateInfo {
|
||||
init?(apiAppUpdate: Api.help.AppUpdate) {
|
||||
switch apiAppUpdate {
|
||||
case let .appUpdate(flags, _, version, text, entities, _, _, _):
|
||||
case let .appUpdate(appUpdateData):
|
||||
let (flags, version, text, entities) = (appUpdateData.flags, appUpdateData.version, appUpdateData.text, appUpdateData.entities)
|
||||
self.blocking = (flags & (1 << 0)) != 0
|
||||
self.version = version
|
||||
self.text = text
|
||||
|
||||
@@ -67,7 +67,8 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes
|
||||
|
||||
for update in result.allUpdates {
|
||||
switch update {
|
||||
case let .updateMessageID(id, randomId):
|
||||
case let .updateMessageID(updateMessageIDData):
|
||||
let (id, randomId) = (updateMessageIDData.id, updateMessageIDData.randomId)
|
||||
for attribute in message.attributes {
|
||||
if let attribute = attribute as? OutgoingMessageInfoAttribute {
|
||||
if attribute.uniqueId == randomId {
|
||||
@@ -104,16 +105,19 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes
|
||||
var updatedTimestamp: Int32?
|
||||
if let apiMessage = apiMessage {
|
||||
switch apiMessage {
|
||||
case let .message(_, _, _, _, _, _, _, _, _, _, _, date, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
|
||||
case let .message(messageData):
|
||||
let date = messageData.date
|
||||
updatedTimestamp = date
|
||||
case .messageEmpty:
|
||||
break
|
||||
case let .messageService(_, _, _, _, _, _, date, _, _, _):
|
||||
case let .messageService(messageServiceData):
|
||||
let date = messageServiceData.date
|
||||
updatedTimestamp = date
|
||||
}
|
||||
} else {
|
||||
switch result {
|
||||
case let .updateShortSentMessage(_, _, _, _, date, _, _, _):
|
||||
case let .updateShortSentMessage(updateShortSentMessageData):
|
||||
let (_, _, _, _, date, _, _, _) = (updateShortSentMessageData.flags, updateShortSentMessageData.id, updateShortSentMessageData.pts, updateShortSentMessageData.ptsCount, updateShortSentMessageData.date, updateShortSentMessageData.media, updateShortSentMessageData.entities, updateShortSentMessageData.ttlPeriod)
|
||||
updatedTimestamp = date
|
||||
default:
|
||||
break
|
||||
@@ -151,7 +155,8 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes
|
||||
text = updatedMessage.text
|
||||
forwardInfo = updatedMessage.forwardInfo
|
||||
threadId = updatedMessage.threadId
|
||||
} else if case let .updateShortSentMessage(_, _, _, _, _, apiMedia, entities, ttlPeriod) = result {
|
||||
} else if case let .updateShortSentMessage(updateShortSentMessageData) = result {
|
||||
let (_, _, _, _, _, apiMedia, entities, ttlPeriod) = (updateShortSentMessageData.flags, updateShortSentMessageData.id, updateShortSentMessageData.pts, updateShortSentMessageData.ptsCount, updateShortSentMessageData.date, updateShortSentMessageData.media, updateShortSentMessageData.entities, updateShortSentMessageData.ttlPeriod)
|
||||
let (mediaValue, _, nonPremium, hasSpoiler, _, _) = textMediaAndExpirationTimerFromApiMedia(apiMedia, currentMessage.id.peerId)
|
||||
if let mediaValue = mediaValue {
|
||||
media = [mediaValue]
|
||||
@@ -400,7 +405,7 @@ func applyUpdateGroupMessages(postbox: Postbox, stateManager: AccountStateManage
|
||||
} else if let message = messages.first, let apiMessage = result.messages.first {
|
||||
if message.scheduleTime != nil && message.scheduleTime == apiMessage.timestamp {
|
||||
namespace = Namespaces.Message.ScheduledCloud
|
||||
} else if let apiMessage = result.messages.first, case let .message(_, flags2, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) = apiMessage, (flags2 & (1 << 4)) != 0 {
|
||||
} else if let apiMessage = result.messages.first, case let .message(messageData) = apiMessage, (messageData.flags2 & (1 << 4)) != 0 {
|
||||
namespace = Namespaces.Message.ScheduledCloud
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,8 @@ public final class AvailableMessageEffects: Equatable, Codable {
|
||||
private extension AvailableMessageEffects.MessageEffect {
|
||||
convenience init?(apiMessageEffect: Api.AvailableEffect, files: [Int64: TelegramMediaFile]) {
|
||||
switch apiMessageEffect {
|
||||
case let .availableEffect(flags, id, emoticon, staticIconId, effectStickerId, effectAnimationId):
|
||||
case let .availableEffect(availableEffectData):
|
||||
let (flags, id, emoticon, staticIconId, effectStickerId, effectAnimationId) = (availableEffectData.flags, availableEffectData.id, availableEffectData.emoticon, availableEffectData.staticIconId, availableEffectData.effectStickerId, availableEffectData.effectAnimationId)
|
||||
guard let effectSticker = files[effectStickerId] else {
|
||||
return nil
|
||||
}
|
||||
@@ -239,7 +240,8 @@ func managedSynchronizeAvailableMessageEffects(postbox: Postbox, network: Networ
|
||||
return .complete()
|
||||
}
|
||||
switch result {
|
||||
case let .availableEffects(hash, effects, documents):
|
||||
case let .availableEffects(availableEffectsData):
|
||||
let (hash, effects, documents) = (availableEffectsData.hash, availableEffectsData.effects, availableEffectsData.documents)
|
||||
var files: [Int64: TelegramMediaFile] = [:]
|
||||
for document in documents {
|
||||
if let file = telegramMediaFileFromApiDocument(document, altDocuments: []) {
|
||||
|
||||
@@ -314,7 +314,8 @@ public final class AvailableReactions: Equatable, Codable {
|
||||
private extension AvailableReactions.Reaction {
|
||||
convenience init?(apiReaction: Api.AvailableReaction) {
|
||||
switch apiReaction {
|
||||
case let .availableReaction(flags, reaction, title, staticIcon, appearAnimation, selectAnimation, activateAnimation, effectAnimation, aroundAnimation, centerIcon):
|
||||
case let .availableReaction(availableReactionData):
|
||||
let (flags, reaction, title, staticIcon, appearAnimation, selectAnimation, activateAnimation, effectAnimation, aroundAnimation, centerIcon) = (availableReactionData.flags, availableReactionData.reaction, availableReactionData.title, availableReactionData.staticIcon, availableReactionData.appearAnimation, availableReactionData.selectAnimation, availableReactionData.activateAnimation, availableReactionData.effectAnimation, availableReactionData.aroundAnimation, availableReactionData.centerIcon)
|
||||
guard let staticIconFile = telegramMediaFileFromApiDocument(staticIcon, altDocuments: []) else {
|
||||
return nil
|
||||
}
|
||||
@@ -419,7 +420,8 @@ func managedSynchronizeAvailableReactions(postbox: Postbox, network: Network) ->
|
||||
}
|
||||
|
||||
switch result {
|
||||
case let .availableReactions(hash, reactions):
|
||||
case let .availableReactions(availableReactionsData):
|
||||
let (hash, reactions) = (availableReactionsData.hash, availableReactionsData.reactions)
|
||||
let availableReactions = AvailableReactions(
|
||||
hash: hash,
|
||||
reactions: reactions.compactMap(AvailableReactions.Reaction.init(apiReaction:))
|
||||
|
||||
@@ -66,7 +66,8 @@ public struct GroupCallReference: Codable, Equatable {
|
||||
extension GroupCallReference {
|
||||
init?(_ apiGroupCall: Api.InputGroupCall) {
|
||||
switch apiGroupCall {
|
||||
case let .inputGroupCall(id, accessHash):
|
||||
case let .inputGroupCall(inputGroupCallData):
|
||||
let (id, accessHash) = (inputGroupCallData.id, inputGroupCallData.accessHash)
|
||||
self.init(id: id, accessHash: accessHash)
|
||||
case .inputGroupCallSlug, .inputGroupCallInviteMessage:
|
||||
return nil
|
||||
@@ -74,7 +75,7 @@ extension GroupCallReference {
|
||||
}
|
||||
|
||||
var apiInputGroupCall: Api.InputGroupCall {
|
||||
return .inputGroupCall(id: self.id, accessHash: self.accessHash)
|
||||
return .inputGroupCall(.init(id: self.id, accessHash: self.accessHash))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,10 +330,12 @@ public enum CallSessionConnection: Equatable {
|
||||
|
||||
private func parseConnection(_ apiConnection: Api.PhoneConnection) -> CallSessionConnection {
|
||||
switch apiConnection {
|
||||
case let .phoneConnection(flags, id, ip, ipv6, port, peerTag):
|
||||
case let .phoneConnection(phoneConnectionData):
|
||||
let (flags, id, ip, ipv6, port, peerTag) = (phoneConnectionData.flags, phoneConnectionData.id, phoneConnectionData.ip, phoneConnectionData.ipv6, phoneConnectionData.port, phoneConnectionData.peerTag)
|
||||
let isTcp = (flags & (1 << 0)) != 0
|
||||
return .reflector(CallSessionConnection.Reflector(id: id, ip: ip, ipv6: ipv6, isTcp: isTcp, port: port, peerTag: peerTag.makeData()))
|
||||
case let .phoneConnectionWebrtc(flags, id, ip, ipv6, port, username, password):
|
||||
case let .phoneConnectionWebrtc(phoneConnectionWebrtcData):
|
||||
let (flags, id, ip, ipv6, port, username, password) = (phoneConnectionWebrtcData.flags, phoneConnectionWebrtcData.id, phoneConnectionWebrtcData.ip, phoneConnectionWebrtcData.ipv6, phoneConnectionWebrtcData.port, phoneConnectionWebrtcData.username, phoneConnectionWebrtcData.password)
|
||||
return .webRtcReflector(CallSessionConnection.WebRtcReflector(
|
||||
id: id,
|
||||
hasStun: (flags & (1 << 1)) != 0,
|
||||
@@ -751,7 +754,7 @@ private final class CallSessionManagerContext {
|
||||
self.contexts[internalId] = context
|
||||
let queue = self.queue
|
||||
|
||||
let requestSignal: Signal<Api.Bool, MTRpcError> = self.network.request(Api.functions.phone.receivedCall(peer: .inputPhoneCall(id: stableId, accessHash: accessHash)))
|
||||
let requestSignal: Signal<Api.Bool, MTRpcError> = self.network.request(Api.functions.phone.receivedCall(peer: .inputPhoneCall(.init(id: stableId, accessHash: accessHash))))
|
||||
|
||||
context.acknowledgeIncomingCallDisposable.set(requestSignal.start(error: { [weak self] _ in
|
||||
queue.async {
|
||||
@@ -1018,7 +1021,7 @@ private final class CallSessionManagerContext {
|
||||
if let context = self.contexts[internalId] {
|
||||
switch context.state {
|
||||
case let .active(id, accessHash, _, _, _, _, _, _, _, _, _, _):
|
||||
context.signalingDisposables.add(self.network.request(Api.functions.phone.sendSignalingData(peer: .inputPhoneCall(id: id, accessHash: accessHash), data: Buffer(data: data))).start())
|
||||
context.signalingDisposables.add(self.network.request(Api.functions.phone.sendSignalingData(peer: .inputPhoneCall(.init(id: id, accessHash: accessHash)), data: Buffer(data: data))).start())
|
||||
default:
|
||||
break
|
||||
}
|
||||
@@ -1073,10 +1076,12 @@ private final class CallSessionManagerContext {
|
||||
switch call {
|
||||
case .phoneCallEmpty:
|
||||
break
|
||||
case let .phoneCallAccepted(_, id, _, _, _, _, gB, remoteProtocol):
|
||||
case let .phoneCallAccepted(phoneCallAcceptedData):
|
||||
let (id, gB, remoteProtocol) = (phoneCallAcceptedData.id, phoneCallAcceptedData.gB, phoneCallAcceptedData.protocol)
|
||||
let remoteVersions: [String]
|
||||
switch remoteProtocol {
|
||||
case let .phoneCallProtocol(_, _, _, versions):
|
||||
case let .phoneCallProtocol(phoneCallProtocolData):
|
||||
let versions = phoneCallProtocolData.libraryVersions
|
||||
remoteVersions = versions
|
||||
}
|
||||
if let internalId = self.contextIdByStableId[id] {
|
||||
@@ -1129,7 +1134,8 @@ private final class CallSessionManagerContext {
|
||||
assertionFailure()
|
||||
}
|
||||
}
|
||||
case let .phoneCallDiscarded(flags, id, reason, _):
|
||||
case let .phoneCallDiscarded(phoneCallDiscardedData):
|
||||
let (flags, id, reason) = (phoneCallDiscardedData.flags, phoneCallDiscardedData.id, phoneCallDiscardedData.reason)
|
||||
let reportRating = (flags & (1 << 2)) != 0
|
||||
let sendDebugLogs = (flags & (1 << 3)) != 0
|
||||
if let internalId = self.contextIdByStableId[id] {
|
||||
@@ -1145,7 +1151,8 @@ private final class CallSessionManagerContext {
|
||||
parsedReason = .ended(.hungUp)
|
||||
case .phoneCallDiscardReasonMissed:
|
||||
parsedReason = .ended(.missed)
|
||||
case let .phoneCallDiscardReasonMigrateConferenceCall(slug):
|
||||
case let .phoneCallDiscardReasonMigrateConferenceCall(phoneCallDiscardReasonMigrateConferenceCallData):
|
||||
let slug = phoneCallDiscardReasonMigrateConferenceCallData.slug
|
||||
parsedReason = .ended(.switchedToConference(slug: slug))
|
||||
}
|
||||
} else {
|
||||
@@ -1185,7 +1192,8 @@ private final class CallSessionManagerContext {
|
||||
//assertionFailure()
|
||||
}
|
||||
}
|
||||
case let .phoneCall(flags, id, _, _, _, _, gAOrB, keyFingerprint, callProtocol, connections, startDate, customParameters):
|
||||
case let .phoneCall(phoneCallData):
|
||||
let (flags, id, gAOrB, keyFingerprint, callProtocol, connections, startDate, customParameters) = (phoneCallData.flags, phoneCallData.id, phoneCallData.gAOrB, phoneCallData.keyFingerprint, phoneCallData.protocol, phoneCallData.connections, phoneCallData.startDate, phoneCallData.customParameters)
|
||||
let allowsP2P = (flags & (1 << 5)) != 0
|
||||
let supportsConferenceCalls = (flags & (1 << 8)) != 0
|
||||
if let internalId = self.contextIdByStableId[id] {
|
||||
@@ -1200,19 +1208,21 @@ private final class CallSessionManagerContext {
|
||||
if let (key, calculatedKeyId, keyVisualHash) = self.makeSessionEncryptionKey(config: config, gAHash: gAHash, b: b, gA: gAOrB.makeData()) {
|
||||
if keyFingerprint == calculatedKeyId {
|
||||
switch callProtocol {
|
||||
case let .phoneCallProtocol(_, _, maxLayer, versions):
|
||||
case let .phoneCallProtocol(phoneCallProtocolData):
|
||||
let (maxLayer, versions) = (phoneCallProtocolData.maxLayer, phoneCallProtocolData.libraryVersions)
|
||||
if !versions.isEmpty {
|
||||
var customParametersValue: String?
|
||||
switch customParameters {
|
||||
case .none:
|
||||
break
|
||||
case let .dataJSON(data):
|
||||
case let .dataJSON(dataJSONData):
|
||||
let data = dataJSONData.data
|
||||
customParametersValue = data
|
||||
}
|
||||
|
||||
|
||||
let isVideoPossible = self.videoVersions().contains(where: { versions.contains($0) })
|
||||
context.isVideoPossible = isVideoPossible
|
||||
|
||||
|
||||
context.state = .active(id: id, accessHash: accessHash, beginTimestamp: startDate, key: key, keyId: calculatedKeyId, keyVisualHash: keyVisualHash, connections: parseConnectionSet(primary: connections.first!, alternative: Array(connections[1...])), maxLayer: maxLayer, version: versions[0], customParameters: customParametersValue, allowsP2P: allowsP2P, supportsConferenceCalls: supportsConferenceCalls)
|
||||
self.contextUpdated(internalId: internalId)
|
||||
} else {
|
||||
@@ -1227,19 +1237,21 @@ private final class CallSessionManagerContext {
|
||||
}
|
||||
case let .confirming(id, accessHash, key, keyId, keyVisualHash, _):
|
||||
switch callProtocol {
|
||||
case let .phoneCallProtocol(_, _, maxLayer, versions):
|
||||
case let .phoneCallProtocol(phoneCallProtocolData):
|
||||
let (maxLayer, versions) = (phoneCallProtocolData.maxLayer, phoneCallProtocolData.libraryVersions)
|
||||
if !versions.isEmpty {
|
||||
var customParametersValue: String?
|
||||
switch customParameters {
|
||||
case .none:
|
||||
break
|
||||
case let .dataJSON(data):
|
||||
case let .dataJSON(dataJSONData):
|
||||
let data = dataJSONData.data
|
||||
customParametersValue = data
|
||||
}
|
||||
|
||||
|
||||
let isVideoPossible = self.videoVersions().contains(where: { versions.contains($0) })
|
||||
context.isVideoPossible = isVideoPossible
|
||||
|
||||
|
||||
context.state = .active(id: id, accessHash: accessHash, beginTimestamp: startDate, key: key, keyId: keyId, keyVisualHash: keyVisualHash, connections: parseConnectionSet(primary: connections.first!, alternative: Array(connections[1...])), maxLayer: maxLayer, version: versions[0], customParameters: customParametersValue, allowsP2P: allowsP2P, supportsConferenceCalls: supportsConferenceCalls)
|
||||
self.contextUpdated(internalId: internalId)
|
||||
} else {
|
||||
@@ -1251,11 +1263,13 @@ private final class CallSessionManagerContext {
|
||||
assertionFailure()
|
||||
}
|
||||
}
|
||||
case let .phoneCallRequested(flags, id, accessHash, date, adminId, _, gAHash, requestedProtocol):
|
||||
case let .phoneCallRequested(phoneCallRequestedData):
|
||||
let (flags, id, accessHash, date, adminId, gAHash, requestedProtocol) = (phoneCallRequestedData.flags, phoneCallRequestedData.id, phoneCallRequestedData.accessHash, phoneCallRequestedData.date, phoneCallRequestedData.adminId, phoneCallRequestedData.gAHash, phoneCallRequestedData.protocol)
|
||||
let isVideo = (flags & (1 << 6)) != 0
|
||||
let versions: [String]
|
||||
switch requestedProtocol {
|
||||
case let .phoneCallProtocol(_, _, _, libraryVersions):
|
||||
case let .phoneCallProtocol(phoneCallProtocolData):
|
||||
let libraryVersions = phoneCallProtocolData.libraryVersions
|
||||
versions = libraryVersions
|
||||
}
|
||||
if self.contextIdByStableId[id] == nil {
|
||||
@@ -1276,7 +1290,8 @@ private final class CallSessionManagerContext {
|
||||
}
|
||||
}
|
||||
}
|
||||
case let .phoneCallWaiting(_, id, _, _, _, _, _, receiveDate):
|
||||
case let .phoneCallWaiting(phoneCallWaitingData):
|
||||
let (id, receiveDate) = (phoneCallWaitingData.id, phoneCallWaitingData.receiveDate)
|
||||
if let internalId = self.contextIdByStableId[id] {
|
||||
if let context = self.contexts[internalId] {
|
||||
switch context.state {
|
||||
@@ -1598,7 +1613,7 @@ private func acceptCallSession(accountPeerId: PeerId, postbox: Postbox, network:
|
||||
return .single(.failed)
|
||||
}
|
||||
|
||||
return network.request(Api.functions.phone.acceptCall(peer: .inputPhoneCall(id: stableId, accessHash: accessHash), gB: Buffer(data: gb), protocol: .phoneCallProtocol(flags: (1 << 0) | (1 << 1), minLayer: minLayer, maxLayer: maxLayer, libraryVersions: versions)))
|
||||
return network.request(Api.functions.phone.acceptCall(peer: .inputPhoneCall(.init(id: stableId, accessHash: accessHash)), gB: Buffer(data: gb), protocol: .phoneCallProtocol(.init(flags: (1 << 0) | (1 << 1), minLayer: minLayer, maxLayer: maxLayer, libraryVersions: versions))))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.phone.PhoneCall?, NoError> in
|
||||
return .single(nil)
|
||||
@@ -1607,7 +1622,8 @@ private func acceptCallSession(accountPeerId: PeerId, postbox: Postbox, network:
|
||||
if let call = call {
|
||||
return postbox.transaction { transaction -> AcceptCallResult in
|
||||
switch call {
|
||||
case let .phoneCall(phoneCall, users):
|
||||
case let .phoneCall(phoneCallData):
|
||||
let (phoneCall, users) = (phoneCallData.phoneCall, phoneCallData.users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
|
||||
|
||||
switch phoneCall {
|
||||
@@ -1615,19 +1631,22 @@ private func acceptCallSession(accountPeerId: PeerId, postbox: Postbox, network:
|
||||
return .failed
|
||||
case .phoneCallWaiting:
|
||||
return .success(.waiting(config: config))
|
||||
case let .phoneCall(flags, id, _, _, _, _, gAOrB, _, callProtocol, connections, startDate, customParameters):
|
||||
case let .phoneCall(phoneCallData):
|
||||
let (flags, id, gAOrB, callProtocol, connections, startDate, customParameters) = (phoneCallData.flags, phoneCallData.id, phoneCallData.gAOrB, phoneCallData.protocol, phoneCallData.connections, phoneCallData.startDate, phoneCallData.customParameters)
|
||||
if id == stableId {
|
||||
switch callProtocol{
|
||||
case let .phoneCallProtocol(_, _, maxLayer, versions):
|
||||
case let .phoneCallProtocol(phoneCallProtocolData):
|
||||
let (maxLayer, versions) = (phoneCallProtocolData.maxLayer, phoneCallProtocolData.libraryVersions)
|
||||
if !versions.isEmpty {
|
||||
var customParametersValue: String?
|
||||
switch customParameters {
|
||||
case .none:
|
||||
break
|
||||
case let .dataJSON(data):
|
||||
case let .dataJSON(dataJSONData):
|
||||
let data = dataJSONData.data
|
||||
customParametersValue = data
|
||||
}
|
||||
|
||||
|
||||
return .success(.call(config: config, gA: gAOrB.makeData(), timestamp: startDate, connections: parseConnectionSet(primary: connections.first!, alternative: Array(connections[1...])), maxLayer: maxLayer, version: versions[0], customParameters: customParametersValue, allowsP2P: (flags & (1 << 5)) != 0, supportsConferenceCalls: (flags & (1 << 8)) != 0))
|
||||
} else {
|
||||
return .failed
|
||||
@@ -1672,14 +1691,17 @@ private func requestCallSession(postbox: Postbox, network: Network, peerId: Peer
|
||||
callFlags |= 1 << 0
|
||||
}
|
||||
|
||||
return network.request(Api.functions.phone.requestCall(flags: callFlags, userId: inputUser, randomId: Int32(bitPattern: arc4random()), gAHash: Buffer(data: gAHash), protocol: .phoneCallProtocol(flags: (1 << 0) | (1 << 1), minLayer: minLayer, maxLayer: maxLayer, libraryVersions: versions)))
|
||||
return network.request(Api.functions.phone.requestCall(flags: callFlags, userId: inputUser, randomId: Int32(bitPattern: arc4random()), gAHash: Buffer(data: gAHash), protocol: .phoneCallProtocol(.init(flags: (1 << 0) | (1 << 1), minLayer: minLayer, maxLayer: maxLayer, libraryVersions: versions))))
|
||||
|> map { result -> RequestCallSessionResult in
|
||||
switch result {
|
||||
case let .phoneCall(phoneCall, _):
|
||||
case let .phoneCall(phoneCallData):
|
||||
let (phoneCall, _) = (phoneCallData.phoneCall, phoneCallData.users)
|
||||
switch phoneCall {
|
||||
case let .phoneCallRequested(_, id, accessHash, _, _, _, _, _):
|
||||
case let .phoneCallRequested(phoneCallRequestedData):
|
||||
let (id, accessHash) = (phoneCallRequestedData.id, phoneCallRequestedData.accessHash)
|
||||
return .success(id: id, accessHash: accessHash, config: config, gA: ga, remoteConfirmationTimestamp: nil)
|
||||
case let .phoneCallWaiting(_, id, accessHash, _, _, _, _, receiveDate):
|
||||
case let .phoneCallWaiting(phoneCallWaitingData):
|
||||
let (id, accessHash, receiveDate) = (phoneCallWaitingData.id, phoneCallWaitingData.accessHash, phoneCallWaitingData.receiveDate)
|
||||
return .success(id: id, accessHash: accessHash, config: config, gA: ga, remoteConfirmationTimestamp: receiveDate)
|
||||
default:
|
||||
return .failed(.generic)
|
||||
@@ -1709,7 +1731,7 @@ private func requestCallSession(postbox: Postbox, network: Network, peerId: Peer
|
||||
}
|
||||
|
||||
private func confirmCallSession(network: Network, stableId: CallSessionStableId, accessHash: Int64, gA: Data, keyFingerprint: Int64, maxLayer: Int32, versions: [String]) -> Signal<Api.PhoneCall?, NoError> {
|
||||
return network.request(Api.functions.phone.confirmCall(peer: Api.InputPhoneCall.inputPhoneCall(id: stableId, accessHash: accessHash), gA: Buffer(data: gA), keyFingerprint: keyFingerprint, protocol: .phoneCallProtocol(flags: (1 << 0) | (1 << 1), minLayer: minLayer, maxLayer: maxLayer, libraryVersions: versions)))
|
||||
return network.request(Api.functions.phone.confirmCall(peer: Api.InputPhoneCall.inputPhoneCall(.init(id: stableId, accessHash: accessHash)), gA: Buffer(data: gA), keyFingerprint: keyFingerprint, protocol: .phoneCallProtocol(.init(flags: (1 << 0) | (1 << 1), minLayer: minLayer, maxLayer: maxLayer, libraryVersions: versions))))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.phone.PhoneCall?, NoError> in
|
||||
return .single(nil)
|
||||
@@ -1717,7 +1739,8 @@ private func confirmCallSession(network: Network, stableId: CallSessionStableId,
|
||||
|> map { result -> Api.PhoneCall? in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .phoneCall(phoneCall, _):
|
||||
case let .phoneCall(phoneCallData):
|
||||
let (phoneCall, _) = (phoneCallData.phoneCall, phoneCallData.users)
|
||||
return phoneCall
|
||||
}
|
||||
} else {
|
||||
@@ -1751,7 +1774,7 @@ private func dropCallSession(network: Network, addUpdates: @escaping (Api.Update
|
||||
case .missed:
|
||||
mappedReason = .phoneCallDiscardReasonMissed
|
||||
case let .switchToConference(slug):
|
||||
mappedReason = .phoneCallDiscardReasonMigrateConferenceCall(slug: slug)
|
||||
mappedReason = .phoneCallDiscardReasonMigrateConferenceCall(.init(slug: slug))
|
||||
}
|
||||
|
||||
var callFlags: Int32 = 0
|
||||
@@ -1759,7 +1782,7 @@ private func dropCallSession(network: Network, addUpdates: @escaping (Api.Update
|
||||
callFlags |= 1 << 0
|
||||
}
|
||||
|
||||
return network.request(Api.functions.phone.discardCall(flags: callFlags, peer: Api.InputPhoneCall.inputPhoneCall(id: stableId, accessHash: accessHash), duration: duration, reason: mappedReason, connectionId: 0))
|
||||
return network.request(Api.functions.phone.discardCall(flags: callFlags, peer: Api.InputPhoneCall.inputPhoneCall(.init(id: stableId, accessHash: accessHash)), duration: duration, reason: mappedReason, connectionId: 0))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
|
||||
return .single(nil)
|
||||
@@ -1769,12 +1792,15 @@ private func dropCallSession(network: Network, addUpdates: @escaping (Api.Update
|
||||
var sendDebugLogs: Bool = false
|
||||
if let updates = updates {
|
||||
switch updates {
|
||||
case .updates(let updates, _, _, _, _):
|
||||
case let .updates(updatesData):
|
||||
let updates = updatesData.updates
|
||||
for update in updates {
|
||||
switch update {
|
||||
case .updatePhoneCall(let phoneCall):
|
||||
case let .updatePhoneCall(updatePhoneCallData):
|
||||
let phoneCall = updatePhoneCallData.phoneCall
|
||||
switch phoneCall {
|
||||
case let .phoneCallDiscarded(flags, _, _, _):
|
||||
case let .phoneCallDiscarded(phoneCallDiscardedData):
|
||||
let flags = phoneCallDiscardedData.flags
|
||||
reportRating = (flags & (1 << 2)) != 0
|
||||
sendDebugLogs = (flags & (1 << 3)) != 0
|
||||
default:
|
||||
|
||||
@@ -100,7 +100,8 @@ func _internal_getChannelBoostStatus(account: Account, peerId: PeerId) -> Signal
|
||||
return nil
|
||||
}
|
||||
switch result {
|
||||
case let .boostsStatus(flags, level, currentLevelBoosts, boosts, giftBoosts, nextLevelBoosts, premiumAudience, boostUrl, prepaidGiveaways, myBoostSlots):
|
||||
case let .boostsStatus(boostsStatusData):
|
||||
let (flags, level, currentLevelBoosts, boosts, giftBoosts, nextLevelBoosts, premiumAudience, boostUrl, prepaidGiveaways, myBoostSlots) = (boostsStatusData.flags, boostsStatusData.level, boostsStatusData.currentLevelBoosts, boostsStatusData.boosts, boostsStatusData.giftBoosts, boostsStatusData.nextLevelBoosts, boostsStatusData.premiumAudience, boostsStatusData.boostUrl, boostsStatusData.prepaidGiveaways, boostsStatusData.myBoostSlots)
|
||||
let _ = myBoostSlots
|
||||
return ChannelBoostStatus(level: Int(level), boosts: Int(boosts), giftBoosts: giftBoosts.flatMap(Int.init), currentLevelBoosts: Int(currentLevelBoosts), nextLevelBoosts: nextLevelBoosts.flatMap(Int.init), premiumAudience: premiumAudience.flatMap({ StatsPercentValue(apiPercentValue: $0) }), url: boostUrl, prepaidGiveaways: prepaidGiveaways?.map({ PrepaidGiveaway(apiPrepaidGiveaway: $0) }) ?? [], boostedByMe: (flags & (1 << 2)) != 0)
|
||||
}
|
||||
@@ -274,12 +275,14 @@ private final class ChannelBoostersContextImpl {
|
||||
return ([], 0, nil)
|
||||
}
|
||||
switch result {
|
||||
case let .boostsList(_, count, boosts, nextOffset, users):
|
||||
case let .boostsList(boostsListData):
|
||||
let (_, count, boosts, nextOffset, users) = (boostsListData.flags, boostsListData.count, boostsListData.boosts, boostsListData.nextOffset, boostsListData.users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
|
||||
var resultBoosts: [ChannelBoostersContext.State.Boost] = []
|
||||
for boost in boosts {
|
||||
switch boost {
|
||||
case let .boost(flags, id, userId, giveawayMessageId, date, expires, usedGiftSlug, multiplier, stars):
|
||||
case let .boost(boostData):
|
||||
let (flags, id, userId, giveawayMessageId, date, expires, usedGiftSlug, multiplier, stars) = (boostData.flags, boostData.id, boostData.userId, boostData.giveawayMsgId, boostData.date, boostData.expires, boostData.usedGiftSlug, boostData.multiplier, boostData.stars)
|
||||
var boostFlags: ChannelBoostersContext.State.Boost.Flags = []
|
||||
var boostPeer: EnginePeer?
|
||||
if let userId = userId {
|
||||
@@ -546,12 +549,14 @@ extension MyBoostStatus {
|
||||
init(apiMyBoostStatus: Api.premium.MyBoosts, accountPeerId: PeerId, transaction: Transaction) {
|
||||
var boostsResult: [MyBoostStatus.Boost] = []
|
||||
switch apiMyBoostStatus {
|
||||
case let .myBoosts(myBoosts, chats, users):
|
||||
case let .myBoosts(myBoostsData):
|
||||
let (myBoosts, chats, users) = (myBoostsData.myBoosts, myBoostsData.chats, myBoostsData.users)
|
||||
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
for boost in myBoosts {
|
||||
switch boost {
|
||||
case let .myBoost(_, slot, peer, date, expires, cooldownUntilDate):
|
||||
case let .myBoost(myBoostData):
|
||||
let (slot, peer, date, expires, cooldownUntilDate) = (myBoostData.slot, myBoostData.peer, myBoostData.date, myBoostData.expires, myBoostData.cooldownUntilDate)
|
||||
var boostPeer: EnginePeer?
|
||||
if let peerId = peer?.peerId, let peer = transaction.getPeer(peerId) {
|
||||
boostPeer = EnginePeer(peer)
|
||||
|
||||
@@ -14,13 +14,17 @@ func channelUpdatesByPeerId(updates: [ChannelUpdate]) -> [PeerId: [ChannelUpdate
|
||||
for update in updates {
|
||||
var peerId: PeerId?
|
||||
switch update.update {
|
||||
case let .updateNewChannelMessage(message, _, _):
|
||||
case let .updateNewChannelMessage(updateNewChannelMessageData):
|
||||
let (message, _, _) = (updateNewChannelMessageData.message, updateNewChannelMessageData.pts, updateNewChannelMessageData.ptsCount)
|
||||
peerId = apiMessagePeerId(message)
|
||||
case let .updateDeleteChannelMessages(channelId, _, _, _):
|
||||
case let .updateDeleteChannelMessages(updateDeleteChannelMessagesData):
|
||||
let (channelId, _, _, _) = (updateDeleteChannelMessagesData.channelId, updateDeleteChannelMessagesData.messages, updateDeleteChannelMessagesData.pts, updateDeleteChannelMessagesData.ptsCount)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
case let .updateEditChannelMessage(message, _, _):
|
||||
case let .updateEditChannelMessage(updateEditChannelMessageData):
|
||||
let (message, _, _) = (updateEditChannelMessageData.message, updateEditChannelMessageData.pts, updateEditChannelMessageData.ptsCount)
|
||||
peerId = apiMessagePeerId(message)
|
||||
case let .updateChannelWebPage(channelId, _, _, _):
|
||||
case let .updateChannelWebPage(updateChannelWebPageData):
|
||||
let (channelId, _, _, _) = (updateChannelWebPageData.channelId, updateChannelWebPageData.webpage, updateChannelWebPageData.pts, updateChannelWebPageData.ptsCount)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
default:
|
||||
break
|
||||
|
||||
@@ -326,7 +326,7 @@ private func pushDeviceContactData(accountPeerId: PeerId, postbox: Postbox, netw
|
||||
batches = batches
|
||||
|> mapToSignal { intermediateResult -> Signal<PushDeviceContactsResult, NoError> in
|
||||
return network.request(Api.functions.contacts.importContacts(contacts: zip(0 ..< batch.count, batch).map { index, item -> Api.InputContact in
|
||||
return .inputPhoneContact(flags: 0, clientId: Int64(index), phone: item.0.rawValue, firstName: item.1.firstName, lastName: item.1.lastName, note: nil)
|
||||
return .inputPhoneContact(.init(flags: 0, clientId: Int64(index), phone: item.0.rawValue, firstName: item.1.firstName, lastName: item.1.lastName, note: nil))
|
||||
}))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.contacts.ImportedContacts?, NoError> in
|
||||
@@ -341,12 +341,14 @@ private func pushDeviceContactData(accountPeerId: PeerId, postbox: Postbox, netw
|
||||
var importedCounts: [Int: Int32] = [:]
|
||||
var peerIdByClientId: [Int64: PeerId] = [:]
|
||||
switch result {
|
||||
case let .importedContacts(imported, popularInvites, retryContacts, users):
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
|
||||
case let .importedContacts(importedContactsData):
|
||||
let (imported, popularInvites, retryContacts, users) = (importedContactsData.imported, importedContactsData.popularInvites, importedContactsData.retryContacts, importedContactsData.users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
|
||||
|
||||
for item in imported {
|
||||
switch item {
|
||||
case let .importedContact(userId, clientId):
|
||||
case let .importedContact(importedContactData):
|
||||
let (userId, clientId) = (importedContactData.userId, importedContactData.clientId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
|
||||
addedContactPeerIds.insert(peerId)
|
||||
peerIdByClientId[clientId] = peerId
|
||||
@@ -357,7 +359,8 @@ private func pushDeviceContactData(accountPeerId: PeerId, postbox: Postbox, netw
|
||||
}
|
||||
for item in popularInvites {
|
||||
switch item {
|
||||
case let .popularContact(clientId, importers):
|
||||
case let .popularContact(popularContactData):
|
||||
let (clientId, importers) = (popularContactData.clientId, popularContactData.importers)
|
||||
importedCounts[Int(clientId)] = importers
|
||||
}
|
||||
}
|
||||
@@ -405,7 +408,8 @@ private func updateContactPresences(postbox: Postbox, network: Network, accountP
|
||||
var peerPresences: [PeerId: PeerPresence] = [:]
|
||||
for status in statuses {
|
||||
switch status {
|
||||
case let .contactStatus(userId, status):
|
||||
case let .contactStatus(contactStatusData):
|
||||
let (userId, status) = (contactStatusData.userId, contactStatusData.status)
|
||||
peerPresences[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))] = TelegramUserPresence(apiStatus: status)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,26 +159,30 @@ func managedSynchronizeEmojiSearchCategories(postbox: Postbox, network: Network,
|
||||
|> mapToSignal { result -> Signal<Never, NoError> in
|
||||
return postbox.transaction { transaction -> Signal<Never, NoError> in
|
||||
switch result {
|
||||
case let .emojiGroups(hash, groups):
|
||||
case let .emojiGroups(emojiGroupsData):
|
||||
let (hash, groups) = (emojiGroupsData.hash, emojiGroupsData.groups)
|
||||
let categories = EmojiSearchCategories(
|
||||
hash: hash,
|
||||
groups: groups.compactMap { item -> EmojiSearchCategories.Group? in
|
||||
switch item {
|
||||
case let .emojiGroup(title, iconEmojiId, emoticons):
|
||||
case let .emojiGroup(emojiGroupData):
|
||||
let (title, iconEmojiId, emoticons) = (emojiGroupData.title, emojiGroupData.iconEmojiId, emojiGroupData.emoticons)
|
||||
return EmojiSearchCategories.Group(
|
||||
id: iconEmojiId,
|
||||
title: title,
|
||||
identifiers: emoticons,
|
||||
kind: .generic
|
||||
)
|
||||
case let .emojiGroupGreeting(title, iconEmojiId, emoticons):
|
||||
case let .emojiGroupGreeting(emojiGroupGreetingData):
|
||||
let (title, iconEmojiId, emoticons) = (emojiGroupGreetingData.title, emojiGroupGreetingData.iconEmojiId, emojiGroupGreetingData.emoticons)
|
||||
return EmojiSearchCategories.Group(
|
||||
id: iconEmojiId,
|
||||
title: title,
|
||||
identifiers: emoticons,
|
||||
kind: .greeting
|
||||
)
|
||||
case let .emojiGroupPremium(title, iconEmojiId):
|
||||
case let .emojiGroupPremium(emojiGroupPremiumData):
|
||||
let (title, iconEmojiId) = (emojiGroupPremiumData.title, emojiGroupPremiumData.iconEmojiId)
|
||||
return EmojiSearchCategories.Group(
|
||||
id: iconEmojiId,
|
||||
title: title,
|
||||
|
||||
@@ -30,9 +30,11 @@ struct ParsedDialogs {
|
||||
|
||||
private func extractDialogsData(dialogs: Api.messages.Dialogs) -> (apiDialogs: [Api.Dialog], apiMessages: [Api.Message], apiChats: [Api.Chat], apiUsers: [Api.User], apiIsAtLowestBoundary: Bool) {
|
||||
switch dialogs {
|
||||
case let .dialogs(dialogs, messages, chats, users):
|
||||
case let .dialogs(dialogsData):
|
||||
let (dialogs, messages, chats, users) = (dialogsData.dialogs, dialogsData.messages, dialogsData.chats, dialogsData.users)
|
||||
return (dialogs, messages, chats, users, true)
|
||||
case let .dialogsSlice(_, dialogs, messages, chats, users):
|
||||
case let .dialogsSlice(dialogsSliceData):
|
||||
let (_, dialogs, messages, chats, users) = (dialogsSliceData.count, dialogsSliceData.dialogs, dialogsSliceData.messages, dialogsSliceData.chats, dialogsSliceData.users)
|
||||
return (dialogs, messages, chats, users, false)
|
||||
case .dialogsNotModified:
|
||||
assertionFailure()
|
||||
@@ -42,7 +44,8 @@ private func extractDialogsData(dialogs: Api.messages.Dialogs) -> (apiDialogs: [
|
||||
|
||||
private func extractDialogsData(peerDialogs: Api.messages.PeerDialogs) -> (apiDialogs: [Api.Dialog], apiMessages: [Api.Message], apiChats: [Api.Chat], apiUsers: [Api.User], apiIsAtLowestBoundary: Bool) {
|
||||
switch peerDialogs {
|
||||
case let .peerDialogs(dialogs, messages, chats, users, _):
|
||||
case let .peerDialogs(peerDialogsData):
|
||||
let (dialogs, messages, chats, users) = (peerDialogsData.dialogs, peerDialogsData.messages, peerDialogsData.chats, peerDialogsData.users)
|
||||
return (dialogs, messages, chats, users, false)
|
||||
}
|
||||
}
|
||||
@@ -77,7 +80,8 @@ private func parseDialogs(accountPeerId: PeerId, apiDialogs: [Api.Dialog], apiMe
|
||||
var apiChannelPts: Int32?
|
||||
let apiNotificationSettings: Api.PeerNotifySettings
|
||||
switch dialog {
|
||||
case let .dialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, peerNotificationSettings, pts, _, _, ttlPeriod):
|
||||
case let .dialog(dialogData):
|
||||
let (flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, peerNotificationSettings, pts, ttlPeriod) = (dialogData.flags, dialogData.peer, dialogData.topMessage, dialogData.readInboxMaxId, dialogData.readOutboxMaxId, dialogData.unreadCount, dialogData.unreadMentionsCount, dialogData.unreadReactionsCount, dialogData.notifySettings, dialogData.pts, dialogData.ttlPeriod)
|
||||
if let peer = peers.get(peer.peerId) {
|
||||
var isExluded = false
|
||||
if let group = peer as? TelegramGroup {
|
||||
@@ -109,11 +113,14 @@ private func parseDialogs(accountPeerId: PeerId, apiDialogs: [Api.Dialog], apiMe
|
||||
}
|
||||
let peerId: PeerId
|
||||
switch apiPeer {
|
||||
case let .peerUser(userId):
|
||||
case let .peerUser(peerUserData):
|
||||
let userId = peerUserData.userId
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
|
||||
case let .peerChat(chatId):
|
||||
case let .peerChat(peerChatData):
|
||||
let chatId = peerChatData.chatId
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))
|
||||
case let .peerChannel(channelId):
|
||||
case let .peerChannel(peerChannelData):
|
||||
let channelId = peerChannelData.channelId
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
}
|
||||
|
||||
@@ -133,9 +140,11 @@ private func parseDialogs(accountPeerId: PeerId, apiDialogs: [Api.Dialog], apiMe
|
||||
}
|
||||
|
||||
notificationSettings[peerId] = TelegramPeerNotificationSettings(apiSettings: apiNotificationSettings)
|
||||
case let .dialogFolder(_, folder, _, _, unreadMutedPeersCount, _, unreadMutedMessagesCount, _):
|
||||
case let .dialogFolder(dialogFolderData):
|
||||
let (folder, unreadMutedPeersCount, unreadMutedMessagesCount) = (dialogFolderData.folder, dialogFolderData.unreadMutedPeersCount, dialogFolderData.unreadMutedMessagesCount)
|
||||
switch folder {
|
||||
case let .folder(_, id, _, _):
|
||||
case let .folder(folderData):
|
||||
let id = folderData.id
|
||||
referencedFolders[PeerGroupId(rawValue: id)] = PeerGroupUnreadCountersSummary(all: PeerGroupUnreadCounters(messageCount: unreadMutedMessagesCount, chatCount: unreadMutedPeersCount))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,17 +558,20 @@ private func validateChannelMessagesBatch(postbox: Postbox, network: Network, ac
|
||||
var channelPts: Int32?
|
||||
|
||||
switch result {
|
||||
case let .messages(messages: apiMessages, topics: apiTopics, chats: apiChats, users: apiUsers):
|
||||
case let .messages(messagesData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (messagesData.messages, messagesData.topics, messagesData.chats, messagesData.users)
|
||||
let _ = apiTopics
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .messagesSlice(_, _, _, _, _, messages: apiMessages, topics: apiTopics, chats: apiChats, users: apiUsers):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (messagesSliceData.messages, messagesSliceData.topics, messagesSliceData.chats, messagesSliceData.users)
|
||||
let _ = apiTopics
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .channelMessages(_, pts, _, _, apiMessages, apiTopics, apiChats, apiUsers):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (pts, apiMessages, apiTopics, apiChats, apiUsers) = (channelMessagesData.pts, channelMessagesData.messages, channelMessagesData.topics, channelMessagesData.chats, channelMessagesData.users)
|
||||
messages = apiMessages
|
||||
let _ = apiTopics
|
||||
chats = apiChats
|
||||
@@ -629,17 +632,20 @@ private func validateReplyThreadMessagesBatch(postbox: Postbox, network: Network
|
||||
var channelPts: Int32?
|
||||
|
||||
switch result {
|
||||
case let .messages(messages: apiMessages, topics: apiTopics, chats: apiChats, users: apiUsers):
|
||||
case let .messages(messagesData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (messagesData.messages, messagesData.topics, messagesData.chats, messagesData.users)
|
||||
let _ = apiTopics
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .messagesSlice(_, _, _, _, _, messages: apiMessages, topics: apiTopics, chats: apiChats, users: apiUsers):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (messagesSliceData.messages, messagesSliceData.topics, messagesSliceData.chats, messagesSliceData.users)
|
||||
let _ = apiTopics
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .channelMessages(_, pts, _, _, apiMessages, apiTopics, apiChats, apiUsers):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (pts, apiMessages, apiTopics, apiChats, apiUsers) = (channelMessagesData.pts, channelMessagesData.messages, channelMessagesData.topics, channelMessagesData.chats, channelMessagesData.users)
|
||||
messages = apiMessages
|
||||
let _ = apiTopics
|
||||
chats = apiChats
|
||||
@@ -653,7 +659,7 @@ private func validateReplyThreadMessagesBatch(postbox: Postbox, network: Network
|
||||
} else {
|
||||
return .complete()
|
||||
}
|
||||
|
||||
|
||||
return validateReplyThreadBatch(postbox: postbox, network: network, transaction: transaction, accountPeerId: accountPeerId, peerId: peerId, threadId: Int64(threadMessageId), signal: signal, previous: previous, messageNamespace: Namespaces.Message.Cloud)
|
||||
}
|
||||
|> switchToLatest
|
||||
@@ -673,17 +679,20 @@ private func validateScheduledMessagesBatch(postbox: Postbox, network: Network,
|
||||
let users: [Api.User]
|
||||
|
||||
switch result {
|
||||
case let .messages(messages: apiMessages, topics: apiTopics, chats: apiChats, users: apiUsers):
|
||||
case let .messages(messagesData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (messagesData.messages, messagesData.topics, messagesData.chats, messagesData.users)
|
||||
let _ = apiTopics
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .messagesSlice(_, _, _, _, _, messages: apiMessages, topics: apiTopics, chats: apiChats, users: apiUsers):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (messagesSliceData.messages, messagesSliceData.topics, messagesSliceData.chats, messagesSliceData.users)
|
||||
let _ = apiTopics
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .channelMessages(_, _, _, _, apiMessages, apiTopics, apiChats, apiUsers):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (channelMessagesData.messages, channelMessagesData.topics, channelMessagesData.chats, channelMessagesData.users)
|
||||
messages = apiMessages
|
||||
let _ = apiTopics
|
||||
chats = apiChats
|
||||
@@ -721,17 +730,20 @@ private func validateQuickReplyMessagesBatch(postbox: Postbox, network: Network,
|
||||
let users: [Api.User]
|
||||
|
||||
switch result {
|
||||
case let .messages(messages: apiMessages, topics: apiTopics, chats: apiChats, users: apiUsers):
|
||||
case let .messages(messagesData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (messagesData.messages, messagesData.topics, messagesData.chats, messagesData.users)
|
||||
let _ = apiTopics
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .messagesSlice(_, _, _, _, _, messages: apiMessages, topics: apiTopics, chats: apiChats, users: apiUsers):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (messagesSliceData.messages, messagesSliceData.topics, messagesSliceData.chats, messagesSliceData.users)
|
||||
let _ = apiTopics
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .channelMessages(_, _, _, _, apiMessages, apiTopics, apiChats, apiUsers):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (channelMessagesData.messages, channelMessagesData.topics, channelMessagesData.chats, channelMessagesData.users)
|
||||
messages = apiMessages
|
||||
let _ = apiTopics
|
||||
chats = apiChats
|
||||
@@ -802,16 +814,19 @@ private func validateBatch(postbox: Postbox, network: Network, transaction: Tran
|
||||
case let .channel(peerId, _):
|
||||
actuallyRemovedMessagesSignal = postbox.transaction { transaction -> Signal<Set<MessageId>, NoError> in
|
||||
if let inputChannel = transaction.getPeer(peerId).flatMap(apiInputChannel) {
|
||||
return network.request(Api.functions.channels.getMessages(channel: inputChannel, id: maybeRemovedMessageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) })))
|
||||
return network.request(Api.functions.channels.getMessages(channel: inputChannel, id: maybeRemovedMessageIds.map({ Api.InputMessage.inputMessageID(.init(id: $0.id)) })))
|
||||
|> map { result -> Set<MessageId> in
|
||||
let apiMessages: [Api.Message]
|
||||
switch result {
|
||||
case let .channelMessages(_, _, _, _, messages, apiTopics, _, _):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (messages, apiTopics) = (channelMessagesData.messages, channelMessagesData.topics)
|
||||
apiMessages = messages
|
||||
let _ = apiTopics
|
||||
case let .messages(messages, _, _, _):
|
||||
case let .messages(messagesData):
|
||||
let messages = messagesData.messages
|
||||
apiMessages = messages
|
||||
case let .messagesSlice(_, _, _, _, _, messages, _, _, _):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let messages = messagesSliceData.messages
|
||||
apiMessages = messages
|
||||
case .messagesNotModified:
|
||||
return Set()
|
||||
@@ -1051,16 +1066,19 @@ private func validateReplyThreadBatch(postbox: Postbox, network: Network, transa
|
||||
} else {
|
||||
actuallyRemovedMessagesSignal = postbox.transaction { transaction -> Signal<Set<MessageId>, NoError> in
|
||||
if let inputChannel = transaction.getPeer(peerId).flatMap(apiInputChannel) {
|
||||
return network.request(Api.functions.channels.getMessages(channel: inputChannel, id: maybeRemovedMessageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) })))
|
||||
return network.request(Api.functions.channels.getMessages(channel: inputChannel, id: maybeRemovedMessageIds.map({ Api.InputMessage.inputMessageID(.init(id: $0.id)) })))
|
||||
|> map { result -> Set<MessageId> in
|
||||
let apiMessages: [Api.Message]
|
||||
switch result {
|
||||
case let .channelMessages(_, _, _, _, messages, apiTopics, _, _):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (messages, apiTopics) = (channelMessagesData.messages, channelMessagesData.topics)
|
||||
apiMessages = messages
|
||||
let _ = apiTopics
|
||||
case let .messages(messages, _, _, _):
|
||||
case let .messages(messagesData):
|
||||
let messages = messagesData.messages
|
||||
apiMessages = messages
|
||||
case let .messagesSlice(_, _, _, _, _, messages, _, _, _):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let messages = messagesSliceData.messages
|
||||
apiMessages = messages
|
||||
case .messagesNotModified:
|
||||
return Set()
|
||||
|
||||
@@ -244,21 +244,24 @@ func withResolvedAssociatedMessages<T>(postbox: Postbox, source: FetchMessageHis
|
||||
if let peer = transaction.getPeer(peerId) ?? parsedPeers.get(peerId) {
|
||||
var signal: Signal<Api.messages.Messages, MTRpcError>?
|
||||
if peerId.namespace == Namespaces.Peer.CloudUser || peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
signal = source.request(Api.functions.messages.getMessages(id: messageIds.targetIdsBySourceId.values.map({ Api.InputMessage.inputMessageReplyTo(id: $0.id) })))
|
||||
signal = source.request(Api.functions.messages.getMessages(id: messageIds.targetIdsBySourceId.values.map({ Api.InputMessage.inputMessageReplyTo(.init(id: $0.id)) })))
|
||||
} else if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
if let inputChannel = apiInputChannel(peer) {
|
||||
signal = source.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.targetIdsBySourceId.values.map({ Api.InputMessage.inputMessageReplyTo(id: $0.id) })))
|
||||
signal = source.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.targetIdsBySourceId.values.map({ Api.InputMessage.inputMessageReplyTo(.init(id: $0.id)) })))
|
||||
}
|
||||
}
|
||||
if let signal = signal {
|
||||
signals.append(signal
|
||||
|> map { result in
|
||||
switch result {
|
||||
case let .messages(messages, _, chats, users):
|
||||
case let .messages(messagesData):
|
||||
let (messages, _, chats, users) = (messagesData.messages, messagesData.topics, messagesData.chats, messagesData.users)
|
||||
return (peer, messages, chats, users)
|
||||
case let .messagesSlice(_, _, _, _, _, messages, _, chats, users):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let (messages, chats, users) = (messagesSliceData.messages, messagesSliceData.chats, messagesSliceData.users)
|
||||
return (peer, messages, chats, users)
|
||||
case let .channelMessages(_, _, _, _, messages, apiTopics, chats, users):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (messages, apiTopics, chats, users) = (channelMessagesData.messages, channelMessagesData.topics, channelMessagesData.chats, channelMessagesData.users)
|
||||
let _ = apiTopics
|
||||
return (peer, messages, chats, users)
|
||||
case .messagesNotModified:
|
||||
@@ -275,21 +278,24 @@ func withResolvedAssociatedMessages<T>(postbox: Postbox, source: FetchMessageHis
|
||||
if let peer = transaction.getPeer(peerId) ?? parsedPeers.get(peerId) {
|
||||
var signal: Signal<Api.messages.Messages, MTRpcError>?
|
||||
if peerId.namespace == Namespaces.Peer.CloudUser || peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
signal = source.request(Api.functions.messages.getMessages(id: messageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) })))
|
||||
signal = source.request(Api.functions.messages.getMessages(id: messageIds.map({ Api.InputMessage.inputMessageID(.init(id: $0.id)) })))
|
||||
} else if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
if let inputChannel = apiInputChannel(peer) {
|
||||
signal = source.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) })))
|
||||
signal = source.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map({ Api.InputMessage.inputMessageID(.init(id: $0.id)) })))
|
||||
}
|
||||
}
|
||||
if let signal = signal {
|
||||
signals.append(signal
|
||||
|> map { result in
|
||||
switch result {
|
||||
case let .messages(messages, _, chats, users):
|
||||
case let .messages(messagesData):
|
||||
let (messages, _, chats, users) = (messagesData.messages, messagesData.topics, messagesData.chats, messagesData.users)
|
||||
return (peer, messages, chats, users)
|
||||
case let .messagesSlice(_, _, _, _, _, messages, _, chats, users):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let (messages, chats, users) = (messagesSliceData.messages, messagesSliceData.chats, messagesSliceData.users)
|
||||
return (peer, messages, chats, users)
|
||||
case let .channelMessages(_, _, _, _, messages, apiTopics, chats, users):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (messages, apiTopics, chats, users) = (channelMessagesData.messages, channelMessagesData.topics, channelMessagesData.chats, channelMessagesData.users)
|
||||
let _ = apiTopics
|
||||
return (peer, messages, chats, users)
|
||||
case .messagesNotModified:
|
||||
@@ -919,15 +925,18 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
|
||||
let users: [Api.User]
|
||||
var channelPts: Int32?
|
||||
switch result {
|
||||
case let .messages(messages: apiMessages, _, chats: apiChats, users: apiUsers):
|
||||
case let .messages(messagesData):
|
||||
let (apiMessages, _, apiChats, apiUsers) = (messagesData.messages, messagesData.topics, messagesData.chats, messagesData.users)
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .messagesSlice(_, _, _, _, _, messages: apiMessages, _, chats: apiChats, users: apiUsers):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let (apiMessages, apiChats, apiUsers) = (messagesSliceData.messages, messagesSliceData.chats, messagesSliceData.users)
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .channelMessages(_, pts, _, _, apiMessages, apiTopics, apiChats, apiUsers):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (pts, apiMessages, apiTopics, apiChats, apiUsers) = (channelMessagesData.pts, channelMessagesData.messages, channelMessagesData.topics, channelMessagesData.chats, channelMessagesData.users)
|
||||
messages = apiMessages
|
||||
let _ = apiTopics
|
||||
chats = apiChats
|
||||
@@ -1089,13 +1098,13 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
|
||||
func groupBoundaryPeer(_ peerId: PeerId, accountPeerId: PeerId) -> Api.Peer {
|
||||
switch peerId.namespace {
|
||||
case Namespaces.Peer.CloudUser:
|
||||
return Api.Peer.peerUser(userId: peerId.id._internalGetInt64Value())
|
||||
return Api.Peer.peerUser(.init(userId: peerId.id._internalGetInt64Value()))
|
||||
case Namespaces.Peer.CloudGroup:
|
||||
return Api.Peer.peerChat(chatId: peerId.id._internalGetInt64Value())
|
||||
return Api.Peer.peerChat(.init(chatId: peerId.id._internalGetInt64Value()))
|
||||
case Namespaces.Peer.CloudChannel:
|
||||
return Api.Peer.peerChannel(channelId: peerId.id._internalGetInt64Value())
|
||||
return Api.Peer.peerChannel(.init(channelId: peerId.id._internalGetInt64Value()))
|
||||
default:
|
||||
return Api.Peer.peerUser(userId: accountPeerId.id._internalGetInt64Value())
|
||||
return Api.Peer.peerUser(.init(userId: accountPeerId.id._internalGetInt64Value()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1210,22 +1219,25 @@ func fetchCallListHole(network: Network, postbox: Postbox, accountPeerId: PeerId
|
||||
offset = single((holeIndex.timestamp, min(holeIndex.id.id, Int32.max - 1) + 1, Api.InputPeer.inputPeerEmpty), NoError.self)
|
||||
return offset
|
||||
|> mapToSignal { (timestamp, id, peer) -> Signal<Void, NoError> in
|
||||
let searchResult = network.request(Api.functions.messages.search(flags: 0, peer: .inputPeerEmpty, q: "", fromId: nil, savedPeerId: nil, savedReaction: nil, topMsgId: nil, filter: .inputMessagesFilterPhoneCalls(flags: 0), minDate: 0, maxDate: holeIndex.timestamp, offsetId: 0, addOffset: 0, limit: limit, maxId: holeIndex.id.id, minId: 0, hash: 0))
|
||||
let searchResult = network.request(Api.functions.messages.search(flags: 0, peer: .inputPeerEmpty, q: "", fromId: nil, savedPeerId: nil, savedReaction: nil, topMsgId: nil, filter: .inputMessagesFilterPhoneCalls(.init(flags: 0)), minDate: 0, maxDate: holeIndex.timestamp, offsetId: 0, addOffset: 0, limit: limit, maxId: holeIndex.id.id, minId: 0, hash: 0))
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
let messages: [Api.Message]
|
||||
let chats: [Api.Chat]
|
||||
let users: [Api.User]
|
||||
switch result {
|
||||
case let .messages(messages: apiMessages, _, chats: apiChats, users: apiUsers):
|
||||
case let .messages(messagesData):
|
||||
let (apiMessages, _, apiChats, apiUsers) = (messagesData.messages, messagesData.topics, messagesData.chats, messagesData.users)
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .messagesSlice(_, _, _, _, _, messages: apiMessages, _, chats: apiChats, users: apiUsers):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let (apiMessages, apiChats, apiUsers) = (messagesSliceData.messages, messagesSliceData.chats, messagesSliceData.users)
|
||||
messages = apiMessages
|
||||
chats = apiChats
|
||||
users = apiUsers
|
||||
case let .channelMessages(_, _, _, _, apiMessages, apiTopics, apiChats, apiUsers):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (apiMessages, apiTopics, apiChats, apiUsers) = (channelMessagesData.messages, channelMessagesData.topics, channelMessagesData.chats, channelMessagesData.users)
|
||||
messages = apiMessages
|
||||
let _ = apiTopics
|
||||
chats = apiChats
|
||||
|
||||
@@ -12,7 +12,8 @@ func updateAppConfigurationOnce(postbox: Postbox, network: Network) -> Signal<Vo
|
||||
return network.request(Api.functions.help.getAppConfig(hash: hash))
|
||||
|> map { result -> (data: Api.JSONValue, hash: Int32)? in
|
||||
switch result {
|
||||
case let .appConfig(updatedHash, config):
|
||||
case let .appConfig(appConfigData):
|
||||
let (updatedHash, config) = (appConfigData.hash, appConfigData.config)
|
||||
return (config, updatedHash)
|
||||
case .appConfigNotModified:
|
||||
return nil
|
||||
|
||||
+13
-7
@@ -205,7 +205,8 @@ private func removeMessages(postbox: Postbox, network: Network, stateManager: Ac
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .affectedMessages(pts, ptsCount):
|
||||
case let .affectedMessages(affectedMessagesData):
|
||||
let (pts, ptsCount) = (affectedMessagesData.pts, affectedMessagesData.ptsCount)
|
||||
stateManager.addUpdateGroups([.updateChannelPts(channelId: peer.id.id._internalGetInt64Value(), pts: pts, ptsCount: ptsCount)])
|
||||
}
|
||||
}
|
||||
@@ -240,13 +241,14 @@ private func removeMessages(postbox: Postbox, network: Network, stateManager: Ac
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .affectedMessages(pts, ptsCount):
|
||||
case let .affectedMessages(affectedMessagesData):
|
||||
let (pts, ptsCount) = (affectedMessagesData.pts, affectedMessagesData.ptsCount)
|
||||
stateManager.addUpdateGroups([.updatePts(pts: pts, ptsCount: ptsCount)])
|
||||
}
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
|
||||
|
||||
signal = signal
|
||||
|> then(partSignal)
|
||||
}
|
||||
@@ -396,7 +398,8 @@ private func requestClearHistory(postbox: Postbox, network: Network, stateManage
|
||||
|> mapToSignal { result -> Signal<Void, Bool> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .affectedHistory(pts, ptsCount, offset):
|
||||
case let .affectedHistory(affectedHistoryData):
|
||||
let (pts, ptsCount, offset) = (affectedHistoryData.pts, affectedHistoryData.ptsCount, affectedHistoryData.offset)
|
||||
stateManager.addUpdateGroups([.updatePts(pts: pts, ptsCount: ptsCount)])
|
||||
if offset == 0 {
|
||||
return .fail(true)
|
||||
@@ -463,7 +466,8 @@ private func _internal_clearHistory(transaction: Transaction, postbox: Postbox,
|
||||
|> mapToSignal { result -> Signal<Void, Bool> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .affectedHistory(pts, ptsCount, offset):
|
||||
case let .affectedHistory(affectedHistoryData):
|
||||
let (pts, ptsCount, offset) = (affectedHistoryData.pts, affectedHistoryData.ptsCount, affectedHistoryData.offset)
|
||||
stateManager.addUpdateGroups([.updatePts(pts: pts, ptsCount: ptsCount)])
|
||||
if offset == 0 {
|
||||
return .fail(true)
|
||||
@@ -491,7 +495,8 @@ private func _internal_clearHistory(transaction: Transaction, postbox: Postbox,
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .affectedHistory(pts, ptsCount, _):
|
||||
case let .affectedHistory(affectedHistoryData):
|
||||
let (pts, ptsCount) = (affectedHistoryData.pts, affectedHistoryData.ptsCount)
|
||||
stateManager.addUpdateGroups([.updatePts(pts: pts, ptsCount: ptsCount)])
|
||||
return .complete()
|
||||
}
|
||||
@@ -539,7 +544,8 @@ private func _internal_clearHistory(transaction: Transaction, postbox: Postbox,
|
||||
|> mapToSignal { result -> Signal<Void, Bool> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .affectedHistory(pts, ptsCount, offset):
|
||||
case let .affectedHistory(affectedHistoryData):
|
||||
let (pts, ptsCount, offset) = (affectedHistoryData.pts, affectedHistoryData.ptsCount, affectedHistoryData.offset)
|
||||
stateManager.addUpdateGroups([.updatePts(pts: pts, ptsCount: ptsCount)])
|
||||
if offset == 0 {
|
||||
return .fail(true)
|
||||
|
||||
@@ -14,11 +14,13 @@ func managedConfigurationUpdates(accountManager: AccountManager<TelegramAccountM
|
||||
|> mapToSignal { result, defaultHistoryTtl -> Signal<Void, NoError> in
|
||||
return postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||
switch result {
|
||||
case let .config(flags, _, _, _, _, dcOptions, _, chatSizeMax, megagroupSizeMax, forwardedCountMax, _, _, _, _, _, _, _, _, editTimeLimit, revokeTimeLimit, revokePmTimeLimit, _, stickersRecentLimit, _, _, _, _, _, _, _, autoupdateUrlPrefix, gifSearchUsername, venueSearchUsername, imgSearchUsername, _, _, _, webfileDcId, suggestedLangCode, langPackVersion, baseLangPackVersion, reactionsDefault, autologinToken):
|
||||
case let .config(configData):
|
||||
let (flags, dcOptions, chatSizeMax, megagroupSizeMax, forwardedCountMax, editTimeLimit, revokeTimeLimit, revokePmTimeLimit, stickersRecentLimit, autoupdateUrlPrefix, gifSearchUsername, venueSearchUsername, imgSearchUsername, webfileDcId, suggestedLangCode, langPackVersion, baseLangPackVersion, reactionsDefault, autologinToken) = (configData.flags, configData.dcOptions, configData.chatSizeMax, configData.megagroupSizeMax, configData.forwardedCountMax, configData.editTimeLimit, configData.revokeTimeLimit, configData.revokePmTimeLimit, configData.stickersRecentLimit, configData.autoupdateUrlPrefix, configData.gifSearchUsername, configData.venueSearchUsername, configData.imgSearchUsername, configData.webfileDcId, configData.suggestedLangCode, configData.langPackVersion, configData.baseLangPackVersion, configData.reactionsDefault, configData.autologinToken)
|
||||
var addressList: [Int: [MTDatacenterAddress]] = [:]
|
||||
for option in dcOptions {
|
||||
switch option {
|
||||
case let .dcOption(flags, id, ipAddress, port, secret):
|
||||
case let .dcOption(dcOptionData):
|
||||
let (flags, id, ipAddress, port, secret) = (dcOptionData.flags, dcOptionData.id, dcOptionData.ipAddress, dcOptionData.port, dcOptionData.secret)
|
||||
let preferForMedia = (flags & (1 << 1)) != 0
|
||||
if addressList[Int(id)] == nil {
|
||||
addressList[Int(id)] = []
|
||||
@@ -77,7 +79,8 @@ func managedConfigurationUpdates(accountManager: AccountManager<TelegramAccountM
|
||||
|
||||
let messageAutoremoveSeconds: Int32?
|
||||
switch defaultHistoryTtl {
|
||||
case let .defaultHistoryTTL(period):
|
||||
case let .defaultHistoryTTL(defaultHistoryTTLData):
|
||||
let period = defaultHistoryTTLData.period
|
||||
if period != 0 {
|
||||
messageAutoremoveSeconds = period
|
||||
} else {
|
||||
|
||||
@@ -256,7 +256,8 @@ private func synchronizeConsumeMessageContents(transaction: Transaction, postbox
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .affectedMessages(pts, ptsCount):
|
||||
case let .affectedMessages(affectedMessagesData):
|
||||
let (pts, ptsCount) = (affectedMessagesData.pts, affectedMessagesData.ptsCount)
|
||||
stateManager.addUpdateGroups([.updatePts(pts: pts, ptsCount: ptsCount)])
|
||||
}
|
||||
}
|
||||
@@ -324,7 +325,8 @@ private func synchronizeReadMessageReactions(transaction: Transaction, postbox:
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .affectedMessages(pts, ptsCount):
|
||||
case let .affectedMessages(affectedMessagesData):
|
||||
let (pts, ptsCount) = (affectedMessagesData.pts, affectedMessagesData.ptsCount)
|
||||
stateManager.addUpdateGroups([.updatePts(pts: pts, ptsCount: ptsCount)])
|
||||
}
|
||||
}
|
||||
@@ -386,7 +388,7 @@ private func synchronizeReadMessageReactions(transaction: Transaction, postbox:
|
||||
private func synchronizeUnseenPersonalMentionsTag(postbox: Postbox, network: Network, entry: InvalidatedMessageHistoryTagsSummaryEntry) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||
if let peer = transaction.getPeer(entry.key.peerId), let inputPeer = apiInputPeer(peer) {
|
||||
return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeer(peer: inputPeer)]))
|
||||
return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeer(.init(peer: inputPeer))]))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.messages.PeerDialogs?, NoError> in
|
||||
return .single(nil)
|
||||
@@ -394,20 +396,22 @@ private func synchronizeUnseenPersonalMentionsTag(postbox: Postbox, network: Net
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .peerDialogs(dialogs, _, _, _, _):
|
||||
case let .peerDialogs(peerDialogsData):
|
||||
let dialogs = peerDialogsData.dialogs
|
||||
if let dialog = dialogs.filter({ $0.peerId == entry.key.peerId }).first {
|
||||
let apiTopMessage: Int32
|
||||
let apiUnreadMentionsCount: Int32
|
||||
switch dialog {
|
||||
case let .dialog(_, _, topMessage, _, _, _, unreadMentionsCount, _, _, _, _, _, _):
|
||||
case let .dialog(dialogData):
|
||||
let (topMessage, unreadMentionsCount) = (dialogData.topMessage, dialogData.unreadMentionsCount)
|
||||
apiTopMessage = topMessage
|
||||
apiUnreadMentionsCount = unreadMentionsCount
|
||||
|
||||
|
||||
case .dialogFolder:
|
||||
assertionFailure()
|
||||
return .complete()
|
||||
}
|
||||
|
||||
|
||||
return postbox.transaction { transaction -> Void in
|
||||
transaction.replaceMessageTagSummary(peerId: entry.key.peerId, threadId: nil, tagMask: entry.key.tagMask, namespace: entry.key.namespace, customTag: nil, count: apiUnreadMentionsCount, maxId: apiTopMessage)
|
||||
}
|
||||
@@ -428,7 +432,7 @@ private func synchronizeUnseenPersonalMentionsTag(postbox: Postbox, network: Net
|
||||
private func synchronizeUnseenReactionsTag(postbox: Postbox, network: Network, entry: InvalidatedMessageHistoryTagsSummaryEntry) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||
if let peer = transaction.getPeer(entry.key.peerId), let inputPeer = apiInputPeer(peer) {
|
||||
return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeer(peer: inputPeer)]))
|
||||
return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeer(.init(peer: inputPeer))]))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.messages.PeerDialogs?, NoError> in
|
||||
return .single(nil)
|
||||
@@ -436,20 +440,22 @@ private func synchronizeUnseenReactionsTag(postbox: Postbox, network: Network, e
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .peerDialogs(dialogs, _, _, _, _):
|
||||
case let .peerDialogs(peerDialogsData):
|
||||
let dialogs = peerDialogsData.dialogs
|
||||
if let dialog = dialogs.filter({ $0.peerId == entry.key.peerId }).first {
|
||||
let apiTopMessage: Int32
|
||||
let apiUnreadReactionsCount: Int32
|
||||
switch dialog {
|
||||
case let .dialog(_, _, topMessage, _, _, _, _, unreadReactionsCount, _, _, _, _, _):
|
||||
case let .dialog(dialogData):
|
||||
let (topMessage, unreadReactionsCount) = (dialogData.topMessage, dialogData.unreadReactionsCount)
|
||||
apiTopMessage = topMessage
|
||||
apiUnreadReactionsCount = unreadReactionsCount
|
||||
|
||||
|
||||
case .dialogFolder:
|
||||
assertionFailure()
|
||||
return .complete()
|
||||
}
|
||||
|
||||
|
||||
return postbox.transaction { transaction -> Void in
|
||||
transaction.replaceMessageTagSummary(peerId: entry.key.peerId, threadId: nil, tagMask: entry.key.tagMask, namespace: entry.key.namespace, customTag: nil, count: apiUnreadReactionsCount, maxId: apiTopMessage)
|
||||
}
|
||||
@@ -546,7 +552,8 @@ private func synchronizeMessageHistoryTagSummary(accountPeerId: PeerId, postbox:
|
||||
}
|
||||
return postbox.transaction { transaction -> Void in
|
||||
switch result {
|
||||
case let .channelMessages(_, _, count, _, messages, _, _, _):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (count, messages) = (channelMessagesData.count, channelMessagesData.messages)
|
||||
let topId: Int32 = messages.first?.id(namespace: Namespaces.Message.Cloud)?.id ?? 1
|
||||
transaction.replaceMessageTagSummary(peerId: entry.key.peerId, threadId: threadId, tagMask: entry.key.tagMask, namespace: entry.key.namespace, customTag: nil, count: count, maxId: topId)
|
||||
default:
|
||||
@@ -574,16 +581,20 @@ private func synchronizeMessageHistoryTagSummary(accountPeerId: PeerId, postbox:
|
||||
let apiMessages: [Api.Message]
|
||||
let apiCount: Int32
|
||||
switch result {
|
||||
case let .channelMessages(_, _, count, _, messages, _, _, _):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let (count, messages) = (channelMessagesData.count, channelMessagesData.messages)
|
||||
apiMessages = messages
|
||||
apiCount = count
|
||||
case let .messages(messages, _, _, _):
|
||||
case let .messages(messagesData):
|
||||
let messages = messagesData.messages
|
||||
apiMessages = messages
|
||||
apiCount = Int32(messages.count)
|
||||
case let .messagesNotModified(count):
|
||||
case let .messagesNotModified(messagesNotModifiedData):
|
||||
let count = messagesNotModifiedData.count
|
||||
apiMessages = []
|
||||
apiCount = count
|
||||
case let .messagesSlice(_, count, _, _, _, messages, _, _, _):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let (count, messages) = (messagesSliceData.count, messagesSliceData.messages)
|
||||
apiMessages = messages
|
||||
apiCount = count
|
||||
}
|
||||
@@ -731,12 +742,14 @@ func synchronizeSavedMessageTags(postbox: Postbox, network: Network, peerId: Pee
|
||||
transaction.setPreferencesEntry(key: PreferencesKeys.didCacheSavedMessageTags(threadId: threadId), value: PreferencesEntry(data: Data()))
|
||||
}
|
||||
|> ignoreValues
|
||||
case let .savedReactionTags(tags, _):
|
||||
case let .savedReactionTags(savedReactionTagsData):
|
||||
let tags = savedReactionTagsData.tags
|
||||
var customFileIds: [Int64] = []
|
||||
var parsedTags: [SavedMessageTags.Tag] = []
|
||||
for tag in tags {
|
||||
switch tag {
|
||||
case let .savedReactionTag(_, reaction, title, count):
|
||||
case let .savedReactionTag(savedReactionTagData):
|
||||
let (reaction, title, count) = (savedReactionTagData.reaction, savedReactionTagData.title, savedReactionTagData.count)
|
||||
guard let reaction = MessageReaction.Reaction(apiReaction: reaction) else {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@ public enum EmojiGameInfo: Codable, Equatable {
|
||||
extension EmojiGameInfo {
|
||||
init(apiEmojiGameInfo: Api.messages.EmojiGameInfo) {
|
||||
switch apiEmojiGameInfo {
|
||||
case let .emojiGameDiceInfo(_, gameHash, prevStake, currentStreak, params, playsLeft):
|
||||
case let .emojiGameDiceInfo(emojiGameDiceInfoData):
|
||||
let (gameHash, prevStake, currentStreak, params, playsLeft) = (emojiGameDiceInfoData.gameHash, emojiGameDiceInfoData.prevStake, emojiGameDiceInfoData.currentStreak, emojiGameDiceInfoData.params, emojiGameDiceInfoData.playsLeft)
|
||||
self = .available(Info(gameHash: gameHash, previousStake: prevStake, currentStreak: currentStreak, parameters: params, playsLeft: playsLeft))
|
||||
case .emojiGameUnavailable:
|
||||
self = .unavailable
|
||||
|
||||
@@ -120,7 +120,8 @@ private func fetchedNotificationSettings(network: Network) -> Signal<GlobalNotif
|
||||
}
|
||||
let chatsSettings: MessageNotificationSettings
|
||||
switch chats {
|
||||
case let .peerNotifySettings(_, showPreviews, _, muteUntil, iosSound, _, desktopSound, storiesMuted, storiesHideSender, storiesIosSound, _, storiesDesktopSound):
|
||||
case let .peerNotifySettings(peerNotifySettingsData):
|
||||
let (_, showPreviews, _, muteUntil, iosSound, _, desktopSound, storiesMuted, storiesHideSender, storiesIosSound, _, storiesDesktopSound) = (peerNotifySettingsData.flags, peerNotifySettingsData.showPreviews, peerNotifySettingsData.silent, peerNotifySettingsData.muteUntil, peerNotifySettingsData.iosSound, peerNotifySettingsData.androidSound, peerNotifySettingsData.otherSound, peerNotifySettingsData.storiesMuted, peerNotifySettingsData.storiesHideSender, peerNotifySettingsData.storiesIosSound, peerNotifySettingsData.storiesAndroidSound, peerNotifySettingsData.storiesOtherSound)
|
||||
let sound: Api.NotificationSound?
|
||||
let storiesSound: Api.NotificationSound?
|
||||
#if os(iOS)
|
||||
@@ -130,7 +131,7 @@ private func fetchedNotificationSettings(network: Network) -> Signal<GlobalNotif
|
||||
sound = desktopSound
|
||||
storiesSound = storiesDesktopSound
|
||||
#endif
|
||||
|
||||
|
||||
let enabled: Bool
|
||||
if muteUntil != nil && muteUntil != 0 {
|
||||
enabled = false
|
||||
@@ -143,21 +144,21 @@ private func fetchedNotificationSettings(network: Network) -> Signal<GlobalNotif
|
||||
} else {
|
||||
displayPreviews = true
|
||||
}
|
||||
|
||||
|
||||
let storiesMutedValue: PeerStoryNotificationSettings.Mute
|
||||
if let storiesMuted = storiesMuted {
|
||||
storiesMutedValue = storiesMuted == .boolTrue ? .muted : .unmuted
|
||||
} else {
|
||||
storiesMutedValue = .default
|
||||
}
|
||||
|
||||
|
||||
var storiesHideSenderValue: PeerStoryNotificationSettings.HideSender
|
||||
if let storiesHideSender = storiesHideSender {
|
||||
storiesHideSenderValue = storiesHideSender == .boolTrue ? .hide : .show
|
||||
} else {
|
||||
storiesHideSenderValue = .default
|
||||
}
|
||||
|
||||
|
||||
chatsSettings = MessageNotificationSettings(
|
||||
enabled: enabled,
|
||||
displayPreviews: displayPreviews,
|
||||
@@ -172,7 +173,8 @@ private func fetchedNotificationSettings(network: Network) -> Signal<GlobalNotif
|
||||
|
||||
let userSettings: MessageNotificationSettings
|
||||
switch users {
|
||||
case let .peerNotifySettings(_, showPreviews, _, muteUntil, iosSound, _, desktopSound, storiesMuted, storiesHideSender, storiesIosSound, _, storiesDesktopSound):
|
||||
case let .peerNotifySettings(peerNotifySettingsData):
|
||||
let (_, showPreviews, _, muteUntil, iosSound, _, desktopSound, storiesMuted, storiesHideSender, storiesIosSound, _, storiesDesktopSound) = (peerNotifySettingsData.flags, peerNotifySettingsData.showPreviews, peerNotifySettingsData.silent, peerNotifySettingsData.muteUntil, peerNotifySettingsData.iosSound, peerNotifySettingsData.androidSound, peerNotifySettingsData.otherSound, peerNotifySettingsData.storiesMuted, peerNotifySettingsData.storiesHideSender, peerNotifySettingsData.storiesIosSound, peerNotifySettingsData.storiesAndroidSound, peerNotifySettingsData.storiesOtherSound)
|
||||
let sound: Api.NotificationSound?
|
||||
let storiesSound: Api.NotificationSound?
|
||||
#if os(iOS)
|
||||
@@ -182,7 +184,7 @@ private func fetchedNotificationSettings(network: Network) -> Signal<GlobalNotif
|
||||
sound = desktopSound
|
||||
storiesSound = storiesDesktopSound
|
||||
#endif
|
||||
|
||||
|
||||
let enabled: Bool
|
||||
if muteUntil != nil && muteUntil != 0 {
|
||||
enabled = false
|
||||
@@ -195,21 +197,21 @@ private func fetchedNotificationSettings(network: Network) -> Signal<GlobalNotif
|
||||
} else {
|
||||
displayPreviews = true
|
||||
}
|
||||
|
||||
|
||||
let storiesMutedValue: PeerStoryNotificationSettings.Mute
|
||||
if let storiesMuted = storiesMuted {
|
||||
storiesMutedValue = storiesMuted == .boolTrue ? .muted : .unmuted
|
||||
} else {
|
||||
storiesMutedValue = .default
|
||||
}
|
||||
|
||||
|
||||
var storiesHideSenderValue: PeerStoryNotificationSettings.HideSender
|
||||
if let storiesHideSender = storiesHideSender {
|
||||
storiesHideSenderValue = storiesHideSender == .boolTrue ? .hide : .show
|
||||
} else {
|
||||
storiesHideSenderValue = .default
|
||||
}
|
||||
|
||||
|
||||
userSettings = MessageNotificationSettings(
|
||||
enabled: enabled,
|
||||
displayPreviews: displayPreviews,
|
||||
@@ -224,7 +226,8 @@ private func fetchedNotificationSettings(network: Network) -> Signal<GlobalNotif
|
||||
|
||||
let channelSettings: MessageNotificationSettings
|
||||
switch channels {
|
||||
case let .peerNotifySettings(_, showPreviews, _, muteUntil, iosSound, _, desktopSound, storiesMuted, storiesHideSender, storiesIosSound, _, storiesDesktopSound):
|
||||
case let .peerNotifySettings(peerNotifySettingsData):
|
||||
let (_, showPreviews, _, muteUntil, iosSound, _, desktopSound, storiesMuted, storiesHideSender, storiesIosSound, _, storiesDesktopSound) = (peerNotifySettingsData.flags, peerNotifySettingsData.showPreviews, peerNotifySettingsData.silent, peerNotifySettingsData.muteUntil, peerNotifySettingsData.iosSound, peerNotifySettingsData.androidSound, peerNotifySettingsData.otherSound, peerNotifySettingsData.storiesMuted, peerNotifySettingsData.storiesHideSender, peerNotifySettingsData.storiesIosSound, peerNotifySettingsData.storiesAndroidSound, peerNotifySettingsData.storiesOtherSound)
|
||||
let sound: Api.NotificationSound?
|
||||
let storiesSound: Api.NotificationSound?
|
||||
#if os(iOS)
|
||||
@@ -234,7 +237,7 @@ private func fetchedNotificationSettings(network: Network) -> Signal<GlobalNotif
|
||||
sound = desktopSound
|
||||
storiesSound = storiesDesktopSound
|
||||
#endif
|
||||
|
||||
|
||||
let enabled: Bool
|
||||
if muteUntil != nil && muteUntil != 0 {
|
||||
enabled = false
|
||||
@@ -247,21 +250,21 @@ private func fetchedNotificationSettings(network: Network) -> Signal<GlobalNotif
|
||||
} else {
|
||||
displayPreviews = true
|
||||
}
|
||||
|
||||
|
||||
let storiesMutedValue: PeerStoryNotificationSettings.Mute
|
||||
if let storiesMuted = storiesMuted {
|
||||
storiesMutedValue = storiesMuted == .boolTrue ? .muted : .unmuted
|
||||
} else {
|
||||
storiesMutedValue = .default
|
||||
}
|
||||
|
||||
|
||||
var storiesHideSenderValue: PeerStoryNotificationSettings.HideSender
|
||||
if let storiesHideSender = storiesHideSender {
|
||||
storiesHideSenderValue = storiesHideSender == .boolTrue ? .hide : .show
|
||||
} else {
|
||||
storiesHideSenderValue = .default
|
||||
}
|
||||
|
||||
|
||||
channelSettings = MessageNotificationSettings(
|
||||
enabled: enabled,
|
||||
displayPreviews: displayPreviews,
|
||||
@@ -276,7 +279,8 @@ private func fetchedNotificationSettings(network: Network) -> Signal<GlobalNotif
|
||||
|
||||
let reactionSettings: PeerReactionNotificationSettings
|
||||
switch reactions {
|
||||
case let .reactionsNotifySettings(_, messagesNotifyFrom, storiesNotifyFrom, sound, showPreviews):
|
||||
case let .reactionsNotifySettings(reactionsNotifySettingsData):
|
||||
let (_, messagesNotifyFrom, storiesNotifyFrom, sound, showPreviews) = (reactionsNotifySettingsData.flags, reactionsNotifySettingsData.messagesNotifyFrom, reactionsNotifySettingsData.storiesNotifyFrom, reactionsNotifySettingsData.sound, reactionsNotifySettingsData.showPreviews)
|
||||
let mappedMessages: PeerReactionNotificationSettings.Sources
|
||||
if let messagesNotifyFrom {
|
||||
switch messagesNotifyFrom {
|
||||
@@ -361,7 +365,7 @@ private func apiInputPeerNotifySettings(_ settings: MessageNotificationSettings)
|
||||
flags |= (1 << 8)
|
||||
}
|
||||
|
||||
return .inputPeerNotifySettings(flags: flags, showPreviews: settings.displayPreviews ? .boolTrue : .boolFalse, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted, storiesHideSender: storiesHideSender, storiesSound: storiesSound)
|
||||
return .inputPeerNotifySettings(.init(flags: flags, showPreviews: settings.displayPreviews ? .boolTrue : .boolFalse, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted, storiesHideSender: storiesHideSender, storiesSound: storiesSound))
|
||||
}
|
||||
|
||||
private func pushedNotificationSettings(network: Network, settings: GlobalNotificationSettingsSet) -> Signal<Void, NoError> {
|
||||
@@ -413,13 +417,13 @@ private func pushedNotificationSettings(network: Network, settings: GlobalNotifi
|
||||
reactionFlags |= 1 << 1
|
||||
}
|
||||
|
||||
let inputReactionSettings: Api.ReactionsNotifySettings = .reactionsNotifySettings(
|
||||
let inputReactionSettings: Api.ReactionsNotifySettings = .reactionsNotifySettings(.init(
|
||||
flags: reactionFlags,
|
||||
messagesNotifyFrom: reactionsMessages,
|
||||
storiesNotifyFrom: reactionsStories,
|
||||
sound: settings.reactionSettings.sound.apiSound,
|
||||
showPreviews: settings.reactionSettings.hideSender == .hide ? .boolFalse : .boolTrue
|
||||
)
|
||||
))
|
||||
let pushedReactions = network.request(Api.functions.account.setReactionsNotifySettings(settings: inputReactionSettings))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.ReactionsNotifySettings?, NoError> in
|
||||
|
||||
@@ -118,23 +118,23 @@ private func actionFromActivity(_ activity: PeerInputActivity?) -> Api.SendMessa
|
||||
case .playingGame:
|
||||
return .sendMessageGamePlayAction
|
||||
case let .uploadingFile(progress):
|
||||
return .sendMessageUploadDocumentAction(progress: progress)
|
||||
return .sendMessageUploadDocumentAction(.init(progress: progress))
|
||||
case let .uploadingPhoto(progress):
|
||||
return .sendMessageUploadPhotoAction(progress: progress)
|
||||
return .sendMessageUploadPhotoAction(.init(progress: progress))
|
||||
case let .uploadingVideo(progress):
|
||||
return .sendMessageUploadVideoAction(progress: progress)
|
||||
return .sendMessageUploadVideoAction(.init(progress: progress))
|
||||
case .recordingInstantVideo:
|
||||
return .sendMessageRecordRoundAction
|
||||
case let .uploadingInstantVideo(progress):
|
||||
return .sendMessageUploadRoundAction(progress: progress)
|
||||
return .sendMessageUploadRoundAction(.init(progress: progress))
|
||||
case .speakingInGroupCall:
|
||||
return .speakingInGroupCallAction
|
||||
case .choosingSticker:
|
||||
return .sendMessageChooseStickerAction
|
||||
case let .interactingWithEmoji(emoticon, messageId, interaction):
|
||||
return .sendMessageEmojiInteraction(emoticon: emoticon, msgId: messageId.id, interaction: interaction?.apiDataJson ?? .dataJSON(data: ""))
|
||||
return .sendMessageEmojiInteraction(.init(emoticon: emoticon, msgId: messageId.id, interaction: interaction?.apiDataJson ?? .dataJSON(.init(data: ""))))
|
||||
case let .seeingEmojiInteraction(emoticon):
|
||||
return .sendMessageEmojiInteractionSeen(emoticon: emoticon)
|
||||
return .sendMessageEmojiInteractionSeen(.init(emoticon: emoticon))
|
||||
}
|
||||
} else {
|
||||
return .sendMessageCancelAction
|
||||
@@ -142,7 +142,7 @@ private func actionFromActivity(_ activity: PeerInputActivity?) -> Api.SendMessa
|
||||
}
|
||||
|
||||
private func requestActivity(postbox: Postbox, network: Network, accountPeerId: PeerId, peerId: PeerId, threadId: Int64?, activity: PeerInputActivity?) -> Signal<Void, NoError> {
|
||||
// GHOST MODE: Block typing indicator
|
||||
// GHOST MODE: Block typing indicator updates.
|
||||
if GhostModeManager.shared.shouldHideTypingIndicator {
|
||||
return .complete()
|
||||
}
|
||||
@@ -195,7 +195,7 @@ private func requestActivity(postbox: Postbox, network: Network, accountPeerId:
|
||||
}
|
||||
} else if let peer = peer as? TelegramSecretChat, activity == .typingText {
|
||||
let _ = PeerId(peer.id.toInt64())
|
||||
return network.request(Api.functions.messages.setEncryptedTyping(peer: .inputEncryptedChat(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: peer.accessHash), typing: .boolTrue))
|
||||
return network.request(Api.functions.messages.setEncryptedTyping(peer: .inputEncryptedChat(.init(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: peer.accessHash)), typing: .boolTrue))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
||||
}
|
||||
|
||||
@@ -132,15 +132,19 @@ func getLocalization(_ transaction: AccountManagerModifier<TelegramAccountManage
|
||||
|
||||
private func parseLangPackDifference(_ difference: Api.LangPackDifference) -> (code: String, fromVersion: Int32, version: Int32, entries: [LocalizationEntry]) {
|
||||
switch difference {
|
||||
case let .langPackDifference(code, fromVersion, version, strings):
|
||||
case let .langPackDifference(langPackDifferenceData):
|
||||
let (code, fromVersion, version, strings) = (langPackDifferenceData.langCode, langPackDifferenceData.fromVersion, langPackDifferenceData.version, langPackDifferenceData.strings)
|
||||
var entries: [LocalizationEntry] = []
|
||||
for string in strings {
|
||||
switch string {
|
||||
case let .langPackString(key, value):
|
||||
case let .langPackString(langPackStringData):
|
||||
let (key, value) = (langPackStringData.key, langPackStringData.value)
|
||||
entries.append(.string(key: key, value: value))
|
||||
case let .langPackStringPluralized(_, key, zeroValue, oneValue, twoValue, fewValue, manyValue, otherValue):
|
||||
case let .langPackStringPluralized(langPackStringPluralizedData):
|
||||
let (key, zeroValue, oneValue, twoValue, fewValue, manyValue, otherValue) = (langPackStringPluralizedData.key, langPackStringPluralizedData.zeroValue, langPackStringPluralizedData.oneValue, langPackStringPluralizedData.twoValue, langPackStringPluralizedData.fewValue, langPackStringPluralizedData.manyValue, langPackStringPluralizedData.otherValue)
|
||||
entries.append(.pluralizedString(key: key, zero: zeroValue, one: oneValue, two: twoValue, few: fewValue, many: manyValue, other: otherValue))
|
||||
case let .langPackStringDeleted(key):
|
||||
case let .langPackStringDeleted(langPackStringDeletedData):
|
||||
let key = langPackStringDeletedData.key
|
||||
entries.append(.string(key: key, value: ""))
|
||||
}
|
||||
}
|
||||
@@ -242,7 +246,8 @@ private func synchronizeLocalizationUpdates(accountManager: AccountManager<Teleg
|
||||
func tryApplyingLanguageDifference(transaction: AccountManagerModifier<TelegramAccountManagerTypes>, langCode: String, difference: Api.LangPackDifference) -> Bool {
|
||||
let (primary, secondary) = getLocalization(transaction)
|
||||
switch difference {
|
||||
case let .langPackDifference(updatedCode, fromVersion, updatedVersion, strings):
|
||||
case let .langPackDifference(langPackDifferenceData):
|
||||
let (updatedCode, fromVersion, updatedVersion, strings) = (langPackDifferenceData.langCode, langPackDifferenceData.fromVersion, langPackDifferenceData.version, langPackDifferenceData.strings)
|
||||
var current: (isPrimary: Bool, version: Int32, entries: [LocalizationEntry])?
|
||||
if updatedCode == primary.code {
|
||||
current = (true, primary.version, primary.entries)
|
||||
@@ -259,11 +264,14 @@ func tryApplyingLanguageDifference(transaction: AccountManagerModifier<TelegramA
|
||||
|
||||
for string in strings {
|
||||
switch string {
|
||||
case let .langPackString(key, value):
|
||||
case let .langPackString(langPackStringData):
|
||||
let (key, value) = (langPackStringData.key, langPackStringData.value)
|
||||
updatedEntries.append(.string(key: key, value: value))
|
||||
case let .langPackStringPluralized(_, key, zeroValue, oneValue, twoValue, fewValue, manyValue, otherValue):
|
||||
case let .langPackStringPluralized(langPackStringPluralizedData):
|
||||
let (key, zeroValue, oneValue, twoValue, fewValue, manyValue, otherValue) = (langPackStringPluralizedData.key, langPackStringPluralizedData.zeroValue, langPackStringPluralizedData.oneValue, langPackStringPluralizedData.twoValue, langPackStringPluralizedData.fewValue, langPackStringPluralizedData.manyValue, langPackStringPluralizedData.otherValue)
|
||||
updatedEntries.append(.pluralizedString(key: key, zero: zeroValue, one: oneValue, two: twoValue, few: fewValue, many: manyValue, other: otherValue))
|
||||
case let .langPackStringDeleted(key):
|
||||
case let .langPackStringDeleted(langPackStringDeletedData):
|
||||
let key = langPackStringDeletedData.key
|
||||
updatedEntries.append(.string(key: key, value: ""))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,14 +244,16 @@ private extension EngineAvailableColorOptions.ColorOption {
|
||||
let stories: EngineAvailableColorOptions.MultiColorPack?
|
||||
|
||||
switch apiColors {
|
||||
case let .peerColorSet(colors):
|
||||
case let .peerColorSet(peerColorSetData):
|
||||
let colors = peerColorSetData.colors
|
||||
if colors.isEmpty {
|
||||
return nil
|
||||
}
|
||||
palette = EngineAvailableColorOptions.MultiColorPack(colors: colors.map(UInt32.init(bitPattern:)))
|
||||
background = palette
|
||||
stories = nil
|
||||
case let .peerColorProfileSet(palleteColors, bgColors, storyColors):
|
||||
case let .peerColorProfileSet(peerColorProfileSetData):
|
||||
let (palleteColors, bgColors, storyColors) = (peerColorProfileSetData.paletteColors, peerColorProfileSetData.bgColors, peerColorProfileSetData.storyColors)
|
||||
if palleteColors.isEmpty {
|
||||
return nil
|
||||
}
|
||||
@@ -278,7 +280,8 @@ private extension EngineAvailableColorOptions {
|
||||
var mappedOptions: [Option] = []
|
||||
for apiColor in apiColors {
|
||||
switch apiColor {
|
||||
case let .peerColorOption(flags, colorId, colors, darkColors, requiredChannelMinBoostLevel, requiredGroupMinBoostLevel):
|
||||
case let .peerColorOption(peerColorOptionData):
|
||||
let (flags, colorId, colors, darkColors, requiredChannelMinBoostLevel, requiredGroupMinBoostLevel) = (peerColorOptionData.flags, peerColorOptionData.colorId, peerColorOptionData.colors, peerColorOptionData.darkColors, peerColorOptionData.channelMinLevel, peerColorOptionData.groupMinLevel)
|
||||
let isHidden = (flags & (1 << 0)) != 0
|
||||
|
||||
let mappedColors = colors.flatMap(EngineAvailableColorOptions.ColorOption.init(apiColors:))
|
||||
@@ -348,7 +351,8 @@ private func _internal_fetchPeerColors(postbox: Postbox, network: Network, scope
|
||||
switch result {
|
||||
case .peerColorsNotModified:
|
||||
return .complete()
|
||||
case let .peerColors(hash, colors):
|
||||
case let .peerColors(peerColorsData):
|
||||
let (hash, colors) = (peerColorsData.hash, peerColorsData.colors)
|
||||
return postbox.transaction { transaction -> Void in
|
||||
let value = EngineAvailableColorOptions(hash: hash, apiColors: colors)
|
||||
_internal_setCachedAvailableColorOptions(transaction: transaction, scope: scope, value: value)
|
||||
|
||||
@@ -162,8 +162,8 @@ func pushPeerNotificationSettings(postbox: Postbox, network: Network, peerId: Pe
|
||||
flags |= (1 << 8)
|
||||
}
|
||||
|
||||
let inputSettings = Api.InputPeerNotifySettings.inputPeerNotifySettings(flags: flags, showPreviews: showPreviews, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted, storiesHideSender: storiesHideSender, storiesSound: storiesSound)
|
||||
return network.request(Api.functions.account.updateNotifySettings(peer: .inputNotifyForumTopic(peer: inputPeer, topMsgId: Int32(clamping: threadId)), settings: inputSettings))
|
||||
let inputSettings = Api.InputPeerNotifySettings.inputPeerNotifySettings(.init(flags: flags, showPreviews: showPreviews, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted, storiesHideSender: storiesHideSender, storiesSound: storiesSound))
|
||||
return network.request(Api.functions.account.updateNotifySettings(peer: .inputNotifyForumTopic(.init(peer: inputPeer, topMsgId: Int32(clamping: threadId))), settings: inputSettings))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
||||
}
|
||||
@@ -237,8 +237,8 @@ func pushPeerNotificationSettings(postbox: Postbox, network: Network, peerId: Pe
|
||||
flags |= (1 << 8)
|
||||
}
|
||||
|
||||
let inputSettings = Api.InputPeerNotifySettings.inputPeerNotifySettings(flags: flags, showPreviews: showPreviews, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted, storiesHideSender: storiesHideSender, storiesSound: storiesSound)
|
||||
return network.request(Api.functions.account.updateNotifySettings(peer: .inputNotifyPeer(peer: inputPeer), settings: inputSettings))
|
||||
let inputSettings = Api.InputPeerNotifySettings.inputPeerNotifySettings(.init(flags: flags, showPreviews: showPreviews, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted, storiesHideSender: storiesHideSender, storiesSound: storiesSound))
|
||||
return network.request(Api.functions.account.updateNotifySettings(peer: .inputNotifyPeer(.init(peer: inputPeer)), settings: inputSettings))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ func updatePremiumPromoConfigurationOnce(accountPeerId: PeerId, postbox: Postbox
|
||||
return .complete()
|
||||
}
|
||||
return postbox.transaction { transaction -> Void in
|
||||
if case let .premiumPromo(_, _, _, _, _, apiUsers) = result {
|
||||
if case let .premiumPromo(premiumPromoData) = result {
|
||||
let apiUsers = premiumPromoData.users
|
||||
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: [], users: apiUsers)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
}
|
||||
@@ -59,7 +60,8 @@ private func updatePremiumPromoConfiguration(transaction: Transaction, _ f: (Pre
|
||||
private extension PremiumPromoConfiguration {
|
||||
init(apiPremiumPromo: Api.help.PremiumPromo) {
|
||||
switch apiPremiumPromo {
|
||||
case let .premiumPromo(statusText, statusEntities, videoSections, videoFiles, options, _):
|
||||
case let .premiumPromo(premiumPromoData):
|
||||
let (statusText, statusEntities, videoSections, videoFiles, options) = (premiumPromoData.statusText, premiumPromoData.statusEntities, premiumPromoData.videoSections, premiumPromoData.videos, premiumPromoData.periodOptions)
|
||||
self.status = statusText
|
||||
self.statusEntities = messageTextEntitiesFromApiEntities(statusEntities)
|
||||
|
||||
@@ -73,7 +75,8 @@ private extension PremiumPromoConfiguration {
|
||||
|
||||
var productOptions: [PremiumProductOption] = []
|
||||
for option in options {
|
||||
if case let .premiumSubscriptionOption(flags, transaction, months, currency, amount, botUrl, storeProduct) = option {
|
||||
if case let .premiumSubscriptionOption(premiumSubscriptionOptionData) = option {
|
||||
let (flags, transaction, months, currency, amount, botUrl, storeProduct) = (premiumSubscriptionOptionData.flags, premiumSubscriptionOptionData.transaction, premiumSubscriptionOptionData.months, premiumSubscriptionOptionData.currency, premiumSubscriptionOptionData.amount, premiumSubscriptionOptionData.botUrl, premiumSubscriptionOptionData.storeProduct)
|
||||
productOptions.append(PremiumProductOption(isCurrent: (flags & (1 << 1)) != 0, months: months, currency: currency, amount: amount, botUrl: botUrl, transactionId: transaction, availableForUpgrade: (flags & (1 << 2)) != 0, storeProductId: storeProduct))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,8 @@ public final class ServerSuggestionInfo: Codable, Equatable {
|
||||
extension ServerSuggestionInfo.Item.Text {
|
||||
convenience init(_ apiText: Api.TextWithEntities) {
|
||||
switch apiText {
|
||||
case let .textWithEntities(text, entities):
|
||||
case let .textWithEntities(textWithEntitiesData):
|
||||
let (text, entities) = (textWithEntitiesData.text, textWithEntitiesData.entities)
|
||||
self.init(string: text, entities: messageTextEntitiesFromApiEntities(entities))
|
||||
}
|
||||
}
|
||||
@@ -175,7 +176,8 @@ extension ServerSuggestionInfo.Item.Text {
|
||||
extension ServerSuggestionInfo.Item {
|
||||
convenience init(_ apiItem: Api.PendingSuggestion) {
|
||||
switch apiItem {
|
||||
case let .pendingSuggestion(suggestion, title, description, url):
|
||||
case let .pendingSuggestion(pendingSuggestionData):
|
||||
let (suggestion, title, description, url) = (pendingSuggestionData.suggestion, pendingSuggestionData.title, pendingSuggestionData.description, pendingSuggestionData.url)
|
||||
self.init(
|
||||
id: suggestion,
|
||||
title: ServerSuggestionInfo.Item.Text(title),
|
||||
@@ -189,12 +191,12 @@ extension ServerSuggestionInfo.Item {
|
||||
func _internal_fetchPromoInfo(accountPeerId: EnginePeer.Id, postbox: Postbox, network: Network) -> Signal<Void, NoError> {
|
||||
return network.request(Api.functions.help.getPromoData())
|
||||
|> `catch` { _ -> Signal<Api.help.PromoData, NoError> in
|
||||
return .single(.promoDataEmpty(expires: 10 * 60))
|
||||
return .single(.promoDataEmpty(.init(expires: 10 * 60)))
|
||||
}
|
||||
|> mapToSignal { data -> Signal<Void, NoError> in
|
||||
return postbox.transaction { transaction -> Void in
|
||||
switch data {
|
||||
case .promoDataEmpty:
|
||||
case .promoDataEmpty(_):
|
||||
transaction.replaceAdditionalChatListItems([])
|
||||
|
||||
let suggestionInfo = ServerSuggestionInfo(
|
||||
@@ -206,7 +208,8 @@ func _internal_fetchPromoInfo(accountPeerId: EnginePeer.Id, postbox: Postbox, ne
|
||||
transaction.updatePreferencesEntry(key: PreferencesKeys.serverSuggestionInfo(), { _ in
|
||||
return PreferencesEntry(suggestionInfo)
|
||||
})
|
||||
case let .promoData(flags, expires, peer, psaType, psaMessage, pendingSuggestions, dismissedSuggestions, customPendingSuggestion, chats, users):
|
||||
case let .promoData(promoDataData):
|
||||
let (flags, expires, peer, psaType, psaMessage, pendingSuggestions, dismissedSuggestions, customPendingSuggestion, chats, users) = (promoDataData.flags, promoDataData.expires, promoDataData.peer, promoDataData.psaType, promoDataData.psaMessage, promoDataData.pendingSuggestions, promoDataData.dismissedSuggestions, promoDataData.customPendingSuggestion, promoDataData.chats, promoDataData.users)
|
||||
let _ = expires
|
||||
|
||||
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
|
||||
|
||||
@@ -53,7 +53,8 @@ func managedRecentStickers(postbox: Postbox, network: Network, forceFetch: Bool
|
||||
switch result {
|
||||
case .recentStickersNotModified:
|
||||
return .single(nil)
|
||||
case let .recentStickers(_, _, stickers, _):
|
||||
case let .recentStickers(recentStickersData):
|
||||
let stickers = recentStickersData.stickers
|
||||
var items: [OrderedItemListEntry] = []
|
||||
for sticker in stickers {
|
||||
if let file = telegramMediaFileFromApiDocument(sticker, altDocuments: []), let id = file.id {
|
||||
@@ -79,7 +80,8 @@ func managedRecentGifs(postbox: Postbox, network: Network, forceFetch: Bool = fa
|
||||
switch result {
|
||||
case .savedGifsNotModified:
|
||||
return .single(nil)
|
||||
case let .savedGifs(_, gifs):
|
||||
case let .savedGifs(savedGifsData):
|
||||
let gifs = savedGifsData.gifs
|
||||
var items: [OrderedItemListEntry] = []
|
||||
for gif in gifs {
|
||||
if let file = telegramMediaFileFromApiDocument(gif, altDocuments: []), let id = file.id {
|
||||
@@ -105,11 +107,13 @@ func managedSavedStickers(postbox: Postbox, network: Network, forceFetch: Bool =
|
||||
switch result {
|
||||
case .favedStickersNotModified:
|
||||
return .single(nil)
|
||||
case let .favedStickers(_, packs, stickers):
|
||||
case let .favedStickers(favedStickersData):
|
||||
let (packs, stickers) = (favedStickersData.packs, favedStickersData.stickers)
|
||||
var fileStringRepresentations: [MediaId: [String]] = [:]
|
||||
for pack in packs {
|
||||
switch pack {
|
||||
case let .stickerPack(text, fileIds):
|
||||
case let .stickerPack(stickerPackData):
|
||||
let (text, fileIds) = (stickerPackData.emoticon, stickerPackData.documents)
|
||||
for fileId in fileIds {
|
||||
let mediaId = MediaId(namespace: Namespaces.Media.CloudFile, id: fileId)
|
||||
if fileStringRepresentations[mediaId] == nil {
|
||||
@@ -150,7 +154,8 @@ func managedGreetingStickers(postbox: Postbox, network: Network) -> Signal<Void,
|
||||
switch result {
|
||||
case .stickersNotModified:
|
||||
return .single(nil)
|
||||
case let .stickers(_, stickers):
|
||||
case let .stickers(stickersData):
|
||||
let stickers = stickersData.stickers
|
||||
var items: [OrderedItemListEntry] = []
|
||||
for sticker in stickers {
|
||||
if let file = telegramMediaFileFromApiDocument(sticker, altDocuments: []), let id = file.id {
|
||||
@@ -177,7 +182,8 @@ func managedPremiumStickers(postbox: Postbox, network: Network) -> Signal<Void,
|
||||
switch result {
|
||||
case .stickersNotModified:
|
||||
return .single(nil)
|
||||
case let .stickers(_, stickers):
|
||||
case let .stickers(stickersData):
|
||||
let stickers = stickersData.stickers
|
||||
var items: [OrderedItemListEntry] = []
|
||||
for sticker in stickers {
|
||||
if let file = telegramMediaFileFromApiDocument(sticker, altDocuments: []), let id = file.id {
|
||||
@@ -204,7 +210,8 @@ func managedAllPremiumStickers(postbox: Postbox, network: Network) -> Signal<Voi
|
||||
switch result {
|
||||
case .stickersNotModified:
|
||||
return .single(nil)
|
||||
case let .stickers(_, stickers):
|
||||
case let .stickers(stickersData):
|
||||
let stickers = stickersData.stickers
|
||||
var items: [OrderedItemListEntry] = []
|
||||
for sticker in stickers {
|
||||
if let file = telegramMediaFileFromApiDocument(sticker, altDocuments: []), let id = file.id {
|
||||
@@ -231,9 +238,10 @@ func managedRecentStatusEmoji(postbox: Postbox, network: Network) -> Signal<Void
|
||||
switch result {
|
||||
case .emojiStatusesNotModified:
|
||||
return .single(nil)
|
||||
case let .emojiStatuses(_, statuses):
|
||||
case let .emojiStatuses(emojiStatusesData):
|
||||
let statuses = emojiStatusesData.statuses
|
||||
let parsedStatuses = statuses.compactMap(PeerEmojiStatus.init(apiStatus:))
|
||||
|
||||
|
||||
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: parsedStatuses.compactMap(\.emojiFileId))
|
||||
|> map { files -> [OrderedItemListEntry] in
|
||||
var items: [OrderedItemListEntry] = []
|
||||
@@ -264,9 +272,10 @@ func managedFeaturedStatusEmoji(postbox: Postbox, network: Network) -> Signal<Vo
|
||||
switch result {
|
||||
case .emojiStatusesNotModified:
|
||||
return .single(nil)
|
||||
case let .emojiStatuses(_, statuses):
|
||||
case let .emojiStatuses(emojiStatusesData):
|
||||
let statuses = emojiStatusesData.statuses
|
||||
let parsedStatuses = statuses.compactMap(PeerEmojiStatus.init(apiStatus:))
|
||||
|
||||
|
||||
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: parsedStatuses.compactMap(\.emojiFileId))
|
||||
|> map { files -> [OrderedItemListEntry] in
|
||||
var items: [OrderedItemListEntry] = []
|
||||
@@ -297,9 +306,10 @@ func managedFeaturedChannelStatusEmoji(postbox: Postbox, network: Network) -> Si
|
||||
switch result {
|
||||
case .emojiStatusesNotModified:
|
||||
return .single(nil)
|
||||
case let .emojiStatuses(_, statuses):
|
||||
case let .emojiStatuses(emojiStatusesData):
|
||||
let statuses = emojiStatusesData.statuses
|
||||
let parsedStatuses = statuses.compactMap(PeerEmojiStatus.init(apiStatus:))
|
||||
|
||||
|
||||
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: parsedStatuses.compactMap(\.emojiFileId))
|
||||
|> map { files -> [OrderedItemListEntry] in
|
||||
var items: [OrderedItemListEntry] = []
|
||||
@@ -330,9 +340,10 @@ func managedUniqueStarGifts(accountPeerId: PeerId, postbox: Postbox, network: Ne
|
||||
switch result {
|
||||
case .emojiStatusesNotModified:
|
||||
return .single(nil)
|
||||
case let .emojiStatuses(_, statuses):
|
||||
case let .emojiStatuses(emojiStatusesData):
|
||||
let statuses = emojiStatusesData.statuses
|
||||
let parsedStatuses = statuses.compactMap(PeerEmojiStatus.init(apiStatus:))
|
||||
|
||||
|
||||
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: parsedStatuses.flatMap(\.associatedFileIds))
|
||||
|> map { files -> [OrderedItemListEntry] in
|
||||
var items: [OrderedItemListEntry] = []
|
||||
@@ -349,9 +360,9 @@ func managedUniqueStarGifts(accountPeerId: PeerId, postbox: Postbox, network: Ne
|
||||
slug: slug,
|
||||
owner: .peerId(accountPeerId),
|
||||
attributes: [
|
||||
.model(name: "", file: file, rarity: 0),
|
||||
.pattern(name: "", file: patternFile, rarity: 0),
|
||||
.backdrop(name: "", id: 0, innerColor: innerColor, outerColor: outerColor, patternColor: patternColor, textColor: textColor, rarity: 0)
|
||||
.model(name: "", file: file, rarity: .rare, crafted: true),
|
||||
.pattern(name: "", file: patternFile, rarity: .rare),
|
||||
.backdrop(name: "", id: 0, innerColor: innerColor, outerColor: outerColor, patternColor: patternColor, textColor: textColor, rarity: .rare)
|
||||
],
|
||||
availability: StarGift.UniqueGift.Availability(issued: 0, total: 0),
|
||||
giftAddress: nil,
|
||||
@@ -365,7 +376,8 @@ func managedUniqueStarGifts(accountPeerId: PeerId, postbox: Postbox, network: Ne
|
||||
themePeerId: nil,
|
||||
peerColor: nil,
|
||||
hostPeerId: nil,
|
||||
minOfferStars: nil
|
||||
minOfferStars: nil,
|
||||
craftChancePermille: nil
|
||||
)
|
||||
if let entry = CodableEntry(RecentStarGiftItem(gift)) {
|
||||
items.append(OrderedItemListEntry(id: RecentStarGiftItemId(id).rawValue, contents: entry))
|
||||
@@ -395,7 +407,8 @@ func managedProfilePhotoEmoji(postbox: Postbox, network: Network) -> Signal<Void
|
||||
switch result {
|
||||
case .emojiListNotModified:
|
||||
return .single(nil)
|
||||
case let .emojiList(_, documentIds):
|
||||
case let .emojiList(emojiListData):
|
||||
let documentIds = emojiListData.documentId
|
||||
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: documentIds)
|
||||
|> map { files -> [OrderedItemListEntry] in
|
||||
var items: [OrderedItemListEntry] = []
|
||||
@@ -426,7 +439,8 @@ func managedGroupPhotoEmoji(postbox: Postbox, network: Network) -> Signal<Void,
|
||||
switch result {
|
||||
case .emojiListNotModified:
|
||||
return .single(nil)
|
||||
case let .emojiList(_, documentIds):
|
||||
case let .emojiList(emojiListData):
|
||||
let documentIds = emojiListData.documentId
|
||||
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: documentIds)
|
||||
|> map { files -> [OrderedItemListEntry] in
|
||||
var items: [OrderedItemListEntry] = []
|
||||
@@ -457,7 +471,8 @@ func managedBackgroundIconEmoji(postbox: Postbox, network: Network) -> Signal<Vo
|
||||
switch result {
|
||||
case .emojiListNotModified:
|
||||
return .single(nil)
|
||||
case let .emojiList(_, documentIds):
|
||||
case let .emojiList(emojiListData):
|
||||
let documentIds = emojiListData.documentId
|
||||
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: documentIds)
|
||||
|> map { files -> [OrderedItemListEntry] in
|
||||
var items: [OrderedItemListEntry] = []
|
||||
@@ -488,7 +503,8 @@ func managedDisabledChannelStatusIconEmoji(postbox: Postbox, network: Network) -
|
||||
switch result {
|
||||
case .emojiListNotModified:
|
||||
return .single(nil)
|
||||
case let .emojiList(_, documentIds):
|
||||
case let .emojiList(emojiListData):
|
||||
let documentIds = emojiListData.documentId
|
||||
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: documentIds)
|
||||
|> map { files -> [OrderedItemListEntry] in
|
||||
var items: [OrderedItemListEntry] = []
|
||||
@@ -528,9 +544,10 @@ func managedRecentReactions(postbox: Postbox, network: Network) -> Signal<Void,
|
||||
switch result {
|
||||
case .reactionsNotModified:
|
||||
return .single(nil)
|
||||
case let .reactions(_, reactions):
|
||||
case let .reactions(reactionsData):
|
||||
let reactions = reactionsData.reactions
|
||||
let parsedReactions = reactions.compactMap(MessageReaction.Reaction.init(apiReaction:))
|
||||
|
||||
|
||||
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: parsedReactions.compactMap { reaction -> Int64? in
|
||||
switch reaction {
|
||||
case .builtin:
|
||||
@@ -588,9 +605,10 @@ func managedTopReactions(postbox: Postbox, network: Network) -> Signal<Void, NoE
|
||||
switch result {
|
||||
case .reactionsNotModified:
|
||||
return .single(nil)
|
||||
case let .reactions(_, reactions):
|
||||
case let .reactions(reactionsData):
|
||||
let reactions = reactionsData.reactions
|
||||
let parsedReactions = reactions.compactMap(MessageReaction.Reaction.init(apiReaction:))
|
||||
|
||||
|
||||
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: parsedReactions.compactMap { reaction -> Int64? in
|
||||
switch reaction {
|
||||
case .builtin:
|
||||
@@ -648,9 +666,10 @@ func managedDefaultTagReactions(postbox: Postbox, network: Network) -> Signal<Vo
|
||||
switch result {
|
||||
case .reactionsNotModified:
|
||||
return .single(nil)
|
||||
case let .reactions(_, reactions):
|
||||
case let .reactions(reactionsData):
|
||||
let reactions = reactionsData.reactions
|
||||
let parsedReactions = reactions.compactMap(MessageReaction.Reaction.init(apiReaction:))
|
||||
|
||||
|
||||
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: parsedReactions.compactMap { reaction -> Int64? in
|
||||
switch reaction {
|
||||
case .builtin:
|
||||
|
||||
@@ -246,7 +246,7 @@ private func initialHandshakeAccept(postbox: Postbox, network: Network, peerId:
|
||||
memcpy(&keyFingerprint, bytes.advanced(by: keyHash.count - 8), 8)
|
||||
}
|
||||
|
||||
let result = network.request(Api.functions.messages.acceptEncryption(peer: .inputEncryptedChat(chatId: Int32(peerId.id._internalGetInt64Value()), accessHash: accessHash), gB: Buffer(data: gb), keyFingerprint: keyFingerprint))
|
||||
let result = network.request(Api.functions.messages.acceptEncryption(peer: .inputEncryptedChat(.init(chatId: Int32(peerId.id._internalGetInt64Value()), accessHash: accessHash)), gB: Buffer(data: gb), keyFingerprint: keyFingerprint))
|
||||
|
||||
let response = result
|
||||
|> map { result -> Api.EncryptedChat? in
|
||||
@@ -1783,9 +1783,11 @@ private func sendMessage(auxiliaryMethods: AccountAuxiliaryMethods, postbox: Pos
|
||||
var encryptedFile: SecretChatFileReference?
|
||||
if case let .message(result) = result {
|
||||
switch result {
|
||||
case let .sentEncryptedMessage(date):
|
||||
case let .sentEncryptedMessage(sentEncryptedMessageData):
|
||||
let date = sentEncryptedMessageData.date
|
||||
timestamp = date
|
||||
case let .sentEncryptedFile(date, file):
|
||||
case let .sentEncryptedFile(sentEncryptedFileData):
|
||||
let (date, file) = (sentEncryptedFileData.date, sentEncryptedFileData.file)
|
||||
timestamp = date
|
||||
encryptedFile = SecretChatFileReference(file)
|
||||
}
|
||||
@@ -1928,9 +1930,11 @@ private func sendStandaloneMessage(auxiliaryMethods: AccountAuxiliaryMethods, po
|
||||
var encryptedFile: SecretChatFileReference?
|
||||
if case let .message(result) = result {
|
||||
switch result {
|
||||
case let .sentEncryptedMessage(date):
|
||||
case let .sentEncryptedMessage(sentEncryptedMessageData):
|
||||
let date = sentEncryptedMessageData.date
|
||||
timestamp = date
|
||||
case let .sentEncryptedFile(date, file):
|
||||
case let .sentEncryptedFile(sentEncryptedFileData):
|
||||
let (date, file) = (sentEncryptedFileData.date, sentEncryptedFileData.file)
|
||||
timestamp = date
|
||||
encryptedFile = SecretChatFileReference(file)
|
||||
}
|
||||
@@ -2048,9 +2052,11 @@ private func sendServiceActionMessage(postbox: Postbox, network: Network, peerId
|
||||
var timestamp = currentMessage.timestamp
|
||||
if case let .message(result) = result {
|
||||
switch result {
|
||||
case let .sentEncryptedMessage(date):
|
||||
case let .sentEncryptedMessage(sentEncryptedMessageData):
|
||||
let date = sentEncryptedMessageData.date
|
||||
timestamp = date
|
||||
case let .sentEncryptedFile(date, _):
|
||||
case let .sentEncryptedFile(sentEncryptedFileData):
|
||||
let date = sentEncryptedFileData.date
|
||||
timestamp = date
|
||||
}
|
||||
flags.remove(.Unsent)
|
||||
@@ -2132,7 +2138,7 @@ private func sendBoxedDecryptedMessage(postbox: Postbox, network: Network, peer:
|
||||
decryptedMessage.serialize(payload, role: state.role, sequenceInfo: sequenceInfo)
|
||||
let encryptedPayload = encryptedMessageContents(parameters: parameters, data: MemoryBuffer(payload))
|
||||
let sendMessage: Signal<Api.messages.SentEncryptedMessage, MTRpcError>
|
||||
let inputPeer = Api.InputEncryptedChat.inputEncryptedChat(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: peer.accessHash)
|
||||
let inputPeer = Api.InputEncryptedChat.inputEncryptedChat(.init(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: peer.accessHash))
|
||||
|
||||
var flags: Int32 = 0
|
||||
if silent {
|
||||
@@ -2188,7 +2194,7 @@ private func requestTerminateSecretChat(postbox: Postbox, network: Network, peer
|
||||
}
|
||||
|> mapToSignal { peer -> Signal<Void, NoError> in
|
||||
if let peer = peer {
|
||||
return network.request(Api.functions.messages.reportEncryptedSpam(peer: Api.InputEncryptedChat.inputEncryptedChat(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: peer.accessHash)))
|
||||
return network.request(Api.functions.messages.reportEncryptedSpam(peer: Api.InputEncryptedChat.inputEncryptedChat(.init(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: peer.accessHash))))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.Bool?, NoError> in
|
||||
return .single(nil)
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ private func synchronizeAppLogEvents(transaction: Transaction, postbox: Postbox,
|
||||
switch operation.content {
|
||||
case let .add(time, type, peerId, data):
|
||||
if let data = apiJson(data) {
|
||||
events.append(.inputAppEvent(time: time, type: type, peer: peerId?.toInt64() ?? 0, data: data))
|
||||
events.append(.inputAppEvent(.init(time: time, type: type, peer: peerId?.toInt64() ?? 0, data: data)))
|
||||
}
|
||||
default:
|
||||
break
|
||||
|
||||
+4
-4
@@ -215,17 +215,17 @@ private func synchronizeChatInputState(transaction: Transaction, postbox: Postbo
|
||||
innerFlags |= 1 << 6
|
||||
}
|
||||
if !discard {
|
||||
replyTo = .inputReplyToMessage(flags: innerFlags, replyToMsgId: replySubject.messageId.id, topMsgId: topMsgId, replyToPeerId: replyToPeer, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId)
|
||||
replyTo = .inputReplyToMessage(.init(flags: innerFlags, replyToMsgId: replySubject.messageId.id, topMsgId: topMsgId, replyToPeerId: replyToPeer, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId))
|
||||
}
|
||||
} else if let topMsgId {
|
||||
flags |= 1 << 0
|
||||
|
||||
var innerFlags: Int32 = 0
|
||||
innerFlags |= 1 << 0
|
||||
replyTo = .inputReplyToMessage(flags: innerFlags, replyToMsgId: topMsgId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil)
|
||||
replyTo = .inputReplyToMessage(.init(flags: innerFlags, replyToMsgId: topMsgId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil))
|
||||
} else if let monoforumPeerId {
|
||||
flags |= 1 << 0
|
||||
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
|
||||
replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId))
|
||||
}
|
||||
|
||||
let suggestedPost = inputState?.suggestedPost.flatMap { suggestedPost -> Api.SuggestedPost in
|
||||
@@ -233,7 +233,7 @@ private func synchronizeChatInputState(transaction: Transaction, postbox: Postbo
|
||||
if suggestedPost.timestamp != nil {
|
||||
flags |= 1 << 0
|
||||
}
|
||||
return .suggestedPost(flags: flags, price: suggestedPost.price?.apiAmount ?? .starsAmount(amount: 0, nanos: 0), scheduleDate: suggestedPost.timestamp)
|
||||
return .suggestedPost(.init(flags: flags, price: suggestedPost.price?.apiAmount ?? .starsAmount(.init(amount: 0, nanos: 0)), scheduleDate: suggestedPost.timestamp))
|
||||
}
|
||||
if suggestedPost != nil {
|
||||
flags |= 1 << 8
|
||||
|
||||
+2
-1
@@ -119,7 +119,8 @@ private func synchronizeConsumeMessageContents(transaction: Transaction, network
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .affectedMessages(pts, ptsCount):
|
||||
case let .affectedMessages(affectedMessagesData):
|
||||
let (pts, ptsCount) = (affectedMessagesData.pts, affectedMessagesData.ptsCount)
|
||||
stateManager.addUpdateGroups([.updatePts(pts: pts, ptsCount: ptsCount)])
|
||||
}
|
||||
}
|
||||
|
||||
+11
-6
@@ -123,18 +123,21 @@ private func synchronizeEmojiKeywords(postbox: Postbox, transaction: Transaction
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
switch result {
|
||||
case let .emojiKeywordsDifference(langCode, _, version, keywords):
|
||||
case let .emojiKeywordsDifference(emojiKeywordsDifferenceData):
|
||||
let (langCode, version, keywords) = (emojiKeywordsDifferenceData.langCode, emojiKeywordsDifferenceData.version, emojiKeywordsDifferenceData.keywords)
|
||||
if langCode == languageCode {
|
||||
var itemsToAppend: [String: EmojiKeywordItem] = [:]
|
||||
var itemsToSubtract: [String: EmojiKeywordItem] = [:]
|
||||
for apiEmojiKeyword in keywords {
|
||||
switch apiEmojiKeyword {
|
||||
case let .emojiKeyword(keyword, emoticons):
|
||||
let keyword = keyword.replacingOccurrences(of: " ", with: "")
|
||||
case let .emojiKeyword(emojiKeywordData):
|
||||
let (rawKeyword, emoticons) = (emojiKeywordData.keyword, emojiKeywordData.emoticons)
|
||||
let keyword = rawKeyword.replacingOccurrences(of: " ", with: "")
|
||||
let indexKeys = stringIndexTokens(keyword, transliteration: .none).map { $0.toMemoryBuffer() }
|
||||
let item = EmojiKeywordItem(index: ItemCollectionItemIndex(index: 0, id: 0), collectionId: collectionId.id, keyword: keyword, emoticons: emoticons, indexKeys: indexKeys)
|
||||
itemsToAppend[keyword] = item
|
||||
case let .emojiKeywordDeleted(keyword, emoticons):
|
||||
case let .emojiKeywordDeleted(emojiKeywordDeletedData):
|
||||
let (keyword, emoticons) = (emojiKeywordDeletedData.keyword, emojiKeywordDeletedData.emoticons)
|
||||
let item = EmojiKeywordItem(index: ItemCollectionItemIndex(index: 0, id: 0), collectionId: collectionId.id, keyword: keyword, emoticons: emoticons, indexKeys: [])
|
||||
itemsToSubtract[keyword] = item
|
||||
}
|
||||
@@ -195,11 +198,13 @@ private func synchronizeEmojiKeywords(postbox: Postbox, transaction: Transaction
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
switch result {
|
||||
case let .emojiKeywordsDifference(langCode, _, version, keywords):
|
||||
case let .emojiKeywordsDifference(emojiKeywordsDifferenceData):
|
||||
let (langCode, version, keywords) = (emojiKeywordsDifferenceData.langCode, emojiKeywordsDifferenceData.version, emojiKeywordsDifferenceData.keywords)
|
||||
var items: [EmojiKeywordItem] = []
|
||||
var index: Int32 = 0
|
||||
for apiEmojiKeyword in keywords {
|
||||
if case let .emojiKeyword(fullKeyword, emoticons) = apiEmojiKeyword, !emoticons.isEmpty {
|
||||
if case let .emojiKeyword(emojiKeywordData) = apiEmojiKeyword, !emojiKeywordData.emoticons.isEmpty {
|
||||
let (fullKeyword, emoticons) = (emojiKeywordData.keyword, emojiKeywordData.emoticons)
|
||||
let keyword = fullKeyword
|
||||
let indexKeys = stringIndexTokens(keyword, transliteration: .none).map { $0.toMemoryBuffer() }
|
||||
let item = EmojiKeywordItem(index: ItemCollectionItemIndex(index: index, id: keywordCollectionItemId(keyword, inputLanguageCode: operation.inputLanguageCode)), collectionId: collectionId.id, keyword: keyword, emoticons: emoticons, indexKeys: indexKeys)
|
||||
|
||||
@@ -79,7 +79,7 @@ private func synchronizeGroupMessageStats(postbox: Postbox, network: Network, gr
|
||||
return .complete()
|
||||
}
|
||||
|
||||
return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeerFolder(folderId: groupId.rawValue)]))
|
||||
return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeerFolder(.init(folderId: groupId.rawValue))]))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.messages.PeerDialogs?, NoError> in
|
||||
return .single(nil)
|
||||
@@ -88,10 +88,12 @@ private func synchronizeGroupMessageStats(postbox: Postbox, network: Network, gr
|
||||
return postbox.transaction { transaction in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .peerDialogs(dialogs, _, _, _, _):
|
||||
case let .peerDialogs(peerDialogsData):
|
||||
let dialogs = peerDialogsData.dialogs
|
||||
for dialog in dialogs {
|
||||
switch dialog {
|
||||
case let .dialogFolder(_, _, _, _, unreadMutedPeersCount, _, unreadMutedMessagesCount, _):
|
||||
case let .dialogFolder(dialogFolderData):
|
||||
let (unreadMutedPeersCount, unreadMutedMessagesCount) = (dialogFolderData.unreadMutedPeersCount, dialogFolderData.unreadMutedMessagesCount)
|
||||
transaction.resetPeerGroupSummary(groupId: groupId, namespace: namespace, summary: PeerGroupUnreadCountersSummary(all: PeerGroupUnreadCounters(messageCount: unreadMutedMessagesCount, chatCount: unreadMutedPeersCount)))
|
||||
case .dialog:
|
||||
assertionFailure()
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ private func synchronizeGroupedPeers(transaction: Transaction, postbox: Postbox,
|
||||
var folderPeers: [Api.InputFolderPeer] = []
|
||||
for operation in operations {
|
||||
if let inputPeer = transaction.getPeer(operation.peerId).flatMap(apiInputPeer) {
|
||||
folderPeers.append(.inputFolderPeer(peer: inputPeer, folderId: operation.groupId.rawValue))
|
||||
folderPeers.append(.inputFolderPeer(.init(peer: inputPeer, folderId: operation.groupId.rawValue)))
|
||||
}
|
||||
}
|
||||
if folderPeers.isEmpty {
|
||||
|
||||
+24
-15
@@ -143,19 +143,21 @@ private enum SynchronizeInstalledStickerPacksError {
|
||||
}
|
||||
|
||||
private func fetchStickerPack(network: Network, info: StickerPackCollectionInfo) -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> {
|
||||
return network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash), hash: 0))
|
||||
return network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)), hash: 0))
|
||||
|> map { result -> (StickerPackCollectionInfo, [ItemCollectionItem]) in
|
||||
var items: [ItemCollectionItem] = []
|
||||
var updatedInfo = info
|
||||
switch result {
|
||||
case .stickerSetNotModified:
|
||||
break
|
||||
case let .stickerSet(stickerSet, packs, keywords, documents):
|
||||
case let .stickerSet(stickerSetData):
|
||||
let (stickerSet, packs, keywords, documents) = (stickerSetData.set, stickerSetData.packs, stickerSetData.keywords, stickerSetData.documents)
|
||||
updatedInfo = StickerPackCollectionInfo(apiSet: stickerSet, namespace: info.id.namespace)
|
||||
var indexKeysByFile: [MediaId: [MemoryBuffer]] = [:]
|
||||
for pack in packs {
|
||||
switch pack {
|
||||
case let .stickerPack(text, fileIds):
|
||||
case let .stickerPack(stickerPackData):
|
||||
let (text, fileIds) = (stickerPackData.emoticon, stickerPackData.documents)
|
||||
let key = ValueBoxKey(text).toMemoryBuffer()
|
||||
for fileId in fileIds {
|
||||
let mediaId = MediaId(namespace: Namespaces.Media.CloudFile, id: fileId)
|
||||
@@ -170,7 +172,8 @@ private func fetchStickerPack(network: Network, info: StickerPackCollectionInfo)
|
||||
}
|
||||
for keyword in keywords {
|
||||
switch keyword {
|
||||
case let .stickerKeyword(documentId, texts):
|
||||
case let .stickerKeyword(stickerKeywordData):
|
||||
let (documentId, texts) = (stickerKeywordData.documentId, stickerKeywordData.keyword)
|
||||
for text in texts {
|
||||
let key = ValueBoxKey(text).toMemoryBuffer()
|
||||
let mediaId = MediaId(namespace: Namespaces.Media.CloudFile, id: documentId)
|
||||
@@ -228,22 +231,27 @@ private func resolveStickerPacks(network: Network, remoteInfos: [ItemCollectionI
|
||||
private func installRemoteStickerPacks(network: Network, infos: [StickerPackCollectionInfo]) -> Signal<Set<ItemCollectionId>, NoError> {
|
||||
var signals: [Signal<Set<ItemCollectionId>, NoError>] = []
|
||||
for info in infos {
|
||||
let install = network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash), archived: .boolFalse))
|
||||
let install = network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)), archived: .boolFalse))
|
||||
|> map { result -> Set<ItemCollectionId> in
|
||||
switch result {
|
||||
case .stickerSetInstallResultSuccess:
|
||||
return Set()
|
||||
case let .stickerSetInstallResultArchive(archivedSets):
|
||||
case let .stickerSetInstallResultArchive(stickerSetInstallResultArchiveData):
|
||||
let archivedSets = stickerSetInstallResultArchiveData.sets
|
||||
var archivedIds = Set<ItemCollectionId>()
|
||||
for archivedSet in archivedSets {
|
||||
switch archivedSet {
|
||||
case let .stickerSetCovered(set, _):
|
||||
case let .stickerSetCovered(stickerSetCoveredData):
|
||||
let set = stickerSetCoveredData.set
|
||||
archivedIds.insert(StickerPackCollectionInfo(apiSet: set, namespace: info.id.namespace).id)
|
||||
case let .stickerSetMultiCovered(set, _):
|
||||
case let .stickerSetMultiCovered(stickerSetMultiCoveredData):
|
||||
let set = stickerSetMultiCoveredData.set
|
||||
archivedIds.insert(StickerPackCollectionInfo(apiSet: set, namespace: info.id.namespace).id)
|
||||
case let .stickerSetFullCovered(set, _, _, _):
|
||||
case let .stickerSetFullCovered(stickerSetFullCoveredData):
|
||||
let set = stickerSetFullCoveredData.set
|
||||
archivedIds.insert(StickerPackCollectionInfo(apiSet: set, namespace: info.id.namespace).id)
|
||||
case let .stickerSetNoCovered(set):
|
||||
case let .stickerSetNoCovered(stickerSetNoCoveredData):
|
||||
let set = stickerSetNoCoveredData.set
|
||||
archivedIds.insert(StickerPackCollectionInfo(apiSet: set, namespace: info.id.namespace).id)
|
||||
}
|
||||
}
|
||||
@@ -268,7 +276,7 @@ private func installRemoteStickerPacks(network: Network, infos: [StickerPackColl
|
||||
private func removeRemoteStickerPacks(network: Network, infos: [StickerPackCollectionInfo]) -> Signal<Void, NoError> {
|
||||
if infos.count > 0 {
|
||||
if infos.count > 1 {
|
||||
return network.request(Api.functions.messages.toggleStickerSets(flags: 1 << 0, stickersets: infos.map { .inputStickerSetID(id: $0.id.id, accessHash: $0.accessHash) }))
|
||||
return network.request(Api.functions.messages.toggleStickerSets(flags: 1 << 0, stickersets: infos.map { .inputStickerSetID(.init(id: $0.id.id, accessHash: $0.accessHash)) }))
|
||||
|> mapToSignal { _ -> Signal<Void, MTRpcError> in
|
||||
return .single(Void())
|
||||
}
|
||||
@@ -276,7 +284,7 @@ private func removeRemoteStickerPacks(network: Network, infos: [StickerPackColle
|
||||
return .single(Void())
|
||||
}
|
||||
} else if let info = infos.first {
|
||||
return network.request(Api.functions.messages.uninstallStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash)))
|
||||
return network.request(Api.functions.messages.uninstallStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash))))
|
||||
|> mapToSignal { _ -> Signal<Void, MTRpcError> in
|
||||
return .single(Void())
|
||||
}
|
||||
@@ -291,7 +299,7 @@ private func removeRemoteStickerPacks(network: Network, infos: [StickerPackColle
|
||||
private func archiveRemoteStickerPacks(network: Network, infos: [StickerPackCollectionInfo]) -> Signal<Void, NoError> {
|
||||
if infos.count > 0 {
|
||||
if infos.count > 1 {
|
||||
return network.request(Api.functions.messages.toggleStickerSets(flags: 1 << 1, stickersets: infos.map { .inputStickerSetID(id: $0.id.id, accessHash: $0.accessHash) }))
|
||||
return network.request(Api.functions.messages.toggleStickerSets(flags: 1 << 1, stickersets: infos.map { .inputStickerSetID(.init(id: $0.id.id, accessHash: $0.accessHash)) }))
|
||||
|> mapToSignal { _ -> Signal<Void, MTRpcError> in
|
||||
return .single(Void())
|
||||
}
|
||||
@@ -299,7 +307,7 @@ private func archiveRemoteStickerPacks(network: Network, infos: [StickerPackColl
|
||||
return .single(Void())
|
||||
}
|
||||
} else if let info = infos.first {
|
||||
return network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash), archived: .boolTrue))
|
||||
return network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)), archived: .boolTrue))
|
||||
|> mapToSignal { _ -> Signal<Void, MTRpcError> in
|
||||
return .single(Void())
|
||||
}
|
||||
@@ -501,7 +509,8 @@ private func continueSynchronizeInstalledStickerPacks(transaction: Transaction,
|
||||
|
||||
var remoteCollectionInfos: [StickerPackCollectionInfo] = []
|
||||
switch result {
|
||||
case let .allStickers(_, sets):
|
||||
case let .allStickers(allStickersData):
|
||||
let sets = allStickersData.sets
|
||||
for apiSet in sets {
|
||||
let info = StickerPackCollectionInfo(apiSet: apiSet, namespace: collectionNamespace)
|
||||
remoteCollectionInfos.append(info)
|
||||
|
||||
+10
-5
@@ -126,13 +126,16 @@ private func synchronizeMarkAllUnseen(transaction: Transaction, postbox: Postbox
|
||||
return network.request(Api.functions.messages.getUnreadMentions(flags: 0, peer: inputPeer, topMsgId: nil, offsetId: maxId, addOffset: maxId == 0 ? 0 : -1, limit: limit, maxId: maxId == 0 ? 0 : (maxId + 1), minId: 1))
|
||||
|> mapToSignal { result -> Signal<[MessageId], MTRpcError> in
|
||||
switch result {
|
||||
case let .messages(messages, _, _, _):
|
||||
case let .messages(messagesData):
|
||||
let messages = messagesData.messages
|
||||
return .single(messages.compactMap({ $0.id() }))
|
||||
case let .channelMessages(_, _, _, _, messages, _, _, _):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let messages = channelMessagesData.messages
|
||||
return .single(messages.compactMap({ $0.id() }))
|
||||
case .messagesNotModified:
|
||||
return .single([])
|
||||
case let .messagesSlice(_, _, _, _, _, messages, _, _, _):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let messages = messagesSliceData.messages
|
||||
return .single(messages.compactMap({ $0.id() }))
|
||||
}
|
||||
}
|
||||
@@ -157,7 +160,8 @@ private func synchronizeMarkAllUnseen(transaction: Transaction, postbox: Postbox
|
||||
return network.request(Api.functions.messages.readMessageContents(id: filteredIds.map { $0.id }))
|
||||
|> map { result -> Int32? in
|
||||
switch result {
|
||||
case let .affectedMessages(pts, ptsCount):
|
||||
case let .affectedMessages(affectedMessagesData):
|
||||
let (pts, ptsCount) = (affectedMessagesData.pts, affectedMessagesData.ptsCount)
|
||||
stateManager.addUpdateGroups([.updatePts(pts: pts, ptsCount: ptsCount)])
|
||||
}
|
||||
if ids.count < limit {
|
||||
@@ -310,7 +314,8 @@ private func synchronizeMarkAllUnseenReactions(transaction: Transaction, postbox
|
||||
|> mapToSignal { result -> Signal<Void, Bool> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .affectedHistory(pts, ptsCount, offset):
|
||||
case let .affectedHistory(affectedHistoryData):
|
||||
let (pts, ptsCount, offset) = (affectedHistoryData.pts, affectedHistoryData.ptsCount, affectedHistoryData.offset)
|
||||
stateManager.addUpdateGroups([.updatePts(pts: pts, ptsCount: ptsCount)])
|
||||
if offset == 0 {
|
||||
return .fail(true)
|
||||
|
||||
@@ -146,7 +146,8 @@ private func synchronizePinnedChats(transaction: Transaction, postbox: Postbox,
|
||||
let parsedPeers: AccumulatedPeers
|
||||
|
||||
switch dialogs {
|
||||
case let .peerDialogs(dialogs, messages, chats, users, _):
|
||||
case let .peerDialogs(peerDialogsData):
|
||||
let (dialogs, messages, chats, users) = (peerDialogsData.dialogs, peerDialogsData.messages, peerDialogsData.chats, peerDialogsData.users)
|
||||
parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
|
||||
|
||||
loop: for dialog in dialogs {
|
||||
@@ -160,7 +161,8 @@ private func synchronizePinnedChats(transaction: Transaction, postbox: Postbox,
|
||||
let apiTtlPeriod: Int32?
|
||||
let apiNotificationSettings: Api.PeerNotifySettings
|
||||
switch dialog {
|
||||
case let .dialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, _, _, peerNotificationSettings, pts, _, _, ttlPeriod):
|
||||
case let .dialog(dialogData):
|
||||
let (flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, peerNotificationSettings, pts, ttlPeriod) = (dialogData.flags, dialogData.peer, dialogData.topMessage, dialogData.readInboxMaxId, dialogData.readOutboxMaxId, dialogData.unreadCount, dialogData.notifySettings, dialogData.pts, dialogData.ttlPeriod)
|
||||
apiPeer = peer
|
||||
apiTopMessage = topMessage
|
||||
apiReadInboxMaxId = readInboxMaxId
|
||||
@@ -265,7 +267,7 @@ private func synchronizePinnedChats(transaction: Transaction, postbox: Postbox,
|
||||
switch itemId {
|
||||
case let .peer(peerId):
|
||||
if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
|
||||
inputDialogPeers.append(Api.InputDialogPeer.inputDialogPeer(peer: inputPeer))
|
||||
inputDialogPeers.append(Api.InputDialogPeer.inputDialogPeer(.init(peer: inputPeer)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,7 +313,8 @@ private func synchronizePinnedSavedChats(transaction: Transaction, postbox: Post
|
||||
|
||||
loop: for dialog in dialogs {
|
||||
switch dialog {
|
||||
case let .savedDialog(_, peer, _):
|
||||
case let .savedDialog(savedDialogData):
|
||||
let peer = savedDialogData.peer
|
||||
remoteItemIds.append(peer.peerId)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -128,7 +128,7 @@ private func synchronizeRecentlyUsedMedia(transaction: Transaction, accountPeerI
|
||||
}
|
||||
|
||||
let addSticker: (Data) -> Signal<Api.Bool, SaveRecentlyUsedMediaError> = { fileReference in
|
||||
return network.request(Api.functions.messages.saveRecentSticker(flags: 0, id: .inputDocument(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference)), unsave: .boolFalse))
|
||||
return network.request(Api.functions.messages.saveRecentSticker(flags: 0, id: .inputDocument(.init(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference))), unsave: .boolFalse))
|
||||
|> mapError { error -> SaveRecentlyUsedMediaError in
|
||||
if error.errorDescription.hasPrefix("FILEREF_INVALID") || error.errorDescription.hasPrefix("FILE_REFERENCE_") {
|
||||
return .invalidReference
|
||||
@@ -170,7 +170,7 @@ private func synchronizeRecentlyUsedMedia(transaction: Transaction, accountPeerI
|
||||
return .complete()
|
||||
}
|
||||
case let .remove(id, accessHash):
|
||||
return network.request(Api.functions.messages.saveRecentSticker(flags: 0, id: .inputDocument(id: id, accessHash: accessHash, fileReference: Buffer()), unsave: .boolTrue))
|
||||
return network.request(Api.functions.messages.saveRecentSticker(flags: 0, id: .inputDocument(.init(id: id, accessHash: accessHash, fileReference: Buffer())), unsave: .boolTrue))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ private func synchronizeSavedGifs(transaction: Transaction, accountPeerId: PeerI
|
||||
}
|
||||
|
||||
let saveGif: (Data) -> Signal<Api.Bool, SaveGifError> = { fileReference in
|
||||
return network.request(Api.functions.messages.saveGif(id: .inputDocument(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference)), unsave: .boolFalse))
|
||||
return network.request(Api.functions.messages.saveGif(id: .inputDocument(.init(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference))), unsave: .boolFalse))
|
||||
|> mapError { error -> SaveGifError in
|
||||
if error.errorDescription.hasPrefix("FILEREF_INVALID") || error.errorDescription.hasPrefix("FILE_REFERENCE_") {
|
||||
return .invalidReference
|
||||
@@ -166,7 +166,7 @@ private func synchronizeSavedGifs(transaction: Transaction, accountPeerId: PeerI
|
||||
return .complete()
|
||||
}
|
||||
case let .remove(id, accessHash):
|
||||
return network.request(Api.functions.messages.saveGif(id: .inputDocument(id: id, accessHash: accessHash, fileReference: Buffer()), unsave: .boolTrue))
|
||||
return network.request(Api.functions.messages.saveGif(id: .inputDocument(.init(id: id, accessHash: accessHash, fileReference: Buffer())), unsave: .boolTrue))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
||||
}
|
||||
|
||||
+2
-2
@@ -124,7 +124,7 @@ private func synchronizeSavedStickers(transaction: Transaction, accountPeerId: P
|
||||
}
|
||||
|
||||
let saveSticker: (Data) -> Signal<Api.Bool, SaveStickerError> = { fileReference in
|
||||
return network.request(Api.functions.messages.faveSticker(id: .inputDocument(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference)), unfave: .boolFalse))
|
||||
return network.request(Api.functions.messages.faveSticker(id: .inputDocument(.init(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference))), unfave: .boolFalse))
|
||||
|> mapError { error -> SaveStickerError in
|
||||
if error.errorDescription.hasPrefix("FILEREF_INVALID") || error.errorDescription.hasPrefix("FILE_REFERENCE_") {
|
||||
return .invalidReference
|
||||
@@ -166,7 +166,7 @@ private func synchronizeSavedStickers(transaction: Transaction, accountPeerId: P
|
||||
return .complete()
|
||||
}
|
||||
case let .remove(id, accessHash):
|
||||
return network.request(Api.functions.messages.faveSticker(id: .inputDocument(id: id, accessHash: accessHash, fileReference: Buffer()), unfave: .boolTrue))
|
||||
return network.request(Api.functions.messages.faveSticker(id: .inputDocument(.init(id: id, accessHash: accessHash, fileReference: Buffer())), unfave: .boolTrue))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ func managedVoipConfigurationUpdates(postbox: Postbox, network: Network) -> Sign
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
return postbox.transaction { transaction -> Void in
|
||||
switch result {
|
||||
case let .dataJSON(data):
|
||||
case let .dataJSON(dataJSONData):
|
||||
let data = dataJSONData.data
|
||||
updateVoipConfiguration(transaction: transaction, { configuration in
|
||||
var configuration = configuration
|
||||
configuration.serializedData = data
|
||||
|
||||
@@ -309,7 +309,7 @@ func _internal_updateStarsReactionPrivacy(account: Account, messageId: MessageId
|
||||
guard let inputPrivacyPeer else {
|
||||
return .complete()
|
||||
}
|
||||
mappedPrivacy = .paidReactionPrivacyPeer(peer: inputPrivacyPeer)
|
||||
mappedPrivacy = .paidReactionPrivacyPeer(.init(peer: inputPrivacyPeer))
|
||||
}
|
||||
|
||||
return account.network.request(Api.functions.messages.togglePaidReactionPrivacy(peer: inputPeer, msgId: messageId.id, private: mappedPrivacy))
|
||||
@@ -431,7 +431,7 @@ private func requestSendStarsReaction(postbox: Postbox, network: Network, stateM
|
||||
guard let inputPrivacyPeer = transaction.getPeer(peerId).flatMap(apiInputPeer) else {
|
||||
return nil
|
||||
}
|
||||
mappedPrivacy = .paidReactionPrivacyPeer(peer: inputPrivacyPeer)
|
||||
mappedPrivacy = .paidReactionPrivacyPeer(.init(peer: inputPrivacyPeer))
|
||||
}
|
||||
privacy = mappedPrivacy
|
||||
break
|
||||
@@ -907,7 +907,8 @@ public final class EngineMessageReactionListContext {
|
||||
|> mapToSignal { result -> Signal<InternalState, NoError> in
|
||||
return account.postbox.transaction { transaction -> InternalState in
|
||||
switch result {
|
||||
case let .messageReactionsList(_, count, reactions, chats, users, nextOffset):
|
||||
case let .messageReactionsList(messageReactionsListData):
|
||||
let (count, reactions, chats, users, nextOffset) = (messageReactionsListData.count, messageReactionsListData.reactions, messageReactionsListData.chats, messageReactionsListData.users, messageReactionsListData.nextOffset)
|
||||
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
|
||||
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
@@ -915,7 +916,8 @@ public final class EngineMessageReactionListContext {
|
||||
var items: [EngineMessageReactionListContext.Item] = []
|
||||
for reaction in reactions {
|
||||
switch reaction {
|
||||
case let .messagePeerReaction(_, peer, date, reaction):
|
||||
case let .messagePeerReaction(messagePeerReactionData):
|
||||
let (peer, date, reaction) = (messagePeerReactionData.peerId, messagePeerReactionData.date, messagePeerReactionData.reaction)
|
||||
if let peer = transaction.getPeer(peer.peerId), let reaction = MessageReaction.Reaction(apiReaction: reaction) {
|
||||
items.append(EngineMessageReactionListContext.Item(peer: EnginePeer(peer), reaction: reaction, timestamp: date, timestampIsReaction: true))
|
||||
}
|
||||
@@ -1022,9 +1024,9 @@ func _internal_updatePeerReactionSettings(account: Account, peerId: PeerId, reac
|
||||
let mappedReactions: Api.ChatReactions
|
||||
switch reactionSettings.allowedReactions {
|
||||
case .all:
|
||||
mappedReactions = .chatReactionsAll(flags: 0)
|
||||
mappedReactions = .chatReactionsAll(.init(flags: 0))
|
||||
case let .limited(array):
|
||||
mappedReactions = .chatReactionsSome(reactions: array.map(\.apiReaction))
|
||||
mappedReactions = .chatReactionsSome(.init(reactions: array.map(\.apiReaction)))
|
||||
case .empty:
|
||||
mappedReactions = .chatReactionsNone
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ func _internal_getPaidMessagesRevenue(account: Account, scopePeerId: PeerId, pee
|
||||
return nil
|
||||
}
|
||||
switch result {
|
||||
case let .paidMessagesRevenue(amount):
|
||||
case let .paidMessagesRevenue(paidMessagesRevenueData):
|
||||
let amount = paidMessagesRevenueData.starsAmount
|
||||
return StarsAmount(value: amount, nanos: 0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,28 +20,33 @@ public struct EmojiInteraction: Equatable {
|
||||
}
|
||||
|
||||
public init?(apiDataJson: Api.DataJSON) {
|
||||
if case let .dataJSON(string) = apiDataJson, let data = string.data(using: .utf8) {
|
||||
do {
|
||||
let decodedData = try JSONSerialization.jsonObject(with: data, options: [])
|
||||
guard let item = decodedData as? [String: Any] else {
|
||||
return nil
|
||||
}
|
||||
guard let version = item["v"] as? Int, version == 1 else {
|
||||
return nil
|
||||
}
|
||||
guard let animationsArray = item["a"] as? [Any] else {
|
||||
return nil
|
||||
}
|
||||
var animations: [EmojiInteraction.Animation] = []
|
||||
for animationDict in animationsArray {
|
||||
if let animationDict = animationDict as? [String: Any] {
|
||||
if let index = animationDict["i"] as? Int, let timeOffset = animationDict["t"] as? Double {
|
||||
animations.append(EmojiInteraction.Animation(index: index, timeOffset: Float(timeOffset)))
|
||||
if case let .dataJSON(dataJSONData) = apiDataJson {
|
||||
let string = dataJSONData.data
|
||||
if let data = string.data(using: .utf8) {
|
||||
do {
|
||||
let decodedData = try JSONSerialization.jsonObject(with: data, options: [])
|
||||
guard let item = decodedData as? [String: Any] else {
|
||||
return nil
|
||||
}
|
||||
guard let version = item["v"] as? Int, version == 1 else {
|
||||
return nil
|
||||
}
|
||||
guard let animationsArray = item["a"] as? [Any] else {
|
||||
return nil
|
||||
}
|
||||
var animations: [EmojiInteraction.Animation] = []
|
||||
for animationDict in animationsArray {
|
||||
if let animationDict = animationDict as? [String: Any] {
|
||||
if let index = animationDict["i"] as? Int, let timeOffset = animationDict["t"] as? Double {
|
||||
animations.append(EmojiInteraction.Animation(index: index, timeOffset: Float(timeOffset)))
|
||||
}
|
||||
}
|
||||
}
|
||||
self.animations = animations
|
||||
} catch {
|
||||
return nil
|
||||
}
|
||||
self.animations = animations
|
||||
} catch {
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
@@ -54,9 +59,9 @@ public struct EmojiInteraction: Equatable {
|
||||
public var apiDataJson: Api.DataJSON {
|
||||
let dict = ["v": 1, "a": self.animations.map({ ["i": $0.index, "t": NSDecimalNumber(value: $0.timeOffset).rounding(accordingToBehavior: roundingBehavior)] as [String : Any] })] as [String : Any]
|
||||
if let data = try? JSONSerialization.data(withJSONObject: dict, options: []), let dataString = String(data: data, encoding: .utf8) {
|
||||
return .dataJSON(data: dataString)
|
||||
return .dataJSON(.init(data: dataString))
|
||||
} else {
|
||||
return .dataJSON(data: "")
|
||||
return .dataJSON(.init(data: ""))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,15 +125,19 @@ extension PeerInputActivity {
|
||||
self = .recordingVoice
|
||||
case .sendMessageTypingAction:
|
||||
self = .typingText
|
||||
case let .sendMessageUploadDocumentAction(progress):
|
||||
case let .sendMessageUploadDocumentAction(sendMessageUploadDocumentActionData):
|
||||
let progress = sendMessageUploadDocumentActionData.progress
|
||||
self = .uploadingFile(progress: progress)
|
||||
case let .sendMessageUploadPhotoAction(progress):
|
||||
case let .sendMessageUploadPhotoAction(sendMessageUploadPhotoActionData):
|
||||
let progress = sendMessageUploadPhotoActionData.progress
|
||||
self = .uploadingPhoto(progress: progress)
|
||||
case let .sendMessageUploadVideoAction(progress):
|
||||
case let .sendMessageUploadVideoAction(sendMessageUploadVideoActionData):
|
||||
let progress = sendMessageUploadVideoActionData.progress
|
||||
self = .uploadingVideo(progress: progress)
|
||||
case .sendMessageRecordRoundAction:
|
||||
self = .recordingInstantVideo
|
||||
case let .sendMessageUploadRoundAction(progress):
|
||||
case let .sendMessageUploadRoundAction(sendMessageUploadRoundActionData):
|
||||
let progress = sendMessageUploadRoundActionData.progress
|
||||
self = .uploadingInstantVideo(progress: progress)
|
||||
case .speakingInGroupCallAction:
|
||||
self = .speakingInGroupCall(timestamp: timestamp)
|
||||
@@ -136,13 +145,15 @@ extension PeerInputActivity {
|
||||
self = .choosingSticker
|
||||
case .sendMessageHistoryImportAction:
|
||||
return nil
|
||||
case let .sendMessageEmojiInteraction(emoticon, messageId, interaction):
|
||||
case let .sendMessageEmojiInteraction(sendMessageEmojiInteractionData):
|
||||
let (emoticon, messageId, interaction) = (sendMessageEmojiInteractionData.emoticon, sendMessageEmojiInteractionData.msgId, sendMessageEmojiInteractionData.interaction)
|
||||
if let peerId = peerId {
|
||||
self = .interactingWithEmoji(emoticon: emoticon, messageId: MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: messageId), interaction: EmojiInteraction(apiDataJson: interaction))
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
case let .sendMessageEmojiInteractionSeen(emoticon):
|
||||
case let .sendMessageEmojiInteractionSeen(sendMessageEmojiInteractionSeenData):
|
||||
let emoticon = sendMessageEmojiInteractionSeenData.emoticon
|
||||
self = .seeingEmojiInteraction(emoticon: emoticon)
|
||||
case .sendMessageTextDraftAction:
|
||||
return nil
|
||||
|
||||
@@ -1105,9 +1105,9 @@ public final class PendingMessageManager {
|
||||
var quickReplyShortcut: Api.InputQuickReplyShortcut?
|
||||
if let quickReply {
|
||||
if let threadId = messages[0].0.threadId {
|
||||
quickReplyShortcut = .inputQuickReplyShortcutId(shortcutId: Int32(clamping: threadId))
|
||||
quickReplyShortcut = .inputQuickReplyShortcutId(.init(shortcutId: Int32(clamping: threadId)))
|
||||
} else {
|
||||
quickReplyShortcut = .inputQuickReplyShortcut(shortcut: quickReply.shortcut)
|
||||
quickReplyShortcut = .inputQuickReplyShortcut(.init(shortcut: quickReply.shortcut))
|
||||
}
|
||||
flags |= 1 << 17
|
||||
}
|
||||
@@ -1118,7 +1118,7 @@ public final class PendingMessageManager {
|
||||
|
||||
var replyTo: Api.InputReplyTo?
|
||||
if let monoforumPeerId {
|
||||
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
|
||||
replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId))
|
||||
flags |= 1 << 22
|
||||
}
|
||||
|
||||
@@ -1176,7 +1176,7 @@ public final class PendingMessageManager {
|
||||
singleFlags |= 1 << 0
|
||||
}
|
||||
|
||||
singleMedias.append(.inputSingleMedia(flags: singleFlags, media: inputMedia, randomId: uniqueId, message: text, entities: messageEntities))
|
||||
singleMedias.append(.inputSingleMedia(.init(flags: singleFlags, media: inputMedia, randomId: uniqueId, message: text, entities: messageEntities)))
|
||||
default:
|
||||
return failMessages(postbox: postbox, ids: group.map { $0.0 })
|
||||
}
|
||||
@@ -1253,23 +1253,23 @@ public final class PendingMessageManager {
|
||||
replyFlags |= 1 << 6
|
||||
}
|
||||
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId)
|
||||
replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId))
|
||||
} else if let replyToStoryId {
|
||||
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
|
||||
flags |= 1 << 0
|
||||
replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id)
|
||||
replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id))
|
||||
}
|
||||
} else if let monoforumPeerId {
|
||||
flags |= 1 << 0
|
||||
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
|
||||
replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId))
|
||||
}
|
||||
|
||||
var quickReplyShortcut: Api.InputQuickReplyShortcut?
|
||||
if let quickReply {
|
||||
if let threadId = messages[0].0.threadId {
|
||||
quickReplyShortcut = .inputQuickReplyShortcutId(shortcutId: Int32(clamping: threadId))
|
||||
quickReplyShortcut = .inputQuickReplyShortcutId(.init(shortcutId: Int32(clamping: threadId)))
|
||||
} else {
|
||||
quickReplyShortcut = .inputQuickReplyShortcut(shortcut: quickReply.shortcut)
|
||||
quickReplyShortcut = .inputQuickReplyShortcut(.init(shortcut: quickReply.shortcut))
|
||||
}
|
||||
flags |= 1 << 17
|
||||
}
|
||||
@@ -1645,15 +1645,15 @@ public final class PendingMessageManager {
|
||||
if let _ = replyTodoItemId {
|
||||
replyFlags |= 1 << 6
|
||||
}
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId)
|
||||
replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId))
|
||||
} else if let replyToStoryId = replyToStoryId {
|
||||
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
|
||||
flags |= 1 << 0
|
||||
replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id)
|
||||
replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id))
|
||||
}
|
||||
} else if let monoforumPeerId {
|
||||
flags |= 1 << 0
|
||||
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
|
||||
replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId))
|
||||
}
|
||||
if let attribute = message.webpagePreviewAttribute {
|
||||
if attribute.leadingPreview {
|
||||
@@ -1667,9 +1667,9 @@ public final class PendingMessageManager {
|
||||
var quickReplyShortcut: Api.InputQuickReplyShortcut?
|
||||
if let quickReply {
|
||||
if let threadId = message.threadId {
|
||||
quickReplyShortcut = .inputQuickReplyShortcutId(shortcutId: Int32(clamping: threadId))
|
||||
quickReplyShortcut = .inputQuickReplyShortcutId(.init(shortcutId: Int32(clamping: threadId)))
|
||||
} else {
|
||||
quickReplyShortcut = .inputQuickReplyShortcut(shortcut: quickReply.shortcut)
|
||||
quickReplyShortcut = .inputQuickReplyShortcut(.init(shortcut: quickReply.shortcut))
|
||||
}
|
||||
flags |= 1 << 17
|
||||
}
|
||||
@@ -1743,17 +1743,17 @@ public final class PendingMessageManager {
|
||||
if let _ = replyTodoItemId {
|
||||
replyFlags |= 1 << 6
|
||||
}
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId)
|
||||
replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId))
|
||||
} else if let replyToStoryId = replyToStoryId {
|
||||
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
|
||||
flags |= 1 << 0
|
||||
replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id)
|
||||
replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id))
|
||||
}
|
||||
} else if let monoforumPeerId {
|
||||
flags |= 1 << 0
|
||||
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
|
||||
replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId))
|
||||
}
|
||||
|
||||
|
||||
if let attribute = message.webpagePreviewAttribute {
|
||||
if attribute.leadingPreview {
|
||||
flags |= 1 << 16
|
||||
@@ -1766,9 +1766,9 @@ public final class PendingMessageManager {
|
||||
var quickReplyShortcut: Api.InputQuickReplyShortcut?
|
||||
if let quickReply {
|
||||
if let threadId = message.threadId {
|
||||
quickReplyShortcut = .inputQuickReplyShortcutId(shortcutId: Int32(clamping: threadId))
|
||||
quickReplyShortcut = .inputQuickReplyShortcutId(.init(shortcutId: Int32(clamping: threadId)))
|
||||
} else {
|
||||
quickReplyShortcut = .inputQuickReplyShortcut(shortcut: quickReply.shortcut)
|
||||
quickReplyShortcut = .inputQuickReplyShortcut(.init(shortcut: quickReply.shortcut))
|
||||
}
|
||||
flags |= 1 << 17
|
||||
}
|
||||
@@ -1805,9 +1805,9 @@ public final class PendingMessageManager {
|
||||
var quickReplyShortcut: Api.InputQuickReplyShortcut?
|
||||
if let quickReply {
|
||||
if let threadId = message.threadId {
|
||||
quickReplyShortcut = .inputQuickReplyShortcutId(shortcutId: Int32(clamping: threadId))
|
||||
quickReplyShortcut = .inputQuickReplyShortcutId(.init(shortcutId: Int32(clamping: threadId)))
|
||||
} else {
|
||||
quickReplyShortcut = .inputQuickReplyShortcut(shortcut: quickReply.shortcut)
|
||||
quickReplyShortcut = .inputQuickReplyShortcut(.init(shortcut: quickReply.shortcut))
|
||||
}
|
||||
flags |= 1 << 17
|
||||
}
|
||||
@@ -1822,7 +1822,7 @@ public final class PendingMessageManager {
|
||||
|
||||
var replyTo: Api.InputReplyTo?
|
||||
if let monoforumPeerId {
|
||||
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
|
||||
replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId))
|
||||
flags |= 1 << 22
|
||||
}
|
||||
|
||||
@@ -1891,23 +1891,23 @@ public final class PendingMessageManager {
|
||||
if let _ = replyTodoItemId {
|
||||
replyFlags |= 1 << 6
|
||||
}
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: message.threadId.flatMap(Int32.init(clamping:)), replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId)
|
||||
replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: message.threadId.flatMap(Int32.init(clamping:)), replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId))
|
||||
} else if let replyToStoryId = replyToStoryId {
|
||||
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
|
||||
flags |= 1 << 0
|
||||
replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id)
|
||||
replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id))
|
||||
}
|
||||
} else if let monoforumPeerId {
|
||||
flags |= 1 << 0
|
||||
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
|
||||
replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId))
|
||||
}
|
||||
|
||||
var quickReplyShortcut: Api.InputQuickReplyShortcut?
|
||||
if let quickReply {
|
||||
if let threadId = message.threadId {
|
||||
quickReplyShortcut = .inputQuickReplyShortcutId(shortcutId: Int32(clamping: threadId))
|
||||
quickReplyShortcut = .inputQuickReplyShortcutId(.init(shortcutId: Int32(clamping: threadId)))
|
||||
} else {
|
||||
quickReplyShortcut = .inputQuickReplyShortcut(shortcut: quickReply.shortcut)
|
||||
quickReplyShortcut = .inputQuickReplyShortcut(.init(shortcut: quickReply.shortcut))
|
||||
}
|
||||
flags |= 1 << 17
|
||||
}
|
||||
@@ -1923,18 +1923,18 @@ public final class PendingMessageManager {
|
||||
|
||||
if let replyMessageId = replyMessageId {
|
||||
let replyFlags: Int32 = 0
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil)
|
||||
replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil))
|
||||
} else if let replyToStoryId = replyToStoryId {
|
||||
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
|
||||
flags |= 1 << 0
|
||||
replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id)
|
||||
replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id))
|
||||
} else {
|
||||
let replyFlags: Int32 = 0
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil)
|
||||
replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil))
|
||||
}
|
||||
} else {
|
||||
let replyFlags: Int32 = 0
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil)
|
||||
replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil))
|
||||
}
|
||||
|
||||
sendMessageRequest = network.request(Api.functions.messages.sendScreenshotNotification(peer: inputPeer, replyTo: replyTo, randomId: uniqueId))
|
||||
@@ -2042,7 +2042,7 @@ public final class PendingMessageManager {
|
||||
}
|
||||
|
||||
private func applySentMessage(postbox: Postbox, stateManager: AccountStateManager, message: Message, content: PendingMessageUploadedContentAndReuploadInfo, result: Api.Updates) -> Signal<Void, NoError> {
|
||||
if let channel = message.peers[message.id.peerId] as? TelegramChannel, channel.isMonoForum {
|
||||
if let _ = message.peers[message.id.peerId] as? TelegramChannel {
|
||||
for attribute in message.attributes {
|
||||
if let attribute = attribute as? PaidStarsMessageAttribute {
|
||||
stateManager.starsContext?.add(balance: StarsAmount(value: -attribute.stars.value, nanos: (attribute.stars.value == 0 && attribute.stars.nanos != 0 ? -1 : 1) * attribute.stars.nanos))
|
||||
@@ -2076,7 +2076,8 @@ public final class PendingMessageManager {
|
||||
if message.scheduleTime != nil && message.scheduleTime == apiMessage.timestamp {
|
||||
isScheduled = true
|
||||
}
|
||||
if case let .message(_, flags2, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) = apiMessage {
|
||||
if case let .message(messageData) = apiMessage {
|
||||
let flags2 = messageData.flags2
|
||||
if (flags2 & (1 << 4)) != 0 {
|
||||
isScheduled = true
|
||||
}
|
||||
@@ -2120,7 +2121,7 @@ public final class PendingMessageManager {
|
||||
namespace = Namespaces.Message.QuickReplyCloud
|
||||
} else if let apiMessage = result.messages.first, message.scheduleTime != nil && message.scheduleTime == apiMessage.timestamp {
|
||||
namespace = Namespaces.Message.ScheduledCloud
|
||||
} else if let apiMessage = result.messages.first, case let .message(_, flags2, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) = apiMessage, (flags2 & (1 << 4)) != 0 {
|
||||
} else if let apiMessage = result.messages.first, case let .message(messageData) = apiMessage, (messageData.flags2 & (1 << 4)) != 0 {
|
||||
namespace = Namespaces.Message.ScheduledCloud
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ internal func _internal_updateIsPremiumRequiredToContact(account: Account, peerI
|
||||
flags.insert(.premiumRequired)
|
||||
sendPaidMessageStars = nil
|
||||
requirements[peerId] = .premium
|
||||
case let .requirementToContactPaidMessages(starsAmount):
|
||||
case let .requirementToContactPaidMessages(requirementToContactPaidMessagesData):
|
||||
let starsAmount = requirementToContactPaidMessagesData.starsAmount
|
||||
flags.remove(.premiumRequired)
|
||||
sendPaidMessageStars = StarsAmount(value: starsAmount, nanos: 0)
|
||||
requirements[peerId] = .stars(StarsAmount(value: starsAmount, nanos: 0))
|
||||
|
||||
@@ -147,7 +147,8 @@ func _internal_resetAccountState(postbox: Postbox, network: Network, accountPeer
|
||||
|
||||
if let currentState = transaction.getState() as? AuthorizedAccountState {
|
||||
switch state {
|
||||
case let .state(pts, qts, date, seq, _):
|
||||
case let .state(stateData):
|
||||
let (pts, qts, date, seq) = (stateData.pts, stateData.qts, stateData.date, stateData.seq)
|
||||
transaction.setState(currentState.changedState(AuthorizedAccountState.State(pts: pts, qts: qts, date: date, seq: seq)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,13 +168,15 @@ func managedSynchronizeSavedMessageTags(postbox: Postbox, network: Network, acco
|
||||
switch result {
|
||||
case .savedReactionTagsNotModified:
|
||||
return .complete()
|
||||
case let .savedReactionTags(tags, hash):
|
||||
case let .savedReactionTags(savedReactionTagsData):
|
||||
let (tags, hash) = (savedReactionTagsData.tags, savedReactionTagsData.hash)
|
||||
var customFileIds: [Int64] = []
|
||||
|
||||
var parsedTags: [SavedMessageTags.Tag] = []
|
||||
for tag in tags {
|
||||
switch tag {
|
||||
case let .savedReactionTag(_, reaction, title, count):
|
||||
case let .savedReactionTag(savedReactionTagData):
|
||||
let (_, reaction, title, count) = (savedReactionTagData.flags, savedReactionTagData.reaction, savedReactionTagData.title, savedReactionTagData.count)
|
||||
guard let reaction = MessageReaction.Reaction(apiReaction: reaction) else {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
|
||||
|
||||
public class Serialization: NSObject, MTSerialization {
|
||||
public func currentLayer() -> UInt {
|
||||
return 221
|
||||
return 222
|
||||
}
|
||||
|
||||
public func parseMessage(_ data: Data!) -> Any! {
|
||||
@@ -227,7 +227,8 @@ public class Serialization: NSObject, MTSerialization {
|
||||
return { data -> MTExportedAuthorizationData? in
|
||||
if let exported = functionContext.2.parse(Buffer(data: data)) {
|
||||
switch exported {
|
||||
case let .exportedAuthorization(id, bytes):
|
||||
case let .exportedAuthorization(exportedAuthorizationData):
|
||||
let (id, bytes) = (exportedAuthorizationData.id, exportedAuthorizationData.bytes)
|
||||
return MTExportedAuthorizationData(authorizationBytes: bytes.makeData(), authorizationId: id)
|
||||
}
|
||||
} else {
|
||||
@@ -246,11 +247,13 @@ public class Serialization: NSObject, MTSerialization {
|
||||
return { response -> MTDatacenterAddressListData? in
|
||||
if let config = parser.parse(Buffer(data: response)) {
|
||||
switch config {
|
||||
case let .config(_, _, _, _, _, dcOptions, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
|
||||
case let .config(configData):
|
||||
let dcOptions = configData.dcOptions
|
||||
var addressDict: [NSNumber: [Any]] = [:]
|
||||
for option in dcOptions {
|
||||
switch option {
|
||||
case let .dcOption(flags, id, ipAddress, port, secret):
|
||||
case let .dcOption(dcOptionData):
|
||||
let (flags, id, ipAddress, port, secret) = (dcOptionData.flags, dcOptionData.id, dcOptionData.ipAddress, dcOptionData.port, dcOptionData.secret)
|
||||
if addressDict[id as NSNumber] == nil {
|
||||
addressDict[id as NSNumber] = []
|
||||
}
|
||||
|
||||
@@ -65,14 +65,16 @@ func resolveMissingStickerSets(network: Network, postbox: Postbox, stickerSets:
|
||||
var missingSignals: [Signal<(Int, Api.StickerSetCovered)?, NoError>] = []
|
||||
for i in 0 ..< stickerSets.count {
|
||||
switch stickerSets[i] {
|
||||
case let .stickerSetNoCovered(value), let .stickerSetCovered(value, _):
|
||||
case let .stickerSetNoCovered(stickerSetNoCoveredData):
|
||||
let value = stickerSetNoCoveredData.set
|
||||
switch value {
|
||||
case let .stickerSet(_, _, id, accessHash, _, _, _, _, _, _, _, hash):
|
||||
case let .stickerSet(stickerSetData):
|
||||
let (id, accessHash, hash) = (stickerSetData.id, stickerSetData.accessHash, stickerSetData.hash)
|
||||
if ignorePacksWithHashes[id] == hash {
|
||||
continue
|
||||
}
|
||||
|
||||
missingSignals.append(network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(id: id, accessHash: accessHash), hash: 0))
|
||||
|
||||
missingSignals.append(network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(.init(id: id, accessHash: accessHash)), hash: 0))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.messages.StickerSet?, NoError> in
|
||||
return .single(nil)
|
||||
@@ -80,8 +82,37 @@ func resolveMissingStickerSets(network: Network, postbox: Postbox, stickerSets:
|
||||
|> map { result -> (Int, Api.StickerSetCovered)? in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .stickerSet(set, packs, keywords, documents):
|
||||
return (i, Api.StickerSetCovered.stickerSetFullCovered(set: set, packs: packs, keywords: keywords, documents: documents))
|
||||
case let .stickerSet(stickerSetData):
|
||||
let (set, packs, keywords, documents) = (stickerSetData.set, stickerSetData.packs, stickerSetData.keywords, stickerSetData.documents)
|
||||
return (i, Api.StickerSetCovered.stickerSetFullCovered(.init(set: set, packs: packs, keywords: keywords, documents: documents)))
|
||||
case .stickerSetNotModified:
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
})
|
||||
}
|
||||
case let .stickerSetCovered(stickerSetCoveredData):
|
||||
let value = stickerSetCoveredData.set
|
||||
switch value {
|
||||
case let .stickerSet(stickerSetData):
|
||||
let (id, accessHash, hash) = (stickerSetData.id, stickerSetData.accessHash, stickerSetData.hash)
|
||||
if ignorePacksWithHashes[id] == hash {
|
||||
continue
|
||||
}
|
||||
|
||||
missingSignals.append(network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(.init(id: id, accessHash: accessHash)), hash: 0))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.messages.StickerSet?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> map { result -> (Int, Api.StickerSetCovered)? in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .stickerSet(stickerSetData):
|
||||
let (set, packs, keywords, documents) = (stickerSetData.set, stickerSetData.packs, stickerSetData.keywords, stickerSetData.documents)
|
||||
return (i, Api.StickerSetCovered.stickerSetFullCovered(.init(set: set, packs: packs, keywords: keywords, documents: documents)))
|
||||
case .stickerSetNotModified:
|
||||
return nil
|
||||
}
|
||||
@@ -142,7 +173,8 @@ func updatedFeaturedStickerPacks(network: Network, postbox: Postbox, category: F
|
||||
switch result {
|
||||
case .featuredStickersNotModified:
|
||||
return .single(.notModified)
|
||||
case let .featuredStickers(flags, _, _, sets, unread):
|
||||
case let .featuredStickers(featuredStickersData):
|
||||
let (flags, sets, unread) = (featuredStickersData.flags, featuredStickersData.sets, featuredStickersData.unread)
|
||||
return resolveMissingStickerSets(network: network, postbox: postbox, stickerSets: sets, ignorePacksWithHashes: initialPackMap.filter { $0.value.topItems.count > 1 }.mapValues({ item in
|
||||
item.info.hash
|
||||
}))
|
||||
@@ -179,7 +211,8 @@ func updatedFeaturedStickerPacks(network: Network, postbox: Postbox, category: F
|
||||
switch result {
|
||||
case .featuredStickersNotModified:
|
||||
return .single(.notModified)
|
||||
case let .featuredStickers(flags, _, _, sets, unread):
|
||||
case let .featuredStickers(featuredStickersData):
|
||||
let (flags, sets, unread) = (featuredStickersData.flags, featuredStickersData.sets, featuredStickersData.unread)
|
||||
return resolveMissingStickerSets(network: network, postbox: postbox, stickerSets: sets, ignorePacksWithHashes: initialPackMap.mapValues({ item in
|
||||
item.info.hash
|
||||
}))
|
||||
@@ -242,7 +275,8 @@ public func requestOldFeaturedStickerPacks(network: Network, postbox: Postbox, o
|
||||
switch result {
|
||||
case .featuredStickersNotModified:
|
||||
return []
|
||||
case let .featuredStickers(_, _, _, sets, unread):
|
||||
case let .featuredStickers(featuredStickersData):
|
||||
let (sets, unread) = (featuredStickersData.sets, featuredStickersData.unread)
|
||||
let unreadIds = Set(unread)
|
||||
var updatedPacks: [FeaturedStickerPackItem] = []
|
||||
for set in sets {
|
||||
@@ -288,14 +322,16 @@ public func preloadedFeaturedStickerSet(network: Network, postbox: Postbox, id:
|
||||
|
||||
func parsePreviewStickerSet(_ set: Api.StickerSetCovered, namespace: ItemCollectionId.Namespace) -> (StickerPackCollectionInfo, [StickerPackItem]) {
|
||||
switch set {
|
||||
case let .stickerSetCovered(set, cover):
|
||||
case let .stickerSetCovered(stickerSetCoveredData):
|
||||
let (set, cover) = (stickerSetCoveredData.set, stickerSetCoveredData.cover)
|
||||
let info = StickerPackCollectionInfo(apiSet: set, namespace: namespace)
|
||||
var items: [StickerPackItem] = []
|
||||
if let file = telegramMediaFileFromApiDocument(cover, altDocuments: []), let id = file.id {
|
||||
items.append(StickerPackItem(index: ItemCollectionItemIndex(index: 0, id: id.id), file: file, indexKeys: []))
|
||||
}
|
||||
return (info, items)
|
||||
case let .stickerSetMultiCovered(set, covers):
|
||||
case let .stickerSetMultiCovered(stickerSetMultiCoveredData):
|
||||
let (set, covers) = (stickerSetMultiCoveredData.set, stickerSetMultiCoveredData.covers)
|
||||
let info = StickerPackCollectionInfo(apiSet: set, namespace: namespace)
|
||||
var items: [StickerPackItem] = []
|
||||
for cover in covers {
|
||||
@@ -304,11 +340,13 @@ func parsePreviewStickerSet(_ set: Api.StickerSetCovered, namespace: ItemCollect
|
||||
}
|
||||
}
|
||||
return (info, items)
|
||||
case let .stickerSetFullCovered(set, packs, keywords, documents):
|
||||
case let .stickerSetFullCovered(stickerSetFullCoveredData):
|
||||
let (set, packs, keywords, documents) = (stickerSetFullCoveredData.set, stickerSetFullCoveredData.packs, stickerSetFullCoveredData.keywords, stickerSetFullCoveredData.documents)
|
||||
var indexKeysByFile: [MediaId: [MemoryBuffer]] = [:]
|
||||
for pack in packs {
|
||||
switch pack {
|
||||
case let .stickerPack(text, fileIds):
|
||||
case let .stickerPack(stickerPackData):
|
||||
let (text, fileIds) = (stickerPackData.emoticon, stickerPackData.documents)
|
||||
let key = ValueBoxKey(text).toMemoryBuffer()
|
||||
for fileId in fileIds {
|
||||
let mediaId = MediaId(namespace: Namespaces.Media.CloudFile, id: fileId)
|
||||
@@ -323,7 +361,8 @@ func parsePreviewStickerSet(_ set: Api.StickerSetCovered, namespace: ItemCollect
|
||||
}
|
||||
for keyword in keywords {
|
||||
switch keyword {
|
||||
case let .stickerKeyword(documentId, texts):
|
||||
case let .stickerKeyword(stickerKeywordData):
|
||||
let (documentId, texts) = (stickerKeywordData.documentId, stickerKeywordData.keyword)
|
||||
for text in texts {
|
||||
let key = ValueBoxKey(text).toMemoryBuffer()
|
||||
let mediaId = MediaId(namespace: Namespaces.Media.CloudFile, id: documentId)
|
||||
@@ -350,7 +389,8 @@ func parsePreviewStickerSet(_ set: Api.StickerSetCovered, namespace: ItemCollect
|
||||
}
|
||||
}
|
||||
return (info, items)
|
||||
case let .stickerSetNoCovered(set):
|
||||
case let .stickerSetNoCovered(stickerSetNoCoveredData):
|
||||
let set = stickerSetNoCoveredData.set
|
||||
let info = StickerPackCollectionInfo(apiSet: set, namespace: namespace)
|
||||
let items: [StickerPackItem] = []
|
||||
return (info, items)
|
||||
|
||||
@@ -47,11 +47,14 @@ private func dialogTopMessage(network: Network, postbox: Postbox, peerId: PeerId
|
||||
}
|
||||
let apiMessages: [Api.Message]
|
||||
switch result {
|
||||
case let .channelMessages(_, _, _, _, messages, _, _, _):
|
||||
case let .channelMessages(channelMessagesData):
|
||||
let messages = channelMessagesData.messages
|
||||
apiMessages = messages
|
||||
case let .messages(messages, _, _, _):
|
||||
case let .messages(messagesData):
|
||||
let messages = messagesData.messages
|
||||
apiMessages = messages
|
||||
case let .messagesSlice(_, _, _, _, _, messages, _, _, _):
|
||||
case let .messagesSlice(messagesSliceData):
|
||||
let messages = messagesSliceData.messages
|
||||
apiMessages = messages
|
||||
case .messagesNotModified:
|
||||
apiMessages = []
|
||||
@@ -74,11 +77,12 @@ private func dialogReadState(network: Network, postbox: Postbox, peerId: PeerId)
|
||||
|
||||
return inputPeer(postbox: postbox, peerId: peerId)
|
||||
|> mapToSignal { inputPeer -> Signal<(PeerReadState, PeerReadStateMarker)?, PeerReadStateValidationError> in
|
||||
return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeer(peer: inputPeer)]))
|
||||
return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeer(.init(peer: inputPeer))]))
|
||||
|> retryRequest
|
||||
|> mapToSignalPromotingError { result -> Signal<(PeerReadState, PeerReadStateMarker)?, PeerReadStateValidationError> in
|
||||
switch result {
|
||||
case let .peerDialogs(dialogs, _, _, _, state):
|
||||
case let .peerDialogs(peerDialogsData):
|
||||
let (dialogs, state) = (peerDialogsData.dialogs, peerDialogsData.state)
|
||||
if let dialog = dialogs.filter({ $0.peerId == peerId }).first {
|
||||
let apiTopMessage: Int32
|
||||
let apiReadInboxMaxId: Int32
|
||||
@@ -87,7 +91,8 @@ private func dialogReadState(network: Network, postbox: Postbox, peerId: PeerId)
|
||||
let apiMarkedUnread: Bool
|
||||
var apiChannelPts: Int32 = 0
|
||||
switch dialog {
|
||||
case let .dialog(flags, _, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, _, _, _, pts, _, _, _):
|
||||
case let .dialog(dialogData):
|
||||
let (flags, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, pts) = (dialogData.flags, dialogData.topMessage, dialogData.readInboxMaxId, dialogData.readOutboxMaxId, dialogData.unreadCount, dialogData.pts)
|
||||
apiTopMessage = topMessage
|
||||
apiReadInboxMaxId = readInboxMaxId
|
||||
apiReadOutboxMaxId = readOutboxMaxId
|
||||
@@ -107,7 +112,8 @@ private func dialogReadState(network: Network, postbox: Postbox, peerId: PeerId)
|
||||
} else {
|
||||
let pts: Int32
|
||||
switch state {
|
||||
case let .state(statePts, _, _, _, _):
|
||||
case let .state(stateData):
|
||||
let (statePts) = (stateData.pts)
|
||||
pts = statePts
|
||||
}
|
||||
|
||||
@@ -219,7 +225,7 @@ private func validatePeerReadState(network: Network, postbox: Postbox, stateMana
|
||||
}
|
||||
|
||||
private func pushPeerReadState(network: Network, postbox: Postbox, stateManager: AccountStateManager, peerId: PeerId, readState: PeerReadState) -> Signal<PeerReadState, PeerReadStateValidationError> {
|
||||
// GHOST MODE: Block read receipts (blue checkmarks) for non-secret chats
|
||||
// GHOST MODE: Keep local read state but skip server read receipts.
|
||||
if peerId.namespace != Namespaces.Peer.SecretChat && GhostModeManager.shared.shouldHideReadReceipts {
|
||||
return .single(readState)
|
||||
}
|
||||
@@ -244,10 +250,11 @@ private func pushPeerReadState(network: Network, postbox: Postbox, stateManager:
|
||||
return inputPeer(postbox: postbox, peerId: peerId)
|
||||
|> mapToSignal { inputPeer -> Signal<PeerReadState, PeerReadStateValidationError> in
|
||||
switch inputPeer {
|
||||
case let .inputPeerChannel(channelId, accessHash):
|
||||
case let .inputPeerChannel(inputPeerChannelData):
|
||||
let (channelId, accessHash) = (inputPeerChannelData.channelId, inputPeerChannelData.accessHash)
|
||||
switch readState {
|
||||
case let .idBased(maxIncomingReadId, _, _, _, markedUnread):
|
||||
var pushSignal: Signal<Void, NoError> = network.request(Api.functions.channels.readHistory(channel: Api.InputChannel.inputChannel(channelId: channelId, accessHash: accessHash), maxId: maxIncomingReadId))
|
||||
var pushSignal: Signal<Void, NoError> = network.request(Api.functions.channels.readHistory(channel: Api.InputChannel.inputChannel(.init(channelId: channelId, accessHash: accessHash)), maxId: maxIncomingReadId))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
@@ -256,7 +263,7 @@ private func pushPeerReadState(network: Network, postbox: Postbox, stateManager:
|
||||
}
|
||||
if markedUnread {
|
||||
pushSignal = pushSignal
|
||||
|> then(network.request(Api.functions.messages.markDialogUnread(flags: 1 << 0, parentPeer: nil, peer: .inputDialogPeer(peer: inputPeer)))
|
||||
|> then(network.request(Api.functions.messages.markDialogUnread(flags: 1 << 0, parentPeer: nil, peer: .inputDialogPeer(.init(peer: inputPeer))))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
@@ -285,16 +292,17 @@ private func pushPeerReadState(network: Network, postbox: Postbox, stateManager:
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .affectedMessages(pts, ptsCount):
|
||||
case let .affectedMessages(affectedMessagesData):
|
||||
let (pts, ptsCount) = (affectedMessagesData.pts, affectedMessagesData.ptsCount)
|
||||
stateManager.addUpdateGroups([.updatePts(pts: pts, ptsCount: ptsCount)])
|
||||
}
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
|
||||
|
||||
if markedUnread {
|
||||
pushSignal = pushSignal
|
||||
|> then(network.request(Api.functions.messages.markDialogUnread(flags: 1 << 0, parentPeer: nil, peer: .inputDialogPeer(peer: inputPeer)))
|
||||
|> then(network.request(Api.functions.messages.markDialogUnread(flags: 1 << 0, parentPeer: nil, peer: .inputDialogPeer(.init(peer: inputPeer))))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|
||||
@@ -75,11 +75,13 @@ public func addSavedSticker(postbox: Postbox, network: Network, file: TelegramMe
|
||||
switch result {
|
||||
case .stickerSetNotModified:
|
||||
break
|
||||
case let .stickerSet(_, packs, _, _):
|
||||
case let .stickerSet(stickerSetData):
|
||||
let packs = stickerSetData.packs
|
||||
var stringRepresentationsByFile: [MediaId: [String]] = [:]
|
||||
for pack in packs {
|
||||
switch pack {
|
||||
case let .stickerPack(text, fileIds):
|
||||
case let .stickerPack(stickerPackData):
|
||||
let (text, fileIds) = (stickerPackData.emoticon, stickerPackData.documents)
|
||||
for fileId in fileIds {
|
||||
let mediaId = MediaId(namespace: Namespaces.Media.CloudFile, id: fileId)
|
||||
if stringRepresentationsByFile[mediaId] == nil {
|
||||
|
||||
@@ -34,11 +34,14 @@ private final class UnauthorizedUpdateMessageService: NSObject, MTMessageService
|
||||
|
||||
func addUpdates(_ updates: Api.Updates) {
|
||||
switch updates {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
case let .updates(updatesData):
|
||||
let updates = updatesData.updates
|
||||
self.putNext(updates)
|
||||
case let .updatesCombined(updates, _, _, _, _, _):
|
||||
case let .updatesCombined(updatesCombinedData):
|
||||
let updates = updatesCombinedData.updates
|
||||
self.putNext(updates)
|
||||
case let .updateShort(update, _):
|
||||
case let .updateShort(updateShortData):
|
||||
let update = updateShortData.update
|
||||
self.putNext([update])
|
||||
case .updateShortChatMessage, .updateShortMessage, .updatesTooLong, .updateShortSentMessage:
|
||||
break
|
||||
@@ -90,12 +93,14 @@ final class UnauthorizedAccountStateManager {
|
||||
switch update {
|
||||
case .updateLoginToken:
|
||||
updateLoginToken()
|
||||
case let .updateServiceNotification(flags, _, _, message, _, _):
|
||||
case let .updateServiceNotification(updateServiceNotificationData):
|
||||
let (flags, message) = (updateServiceNotificationData.flags, updateServiceNotificationData.message)
|
||||
let popup = (flags & (1 << 0)) != 0
|
||||
if popup {
|
||||
displayServiceNotification(message)
|
||||
}
|
||||
case let .updateSentPhoneCode(sentCode):
|
||||
case let .updateSentPhoneCode(updateSentPhoneCodeData):
|
||||
let sentCode = updateSentPhoneCodeData.sentCode
|
||||
updateSentCode(sentCode)
|
||||
default:
|
||||
break
|
||||
|
||||
@@ -60,27 +60,36 @@ enum UpdateGroup {
|
||||
|
||||
func apiUpdatePtsRange(_ update: Api.Update) -> (Int32, Int32)? {
|
||||
switch update {
|
||||
case let .updateDeleteMessages(_, pts, ptsCount):
|
||||
case let .updateDeleteMessages(updateDeleteMessagesData):
|
||||
let (pts, ptsCount) = (updateDeleteMessagesData.pts, updateDeleteMessagesData.ptsCount)
|
||||
return (pts, ptsCount)
|
||||
case let .updateNewMessage(_, pts, ptsCount):
|
||||
case let .updateNewMessage(updateNewMessageData):
|
||||
let (pts, ptsCount) = (updateNewMessageData.pts, updateNewMessageData.ptsCount)
|
||||
return (pts, ptsCount)
|
||||
case let .updateReadHistoryInbox(_, _, _, _, _, _, pts, ptsCount):
|
||||
case let .updateReadHistoryInbox(updateReadHistoryInboxData):
|
||||
let (pts, ptsCount) = (updateReadHistoryInboxData.pts, updateReadHistoryInboxData.ptsCount)
|
||||
return (pts, ptsCount)
|
||||
case let .updateReadHistoryOutbox(_, _, pts, ptsCount):
|
||||
case let .updateReadHistoryOutbox(updateReadHistoryOutboxData):
|
||||
let (pts, ptsCount) = (updateReadHistoryOutboxData.pts, updateReadHistoryOutboxData.ptsCount)
|
||||
return (pts, ptsCount)
|
||||
case let .updateEditMessage(_, pts, ptsCount):
|
||||
case let .updateEditMessage(updateEditMessageData):
|
||||
let (pts, ptsCount) = (updateEditMessageData.pts, updateEditMessageData.ptsCount)
|
||||
return (pts, ptsCount)
|
||||
case let .updateReadMessagesContents(_, _, pts, ptsCount, _):
|
||||
case let .updateReadMessagesContents(updateReadMessagesContentsData):
|
||||
let (pts, ptsCount) = (updateReadMessagesContentsData.pts, updateReadMessagesContentsData.ptsCount)
|
||||
return (pts, ptsCount)
|
||||
case let .updateWebPage(_, pts, ptsCount):
|
||||
case let .updateWebPage(updateWebPageData):
|
||||
let (pts, ptsCount) = (updateWebPageData.pts, updateWebPageData.ptsCount)
|
||||
return (pts, ptsCount)
|
||||
case let .updateFolderPeers(_, pts, ptsCount):
|
||||
case let .updateFolderPeers(updateFolderPeersData):
|
||||
let (pts, ptsCount) = (updateFolderPeersData.pts, updateFolderPeersData.ptsCount)
|
||||
if ptsCount != 0 {
|
||||
return (pts, ptsCount)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
case let .updatePinnedMessages(_, _, _, pts, ptsCount):
|
||||
case let .updatePinnedMessages(updatePinnedMessagesData):
|
||||
let (pts, ptsCount) = (updatePinnedMessagesData.pts, updatePinnedMessagesData.ptsCount)
|
||||
return (pts, ptsCount)
|
||||
default:
|
||||
return nil
|
||||
@@ -89,7 +98,8 @@ func apiUpdatePtsRange(_ update: Api.Update) -> (Int32, Int32)? {
|
||||
|
||||
func apiUpdateQtsRange(_ update: Api.Update) -> (Int32, Int32)? {
|
||||
switch update {
|
||||
case let .updateNewEncryptedMessage(_, qts):
|
||||
case let .updateNewEncryptedMessage(updateNewEncryptedMessageData):
|
||||
let qts = updateNewEncryptedMessageData.qts
|
||||
return (qts, 1)
|
||||
case _:
|
||||
return nil
|
||||
|
||||
@@ -42,47 +42,53 @@ class UpdateMessageService: NSObject, MTMessageService {
|
||||
|
||||
func addUpdates(_ updates: Api.Updates) {
|
||||
switch updates {
|
||||
case let .updates(updates, users, chats, date, seq):
|
||||
case let .updates(updatesData):
|
||||
let (updates, users, chats, date, seq) = (updatesData.updates, updatesData.users, updatesData.chats, updatesData.date, updatesData.seq)
|
||||
let groups = groupUpdates(updates, users: users, chats: chats, date: date, seqRange: seq == 0 ? nil : (seq, 1))
|
||||
if groups.count != 0 {
|
||||
self.putNext(groups)
|
||||
}
|
||||
case let .updatesCombined(updates, users, chats, date, seqStart, seq):
|
||||
case let .updatesCombined(updatesCombinedData):
|
||||
let (updates, users, chats, date, seqStart, seq) = (updatesCombinedData.updates, updatesCombinedData.users, updatesCombinedData.chats, updatesCombinedData.date, updatesCombinedData.seqStart, updatesCombinedData.seq)
|
||||
let groups = groupUpdates(updates, users: users, chats: chats, date: date, seqRange: seq == 0 ? nil : (seq, seq - seqStart))
|
||||
if groups.count != 0 {
|
||||
self.putNext(groups)
|
||||
}
|
||||
case let .updateShort(update, date):
|
||||
case let .updateShort(updateShortData):
|
||||
let (update, date) = (updateShortData.update, updateShortData.date)
|
||||
let groups = groupUpdates([update], users: [], chats: [], date: date, seqRange: nil)
|
||||
if groups.count != 0 {
|
||||
self.putNext(groups)
|
||||
}
|
||||
case let .updateShortChatMessage(flags, id, fromId, chatId, message, pts, ptsCount, date, fwdFrom, viaBotId, replyHeader, entities, ttlPeriod):
|
||||
let generatedMessage = Api.Message.message(flags: flags, flags2: 0, id: id, fromId: .peerUser(userId: fromId), fromBoostsApplied: nil, peerId: Api.Peer.peerChat(chatId: chatId), savedPeerId: nil, fwdFrom: fwdFrom, viaBotId: viaBotId, viaBusinessBotId: nil, replyTo: replyHeader, date: date, message: message, media: Api.MessageMedia.messageMediaEmpty, replyMarkup: nil, entities: entities, views: nil, forwards: nil, replies: nil, editDate: nil, postAuthor: nil, groupedId: nil, reactions: nil, restrictionReason: nil, ttlPeriod: ttlPeriod, quickReplyShortcutId: nil, effect: nil, factcheck: nil, reportDeliveryUntilDate: nil, paidMessageStars: nil, suggestedPost: nil, scheduleRepeatPeriod: nil, summaryFromLanguage: nil)
|
||||
let update = Api.Update.updateNewMessage(message: generatedMessage, pts: pts, ptsCount: ptsCount)
|
||||
case let .updateShortChatMessage(updateShortChatMessageData):
|
||||
let (flags, id, fromId, chatId, message, pts, ptsCount, date, fwdFrom, viaBotId, replyHeader, entities, ttlPeriod) = (updateShortChatMessageData.flags, updateShortChatMessageData.id, updateShortChatMessageData.fromId, updateShortChatMessageData.chatId, updateShortChatMessageData.message, updateShortChatMessageData.pts, updateShortChatMessageData.ptsCount, updateShortChatMessageData.date, updateShortChatMessageData.fwdFrom, updateShortChatMessageData.viaBotId, updateShortChatMessageData.replyTo, updateShortChatMessageData.entities, updateShortChatMessageData.ttlPeriod)
|
||||
let generatedMessage = Api.Message.message(.init(flags: flags, flags2: 0, id: id, fromId: .peerUser(.init(userId: fromId)), fromBoostsApplied: nil, peerId: Api.Peer.peerChat(.init(chatId: chatId)), savedPeerId: nil, fwdFrom: fwdFrom, viaBotId: viaBotId, viaBusinessBotId: nil, replyTo: replyHeader, date: date, message: message, media: Api.MessageMedia.messageMediaEmpty, replyMarkup: nil, entities: entities, views: nil, forwards: nil, replies: nil, editDate: nil, postAuthor: nil, groupedId: nil, reactions: nil, restrictionReason: nil, ttlPeriod: ttlPeriod, quickReplyShortcutId: nil, effect: nil, factcheck: nil, reportDeliveryUntilDate: nil, paidMessageStars: nil, suggestedPost: nil, scheduleRepeatPeriod: nil, summaryFromLanguage: nil))
|
||||
let update = Api.Update.updateNewMessage(.init(message: generatedMessage, pts: pts, ptsCount: ptsCount))
|
||||
let groups = groupUpdates([update], users: [], chats: [], date: date, seqRange: nil)
|
||||
if groups.count != 0 {
|
||||
self.putNext(groups)
|
||||
}
|
||||
case let .updateShortMessage(flags, id, userId, message, pts, ptsCount, date, fwdFrom, viaBotId, replyHeader, entities, ttlPeriod):
|
||||
case let .updateShortMessage(updateShortMessageData):
|
||||
let (flags, id, userId, message, pts, ptsCount, date, fwdFrom, viaBotId, replyHeader, entities, ttlPeriod) = (updateShortMessageData.flags, updateShortMessageData.id, updateShortMessageData.userId, updateShortMessageData.message, updateShortMessageData.pts, updateShortMessageData.ptsCount, updateShortMessageData.date, updateShortMessageData.fwdFrom, updateShortMessageData.viaBotId, updateShortMessageData.replyTo, updateShortMessageData.entities, updateShortMessageData.ttlPeriod)
|
||||
let generatedFromId: Api.Peer
|
||||
if (Int(flags) & 1 << 1) != 0 {
|
||||
generatedFromId = Api.Peer.peerUser(userId: self.peerId.id._internalGetInt64Value())
|
||||
generatedFromId = Api.Peer.peerUser(.init(userId: self.peerId.id._internalGetInt64Value()))
|
||||
} else {
|
||||
generatedFromId = Api.Peer.peerUser(userId: userId)
|
||||
generatedFromId = Api.Peer.peerUser(.init(userId: userId))
|
||||
}
|
||||
|
||||
let generatedPeerId = Api.Peer.peerUser(userId: userId)
|
||||
|
||||
let generatedMessage = Api.Message.message(flags: flags, flags2: 0, id: id, fromId: generatedFromId, fromBoostsApplied: nil, peerId: generatedPeerId, savedPeerId: nil, fwdFrom: fwdFrom, viaBotId: viaBotId, viaBusinessBotId: nil, replyTo: replyHeader, date: date, message: message, media: Api.MessageMedia.messageMediaEmpty, replyMarkup: nil, entities: entities, views: nil, forwards: nil, replies: nil, editDate: nil, postAuthor: nil, groupedId: nil, reactions: nil, restrictionReason: nil, ttlPeriod: ttlPeriod, quickReplyShortcutId: nil, effect: nil, factcheck: nil, reportDeliveryUntilDate: nil, paidMessageStars: nil, suggestedPost: nil, scheduleRepeatPeriod: nil, summaryFromLanguage: nil)
|
||||
let update = Api.Update.updateNewMessage(message: generatedMessage, pts: pts, ptsCount: ptsCount)
|
||||
|
||||
let generatedPeerId = Api.Peer.peerUser(.init(userId: userId))
|
||||
|
||||
let generatedMessage = Api.Message.message(.init(flags: flags, flags2: 0, id: id, fromId: generatedFromId, fromBoostsApplied: nil, peerId: generatedPeerId, savedPeerId: nil, fwdFrom: fwdFrom, viaBotId: viaBotId, viaBusinessBotId: nil, replyTo: replyHeader, date: date, message: message, media: Api.MessageMedia.messageMediaEmpty, replyMarkup: nil, entities: entities, views: nil, forwards: nil, replies: nil, editDate: nil, postAuthor: nil, groupedId: nil, reactions: nil, restrictionReason: nil, ttlPeriod: ttlPeriod, quickReplyShortcutId: nil, effect: nil, factcheck: nil, reportDeliveryUntilDate: nil, paidMessageStars: nil, suggestedPost: nil, scheduleRepeatPeriod: nil, summaryFromLanguage: nil))
|
||||
let update = Api.Update.updateNewMessage(.init(message: generatedMessage, pts: pts, ptsCount: ptsCount))
|
||||
let groups = groupUpdates([update], users: [], chats: [], date: date, seqRange: nil)
|
||||
if groups.count != 0 {
|
||||
self.putNext(groups)
|
||||
}
|
||||
case .updatesTooLong:
|
||||
self.pipe.putNext([.reset])
|
||||
case let .updateShortSentMessage(_, _, pts, ptsCount, _, _, _, _):
|
||||
case let .updateShortSentMessage(updateShortSentMessageData):
|
||||
let (pts, ptsCount) = (updateShortSentMessageData.pts, updateShortSentMessageData.ptsCount)
|
||||
self.pipe.putNext([.updatePts(pts: pts, ptsCount: ptsCount)])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ import TelegramApi
|
||||
|
||||
private func collectPreCachedResources(for photo: Api.Photo) -> [(MediaResource, Data)]? {
|
||||
switch photo {
|
||||
case let .photo(_, id, accessHash, fileReference, _, sizes, _, dcId):
|
||||
case let .photo(photoData):
|
||||
let (id, accessHash, fileReference, sizes, dcId) = (photoData.id, photoData.accessHash, photoData.fileReference, photoData.sizes, photoData.dcId)
|
||||
for size in sizes {
|
||||
switch size {
|
||||
case let .photoCachedSize(type, _, _, bytes):
|
||||
case let .photoCachedSize(photoCachedSizeData):
|
||||
let (type, bytes) = (photoCachedSizeData.type, photoCachedSizeData.bytes)
|
||||
let resource = CloudPhotoSizeMediaResource(datacenterId: dcId, photoId: id, accessHash: accessHash, sizeSpec: type, size: nil, fileReference: fileReference.makeData())
|
||||
let data = bytes.makeData()
|
||||
return [(resource, data)]
|
||||
@@ -24,11 +26,13 @@ private func collectPreCachedResources(for photo: Api.Photo) -> [(MediaResource,
|
||||
|
||||
private func collectPreCachedResources(for document: Api.Document) -> [(MediaResource, Data)]? {
|
||||
switch document {
|
||||
case let .document(_, id, accessHash, fileReference, _, _, _, thumbs, _, dcId, _):
|
||||
case let .document(documentData):
|
||||
let (id, accessHash, fileReference, thumbs, dcId) = (documentData.id, documentData.accessHash, documentData.fileReference, documentData.thumbs, documentData.dcId)
|
||||
if let thumbs = thumbs {
|
||||
for thumb in thumbs {
|
||||
switch thumb {
|
||||
case let .photoCachedSize(type, _, _, bytes):
|
||||
case let .photoCachedSize(photoCachedSizeData):
|
||||
let (type, bytes) = (photoCachedSizeData.type, photoCachedSizeData.bytes)
|
||||
let resource = CloudDocumentSizeMediaResource(datacenterId: dcId, documentId: id, accessHash: accessHash, sizeSpec: type, fileReference: fileReference.makeData())
|
||||
let data = bytes.makeData()
|
||||
return [(resource, data)]
|
||||
@@ -46,22 +50,25 @@ private func collectPreCachedResources(for document: Api.Document) -> [(MediaRes
|
||||
extension Api.MessageMedia {
|
||||
var preCachedResources: [(MediaResource, Data)]? {
|
||||
switch self {
|
||||
case let .messageMediaPhoto(_, photo, _):
|
||||
case let .messageMediaPhoto(messageMediaPhotoData):
|
||||
let photo = messageMediaPhotoData.photo
|
||||
if let photo = photo {
|
||||
return collectPreCachedResources(for: photo)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
case let .messageMediaDocument(_, document, _, _, _, _):
|
||||
case let .messageMediaDocument(messageMediaDocumentData):
|
||||
let document = messageMediaDocumentData.document
|
||||
if let document = document {
|
||||
return collectPreCachedResources(for: document)
|
||||
}
|
||||
return nil
|
||||
case let .messageMediaWebPage(flags, webPage):
|
||||
let _ = flags
|
||||
case let .messageMediaWebPage(messageMediaWebPageData):
|
||||
let webpage = messageMediaWebPageData.webpage
|
||||
var result: [(MediaResource, Data)]?
|
||||
switch webPage {
|
||||
case let .webPage(_, _, _, _, _, _, _, _, _, photo, _, _, _, _, _, _, document, _, _):
|
||||
switch webpage {
|
||||
case let .webPage(webPageData):
|
||||
let (photo, document) = (webPageData.photo, webPageData.document)
|
||||
if let photo = photo {
|
||||
if let photoResult = collectPreCachedResources(for: photo) {
|
||||
if result == nil {
|
||||
@@ -89,9 +96,10 @@ extension Api.MessageMedia {
|
||||
|
||||
var preCachedStories: [StoryId: Api.StoryItem]? {
|
||||
switch self {
|
||||
case let .messageMediaStory(_, peerId, id, story):
|
||||
case let .messageMediaStory(messageMediaStoryData):
|
||||
let (peer, id, story) = (messageMediaStoryData.peer, messageMediaStoryData.id, messageMediaStoryData.story)
|
||||
if let story = story {
|
||||
return [StoryId(peerId: peerId.peerId, id: id): story]
|
||||
return [StoryId(peerId: peer.peerId, id: id): story]
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@@ -104,31 +112,37 @@ extension Api.MessageMedia {
|
||||
extension Api.Message {
|
||||
var rawId: Int32 {
|
||||
switch self {
|
||||
case let .message(_, _, id, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
|
||||
case let .message(messageData):
|
||||
let id = messageData.id
|
||||
return id
|
||||
case let .messageEmpty(_, id, _):
|
||||
case let .messageEmpty(messageEmptyData):
|
||||
let id = messageEmptyData.id
|
||||
return id
|
||||
case let .messageService(_, id, _, _, _, _, _, _, _, _):
|
||||
case let .messageService(messageServiceData):
|
||||
let id = messageServiceData.id
|
||||
return id
|
||||
}
|
||||
}
|
||||
|
||||
func id(namespace: MessageId.Namespace = Namespaces.Message.Cloud) -> MessageId? {
|
||||
switch self {
|
||||
case let .message(_, flags2, id, _, _, messagePeerId, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
|
||||
case let .message(messageData):
|
||||
let (flags2, id, messagePeerId) = (messageData.flags2, messageData.id, messageData.peerId)
|
||||
var namespace = namespace
|
||||
if (flags2 & (1 << 4)) != 0 {
|
||||
namespace = Namespaces.Message.ScheduledCloud
|
||||
}
|
||||
let peerId: PeerId = messagePeerId.peerId
|
||||
return MessageId(peerId: peerId, namespace: namespace, id: id)
|
||||
case let .messageEmpty(_, id, peerId):
|
||||
case let .messageEmpty(messageEmptyData):
|
||||
let (id, peerId) = (messageEmptyData.id, messageEmptyData.peerId)
|
||||
if let peerId = peerId {
|
||||
return MessageId(peerId: peerId.peerId, namespace: Namespaces.Message.Cloud, id: id)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
case let .messageService(_, id, _, chatPeerId, _, _, _, _, _, _):
|
||||
case let .messageService(messageServiceData):
|
||||
let (id, chatPeerId) = (messageServiceData.id, messageServiceData.peerId)
|
||||
let peerId: PeerId = chatPeerId.peerId
|
||||
return MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: id)
|
||||
}
|
||||
@@ -136,12 +150,15 @@ extension Api.Message {
|
||||
|
||||
var peerId: PeerId? {
|
||||
switch self {
|
||||
case let .message(_, _, _, _, _, messagePeerId, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
|
||||
case let .message(messageData):
|
||||
let messagePeerId = messageData.peerId
|
||||
let peerId: PeerId = messagePeerId.peerId
|
||||
return peerId
|
||||
case let .messageEmpty(_, _, peerId):
|
||||
case let .messageEmpty(messageEmptyData):
|
||||
let peerId = messageEmptyData.peerId
|
||||
return peerId?.peerId
|
||||
case let .messageService(_, _, _, chatPeerId, _, _, _, _, _, _):
|
||||
case let .messageService(messageServiceData):
|
||||
let chatPeerId = messageServiceData.peerId
|
||||
let peerId: PeerId = chatPeerId.peerId
|
||||
return peerId
|
||||
}
|
||||
@@ -149,9 +166,11 @@ extension Api.Message {
|
||||
|
||||
var timestamp: Int32? {
|
||||
switch self {
|
||||
case let .message(_, _, _, _, _, _, _, _, _, _, _, date, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
|
||||
case let .message(messageData):
|
||||
let date = messageData.date
|
||||
return date
|
||||
case let .messageService(_, _, _, _, _, _, date, _, _, _):
|
||||
case let .messageService(messageServiceData):
|
||||
let date = messageServiceData.date
|
||||
return date
|
||||
case .messageEmpty:
|
||||
return nil
|
||||
@@ -160,16 +179,18 @@ extension Api.Message {
|
||||
|
||||
var preCachedResources: [(MediaResource, Data)]? {
|
||||
switch self {
|
||||
case let .message(_, _, _, _, _, _, _, _, _, _, _, _, _, media, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
|
||||
case let .message(messageData):
|
||||
let media = messageData.media
|
||||
return media?.preCachedResources
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var preCachedStories: [StoryId: Api.StoryItem]? {
|
||||
switch self {
|
||||
case let .message(_, _, _, _, _, _, _, _, _, _, _, _, _, media, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
|
||||
case let .message(messageData):
|
||||
let media = messageData.media
|
||||
return media?.preCachedStories
|
||||
default:
|
||||
return nil
|
||||
@@ -180,15 +201,20 @@ extension Api.Message {
|
||||
extension Api.Chat {
|
||||
var peerId: PeerId {
|
||||
switch self {
|
||||
case let .chat(_, id, _, _, _, _, _, _, _, _):
|
||||
case let .chat(chatData):
|
||||
let id = chatData.id
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(id))
|
||||
case let .chatEmpty(id):
|
||||
case let .chatEmpty(chatEmptyData):
|
||||
let id = chatEmptyData.id
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(id))
|
||||
case let .chatForbidden(id, _):
|
||||
case let .chatForbidden(chatForbiddenData):
|
||||
let id = chatForbiddenData.id
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(id))
|
||||
case let .channel(_, _, id, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
|
||||
case let .channel(channelData):
|
||||
let id = channelData.id
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(id))
|
||||
case let .channelForbidden(_, id, _, _, _):
|
||||
case let .channelForbidden(channelForbiddenData):
|
||||
let id = channelForbiddenData.id
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(id))
|
||||
}
|
||||
}
|
||||
@@ -197,9 +223,11 @@ extension Api.Chat {
|
||||
extension Api.User {
|
||||
var peerId: PeerId {
|
||||
switch self {
|
||||
case let .user(_, _, id, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
|
||||
case let .user(userData):
|
||||
let id = userData.id
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))
|
||||
case let .userEmpty(id):
|
||||
case let .userEmpty(userEmptyData):
|
||||
let id = userEmptyData.id
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))
|
||||
}
|
||||
}
|
||||
@@ -208,11 +236,14 @@ extension Api.User {
|
||||
extension Api.Peer {
|
||||
var peerId: PeerId {
|
||||
switch self {
|
||||
case let .peerChannel(channelId):
|
||||
case let .peerChannel(peerChannelData):
|
||||
let channelId = peerChannelData.channelId
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
case let .peerChat(chatId):
|
||||
case let .peerChat(peerChatData):
|
||||
let chatId = peerChatData.chatId
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))
|
||||
case let .peerUser(userId):
|
||||
case let .peerUser(peerUserData):
|
||||
let userId = peerUserData.userId
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
|
||||
}
|
||||
}
|
||||
@@ -221,8 +252,8 @@ extension Api.Peer {
|
||||
extension Api.Dialog {
|
||||
var peerId: PeerId? {
|
||||
switch self {
|
||||
case let .dialog(_, peer, _, _, _, _, _, _, _, _, _, _, _):
|
||||
return peer.peerId
|
||||
case let .dialog(dialogData):
|
||||
return dialogData.peer.peerId
|
||||
case .dialogFolder:
|
||||
return nil
|
||||
}
|
||||
@@ -232,11 +263,14 @@ extension Api.Dialog {
|
||||
extension Api.Update {
|
||||
var rawMessageId: Int32? {
|
||||
switch self {
|
||||
case let .updateMessageID(id, _):
|
||||
case let .updateMessageID(updateMessageIDData):
|
||||
let id = updateMessageIDData.id
|
||||
return id
|
||||
case let .updateNewMessage(message, _, _):
|
||||
case let .updateNewMessage(updateNewMessageData):
|
||||
let message = updateNewMessageData.message
|
||||
return message.rawId
|
||||
case let .updateNewChannelMessage(message, _, _):
|
||||
case let .updateNewChannelMessage(updateNewChannelMessageData):
|
||||
let message = updateNewChannelMessageData.message
|
||||
return message.rawId
|
||||
default:
|
||||
return nil
|
||||
@@ -245,7 +279,8 @@ extension Api.Update {
|
||||
|
||||
var updatedRawMessageId: (Int64, Int32)? {
|
||||
switch self {
|
||||
case let .updateMessageID(id, randomId):
|
||||
case let .updateMessageID(updateMessageIDData):
|
||||
let (id, randomId) = (updateMessageIDData.id, updateMessageIDData.randomId)
|
||||
return (randomId, id)
|
||||
default:
|
||||
return nil
|
||||
@@ -254,9 +289,11 @@ extension Api.Update {
|
||||
|
||||
var messageId: MessageId? {
|
||||
switch self {
|
||||
case let .updateNewMessage(message, _, _):
|
||||
case let .updateNewMessage(updateNewMessageData):
|
||||
let message = updateNewMessageData.message
|
||||
return message.id()
|
||||
case let .updateNewChannelMessage(message, _, _):
|
||||
case let .updateNewChannelMessage(updateNewChannelMessageData):
|
||||
let message = updateNewChannelMessageData.message
|
||||
return message.id()
|
||||
default:
|
||||
return nil
|
||||
@@ -265,17 +302,23 @@ extension Api.Update {
|
||||
|
||||
var message: Api.Message? {
|
||||
switch self {
|
||||
case let .updateNewMessage(message, _, _):
|
||||
case let .updateNewMessage(updateNewMessageData):
|
||||
let message = updateNewMessageData.message
|
||||
return message
|
||||
case let .updateNewChannelMessage(message, _, _):
|
||||
case let .updateNewChannelMessage(updateNewChannelMessageData):
|
||||
let message = updateNewChannelMessageData.message
|
||||
return message
|
||||
case let .updateEditMessage(message, _, _):
|
||||
case let .updateEditMessage(updateEditMessageData):
|
||||
let message = updateEditMessageData.message
|
||||
return message
|
||||
case let .updateEditChannelMessage(message, _, _):
|
||||
case let .updateEditChannelMessage(updateEditChannelMessageData):
|
||||
let message = updateEditChannelMessageData.message
|
||||
return message
|
||||
case let .updateNewScheduledMessage(message):
|
||||
case let .updateNewScheduledMessage(updateNewScheduledMessageData):
|
||||
let message = updateNewScheduledMessageData.message
|
||||
return message
|
||||
case let .updateQuickReplyMessage(message):
|
||||
case let .updateQuickReplyMessage(updateQuickReplyMessageData):
|
||||
let message = updateQuickReplyMessageData.message
|
||||
return message
|
||||
default:
|
||||
return nil
|
||||
@@ -284,63 +327,88 @@ extension Api.Update {
|
||||
|
||||
var peerIds: [PeerId] {
|
||||
switch self {
|
||||
case let .updateChannel(channelId):
|
||||
case let .updateChannel(updateChannelData):
|
||||
let channelId = updateChannelData.channelId
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))]
|
||||
case let .updateChat(chatId):
|
||||
case let .updateChat(updateChatData):
|
||||
let chatId = updateChatData.chatId
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))]
|
||||
case let .updateChannelTooLong(_, channelId, _):
|
||||
case let .updateChannelTooLong(updateChannelTooLongData):
|
||||
let channelId = updateChannelTooLongData.channelId
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))]
|
||||
case let .updateChatParticipantAdd(chatId, userId, inviterId, _, _):
|
||||
case let .updateChatParticipantAdd(updateChatParticipantAddData):
|
||||
let (chatId, userId, inviterId) = (updateChatParticipantAddData.chatId, updateChatParticipantAddData.userId, updateChatParticipantAddData.inviterId)
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(inviterId))]
|
||||
case let .updateChatParticipantAdmin(chatId, userId, _, _):
|
||||
case let .updateChatParticipantAdmin(updateChatParticipantAdminData):
|
||||
let (chatId, userId) = (updateChatParticipantAdminData.chatId, updateChatParticipantAdminData.userId)
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))]
|
||||
case let .updateChatParticipantDelete(chatId, userId, _):
|
||||
case let .updateChatParticipantDelete(updateChatParticipantDeleteData):
|
||||
let (chatId, userId) = (updateChatParticipantDeleteData.chatId, updateChatParticipantDeleteData.userId)
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))]
|
||||
case let .updateChatParticipants(participants):
|
||||
case let .updateChatParticipants(updateChatParticipantsData):
|
||||
let participants = updateChatParticipantsData.participants
|
||||
switch participants {
|
||||
case let .chatParticipants(chatId, _, _):
|
||||
case let .chatParticipants(chatParticipantsData):
|
||||
let chatId = chatParticipantsData.chatId
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))]
|
||||
case let .chatParticipantsForbidden(_, chatId, _):
|
||||
case let .chatParticipantsForbidden(chatParticipantsForbiddenData):
|
||||
let chatId = chatParticipantsForbiddenData.chatId
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))]
|
||||
}
|
||||
case let .updateDeleteChannelMessages(channelId, _, _, _):
|
||||
case let .updateDeleteChannelMessages(updateDeleteChannelMessagesData):
|
||||
let channelId = updateDeleteChannelMessagesData.channelId
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))]
|
||||
case let .updatePinnedChannelMessages(_, channelId, _, _, _):
|
||||
case let .updatePinnedChannelMessages(updatePinnedChannelMessagesData):
|
||||
let channelId = updatePinnedChannelMessagesData.channelId
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))]
|
||||
case let .updateNewChannelMessage(message, _, _):
|
||||
case let .updateNewChannelMessage(updateNewChannelMessageData):
|
||||
let message = updateNewChannelMessageData.message
|
||||
return apiMessagePeerIds(message)
|
||||
case let .updateEditChannelMessage(message, _, _):
|
||||
case let .updateEditChannelMessage(updateEditChannelMessageData):
|
||||
let message = updateEditChannelMessageData.message
|
||||
return apiMessagePeerIds(message)
|
||||
case let .updateChannelWebPage(channelId, _, _, _):
|
||||
case let .updateChannelWebPage(updateChannelWebPageData):
|
||||
let channelId = updateChannelWebPageData.channelId
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))]
|
||||
case let .updateNewMessage(message, _, _):
|
||||
case let .updateNewMessage(updateNewMessageData):
|
||||
let message = updateNewMessageData.message
|
||||
return apiMessagePeerIds(message)
|
||||
case let .updateEditMessage(message, _, _):
|
||||
case let .updateEditMessage(updateEditMessageData):
|
||||
let message = updateEditMessageData.message
|
||||
return apiMessagePeerIds(message)
|
||||
case let .updateReadChannelInbox(_, _, channelId, _, _, _):
|
||||
case let .updateReadChannelInbox(updateReadChannelInboxData):
|
||||
let channelId = updateReadChannelInboxData.channelId
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))]
|
||||
case let .updateNotifySettings(peer, _):
|
||||
case let .updateNotifySettings(updateNotifySettingsData):
|
||||
let peer = updateNotifySettingsData.peer
|
||||
switch peer {
|
||||
case let .notifyPeer(peer):
|
||||
case let .notifyPeer(notifyPeerData):
|
||||
let peer = notifyPeerData.peer
|
||||
return [peer.peerId]
|
||||
default:
|
||||
return []
|
||||
}
|
||||
case let .updateUserName(userId, _, _, _):
|
||||
case let .updateUserName(updateUserNameData):
|
||||
let userId = updateUserNameData.userId
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))]
|
||||
case let .updateUserPhone(userId, _):
|
||||
case let .updateUserPhone(updateUserPhoneData):
|
||||
let userId = updateUserPhoneData.userId
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))]
|
||||
case let .updateServiceNotification(_, inboxDate, _, _, _, _):
|
||||
case let .updateServiceNotification(updateServiceNotificationData):
|
||||
let inboxDate = updateServiceNotificationData.inboxDate
|
||||
if let _ = inboxDate {
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(777000))]
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
case let .updateDraftMessage(_, peer, _, _, _):
|
||||
case let .updateDraftMessage(updateDraftMessageData):
|
||||
let peer = updateDraftMessageData.peer
|
||||
return [peer.peerId]
|
||||
case let .updateNewScheduledMessage(message):
|
||||
case let .updateNewScheduledMessage(updateNewScheduledMessageData):
|
||||
let message = updateNewScheduledMessageData.message
|
||||
return apiMessagePeerIds(message)
|
||||
case let .updateQuickReplyMessage(message):
|
||||
case let .updateQuickReplyMessage(updateQuickReplyMessageData):
|
||||
let message = updateQuickReplyMessageData.message
|
||||
return apiMessagePeerIds(message)
|
||||
default:
|
||||
return []
|
||||
@@ -349,15 +417,20 @@ extension Api.Update {
|
||||
|
||||
var associatedMessageIds: (replyIds: ReferencedReplyMessageIds, generalIds: [MessageId])? {
|
||||
switch self {
|
||||
case let .updateNewMessage(message, _, _):
|
||||
case let .updateNewMessage(updateNewMessageData):
|
||||
let message = updateNewMessageData.message
|
||||
return apiMessageAssociatedMessageIds(message)
|
||||
case let .updateNewChannelMessage(message, _, _):
|
||||
case let .updateNewChannelMessage(updateNewChannelMessageData):
|
||||
let message = updateNewChannelMessageData.message
|
||||
return apiMessageAssociatedMessageIds(message)
|
||||
case let .updateEditChannelMessage(message, _, _):
|
||||
case let .updateEditChannelMessage(updateEditChannelMessageData):
|
||||
let message = updateEditChannelMessageData.message
|
||||
return apiMessageAssociatedMessageIds(message)
|
||||
case let .updateNewScheduledMessage(message):
|
||||
case let .updateNewScheduledMessage(updateNewScheduledMessageData):
|
||||
let message = updateNewScheduledMessageData.message
|
||||
return apiMessageAssociatedMessageIds(message)
|
||||
case let .updateQuickReplyMessage(message):
|
||||
case let .updateQuickReplyMessage(updateQuickReplyMessageData):
|
||||
let message = updateQuickReplyMessageData.message
|
||||
return apiMessageAssociatedMessageIds(message)
|
||||
default:
|
||||
break
|
||||
@@ -367,9 +440,11 @@ extension Api.Update {
|
||||
|
||||
var channelPts: Int32? {
|
||||
switch self {
|
||||
case let .updateNewChannelMessage(_, pts, _):
|
||||
case let .updateNewChannelMessage(updateNewChannelMessageData):
|
||||
let pts = updateNewChannelMessageData.pts
|
||||
return pts
|
||||
case let .updateEditChannelMessage(_, pts, _):
|
||||
case let .updateEditChannelMessage(updateEditChannelMessageData):
|
||||
let pts = updateEditChannelMessageData.pts
|
||||
return pts
|
||||
default:
|
||||
return nil
|
||||
@@ -380,11 +455,14 @@ extension Api.Update {
|
||||
extension Api.Updates {
|
||||
var allUpdates: [Api.Update] {
|
||||
switch self {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
case let .updates(updatesData):
|
||||
let updates = updatesData.updates
|
||||
return updates
|
||||
case let .updatesCombined(updates, _, _, _, _, _):
|
||||
case let .updatesCombined(updatesCombinedData):
|
||||
let updates = updatesCombinedData.updates
|
||||
return updates
|
||||
case let .updateShort(update, _):
|
||||
case let .updateShort(updateShortData):
|
||||
let update = updateShortData.update
|
||||
return [update]
|
||||
default:
|
||||
return []
|
||||
@@ -395,7 +473,8 @@ extension Api.Updates {
|
||||
extension Api.Updates {
|
||||
var rawMessageIds: [Int32] {
|
||||
switch self {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
case let .updates(updatesData):
|
||||
let updates = updatesData.updates
|
||||
var result: [Int32] = []
|
||||
for update in updates {
|
||||
if let id = update.rawMessageId {
|
||||
@@ -403,7 +482,8 @@ extension Api.Updates {
|
||||
}
|
||||
}
|
||||
return result
|
||||
case let .updatesCombined(updates, _, _, _, _, _):
|
||||
case let .updatesCombined(updatesCombinedData):
|
||||
let updates = updatesCombinedData.updates
|
||||
var result: [Int32] = []
|
||||
for update in updates {
|
||||
if let id = update.rawMessageId {
|
||||
@@ -411,26 +491,31 @@ extension Api.Updates {
|
||||
}
|
||||
}
|
||||
return result
|
||||
case let .updateShort(update, _):
|
||||
case let .updateShort(updateShortData):
|
||||
let update = updateShortData.update
|
||||
if let id = update.rawMessageId {
|
||||
return [id]
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
case let .updateShortSentMessage(_, id, _, _, _, _, _, _):
|
||||
case let .updateShortSentMessage(updateShortSentMessageData):
|
||||
let id = updateShortSentMessageData.id
|
||||
return [id]
|
||||
case .updatesTooLong:
|
||||
return []
|
||||
case let .updateShortMessage(_, id, _, _, _, _, _, _, _, _, _, _):
|
||||
case let .updateShortMessage(updateShortMessageData):
|
||||
let id = updateShortMessageData.id
|
||||
return [id]
|
||||
case let .updateShortChatMessage(_, id, _, _, _, _, _, _, _, _, _, _, _):
|
||||
case let .updateShortChatMessage(updateShortChatMessageData):
|
||||
let id = updateShortChatMessageData.id
|
||||
return [id]
|
||||
}
|
||||
}
|
||||
|
||||
var messageIds: [MessageId] {
|
||||
switch self {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
case let .updates(updatesData):
|
||||
let updates = updatesData.updates
|
||||
var result: [MessageId] = []
|
||||
for update in updates {
|
||||
if let id = update.messageId {
|
||||
@@ -438,7 +523,8 @@ extension Api.Updates {
|
||||
}
|
||||
}
|
||||
return result
|
||||
case let .updatesCombined(updates, _, _, _, _, _):
|
||||
case let .updatesCombined(updatesCombinedData):
|
||||
let updates = updatesCombinedData.updates
|
||||
var result: [MessageId] = []
|
||||
for update in updates {
|
||||
if let id = update.messageId {
|
||||
@@ -446,7 +532,8 @@ extension Api.Updates {
|
||||
}
|
||||
}
|
||||
return result
|
||||
case let .updateShort(update, _):
|
||||
case let .updateShort(updateShortData):
|
||||
let update = updateShortData.update
|
||||
if let id = update.messageId {
|
||||
return [id]
|
||||
} else {
|
||||
@@ -456,16 +543,19 @@ extension Api.Updates {
|
||||
return []
|
||||
case .updatesTooLong:
|
||||
return []
|
||||
case let .updateShortMessage(_, id, userId, _, _, _, _, _, _, _, _, _):
|
||||
case let .updateShortMessage(updateShortMessageData):
|
||||
let (id, userId) = (updateShortMessageData.id, updateShortMessageData.userId)
|
||||
return [MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), namespace: Namespaces.Message.Cloud, id: id)]
|
||||
case let .updateShortChatMessage(_, id, _, chatId, _, _, _, _, _, _, _, _, _):
|
||||
case let .updateShortChatMessage(updateShortChatMessageData):
|
||||
let (id, chatId) = (updateShortChatMessageData.id, updateShortChatMessageData.chatId)
|
||||
return [MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)), namespace: Namespaces.Message.Cloud, id: id)]
|
||||
}
|
||||
}
|
||||
|
||||
var updatedRawMessageIds: [Int64: Int32] {
|
||||
switch self {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
case let .updates(updatesData):
|
||||
let updates = updatesData.updates
|
||||
var result: [Int64: Int32] = [:]
|
||||
for update in updates {
|
||||
if let (randomId, id) = update.updatedRawMessageId {
|
||||
@@ -473,7 +563,8 @@ extension Api.Updates {
|
||||
}
|
||||
}
|
||||
return result
|
||||
case let .updatesCombined(updates, _, _, _, _, _):
|
||||
case let .updatesCombined(updatesCombinedData):
|
||||
let updates = updatesCombinedData.updates
|
||||
var result: [Int64: Int32] = [:]
|
||||
for update in updates {
|
||||
if let (randomId, id) = update.updatedRawMessageId {
|
||||
@@ -481,7 +572,8 @@ extension Api.Updates {
|
||||
}
|
||||
}
|
||||
return result
|
||||
case let .updateShort(update, _):
|
||||
case let .updateShort(updateShortData):
|
||||
let update = updateShortData.update
|
||||
if let (randomId, id) = update.updatedRawMessageId {
|
||||
return [randomId: id]
|
||||
} else {
|
||||
@@ -502,18 +594,21 @@ extension Api.Updates {
|
||||
extension Api.Updates {
|
||||
var users: [Api.User] {
|
||||
switch self {
|
||||
case let .updates(_, users, _, _, _):
|
||||
case let .updates(updatesData):
|
||||
let users = updatesData.users
|
||||
return users
|
||||
case let .updatesCombined(_, users, _, _, _, _):
|
||||
case let .updatesCombined(updatesCombinedData):
|
||||
let users = updatesCombinedData.users
|
||||
return users
|
||||
default:
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var messages: [Api.Message] {
|
||||
switch self {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
case let .updates(updatesData):
|
||||
let updates = updatesData.updates
|
||||
var result: [Api.Message] = []
|
||||
for update in updates {
|
||||
if let message = update.message {
|
||||
@@ -521,7 +616,8 @@ extension Api.Updates {
|
||||
}
|
||||
}
|
||||
return result
|
||||
case let .updatesCombined(updates, _, _, _, _, _):
|
||||
case let .updatesCombined(updatesCombinedData):
|
||||
let updates = updatesCombinedData.updates
|
||||
var result: [Api.Message] = []
|
||||
for update in updates {
|
||||
if let message = update.message {
|
||||
@@ -529,7 +625,8 @@ extension Api.Updates {
|
||||
}
|
||||
}
|
||||
return result
|
||||
case let .updateShort(update, _):
|
||||
case let .updateShort(updateShortData):
|
||||
let update = updateShortData.update
|
||||
if let message = update.message {
|
||||
return [message]
|
||||
} else {
|
||||
@@ -539,10 +636,11 @@ extension Api.Updates {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var channelPts: Int32? {
|
||||
switch self {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
case let .updates(updatesData):
|
||||
let updates = updatesData.updates
|
||||
var result: Int32?
|
||||
for update in updates {
|
||||
if let channelPts = update.channelPts {
|
||||
@@ -552,7 +650,8 @@ extension Api.Updates {
|
||||
}
|
||||
}
|
||||
return result
|
||||
case let .updatesCombined(updates, _, _, _, _, _):
|
||||
case let .updatesCombined(updatesCombinedData):
|
||||
let updates = updatesCombinedData.updates
|
||||
var result: Int32?
|
||||
for update in updates {
|
||||
if let channelPts = update.channelPts {
|
||||
@@ -562,7 +661,8 @@ extension Api.Updates {
|
||||
}
|
||||
}
|
||||
return result
|
||||
case let .updateShort(update, _):
|
||||
case let .updateShort(updateShortData):
|
||||
let update = updateShortData.update
|
||||
if let channelPts = update.channelPts {
|
||||
return channelPts
|
||||
} else {
|
||||
@@ -577,13 +677,15 @@ extension Api.Updates {
|
||||
extension Api.Updates {
|
||||
var chats: [Api.Chat] {
|
||||
switch self {
|
||||
case let .updates(_, _, chats, _, _):
|
||||
case let .updates(updatesData):
|
||||
let chats = updatesData.chats
|
||||
var result: [Api.Chat] = []
|
||||
for chat in chats {
|
||||
result.append(chat)
|
||||
}
|
||||
return result
|
||||
case let .updatesCombined(_, _, chats, _, _, _):
|
||||
case let .updatesCombined(updatesCombinedData):
|
||||
let chats = updatesCombinedData.chats
|
||||
var result: [Api.Chat] = []
|
||||
for chat in chats {
|
||||
result.append(chat)
|
||||
@@ -598,15 +700,20 @@ extension Api.Updates {
|
||||
extension Api.EncryptedChat {
|
||||
var peerId: PeerId {
|
||||
switch self {
|
||||
case let .encryptedChat(id, _, _, _, _, _, _):
|
||||
case let .encryptedChat(encryptedChatData):
|
||||
let id = encryptedChatData.id
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id)))
|
||||
case let .encryptedChatDiscarded(_, id):
|
||||
case let .encryptedChatDiscarded(encryptedChatDiscardedData):
|
||||
let id = encryptedChatDiscardedData.id
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id)))
|
||||
case let .encryptedChatEmpty(id):
|
||||
case let .encryptedChatEmpty(encryptedChatEmptyData):
|
||||
let id = encryptedChatEmptyData.id
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id)))
|
||||
case let .encryptedChatRequested(_, _, id, _, _, _, _, _):
|
||||
case let .encryptedChatRequested(encryptedChatRequestedData):
|
||||
let id = encryptedChatRequestedData.id
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id)))
|
||||
case let .encryptedChatWaiting(id, _, _, _, _):
|
||||
case let .encryptedChatWaiting(encryptedChatWaitingData):
|
||||
let id = encryptedChatWaitingData.id
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id)))
|
||||
}
|
||||
}
|
||||
@@ -615,9 +722,11 @@ extension Api.EncryptedChat {
|
||||
extension Api.EncryptedMessage {
|
||||
var peerId: PeerId {
|
||||
switch self {
|
||||
case let .encryptedMessage(_, chatId, _, _, _):
|
||||
case let .encryptedMessage(encryptedMessageData):
|
||||
let chatId = encryptedMessageData.chatId
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId)))
|
||||
case let .encryptedMessageService(_, chatId, _, _):
|
||||
case let .encryptedMessageService(encryptedMessageServiceData):
|
||||
let chatId = encryptedMessageServiceData.chatId
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId)))
|
||||
}
|
||||
}
|
||||
@@ -626,20 +735,22 @@ extension Api.EncryptedMessage {
|
||||
extension Api.InputMedia {
|
||||
func withUpdatedStickers(_ stickers: [Api.InputDocument]?) -> Api.InputMedia {
|
||||
switch self {
|
||||
case let .inputMediaUploadedDocument(flags, file, thumb, mimeType, attributes, _, videoCover, videoTimestamp, ttlSeconds):
|
||||
var flags = flags
|
||||
var attributes = attributes
|
||||
case let .inputMediaUploadedDocument(inputMediaUploadedDocumentData):
|
||||
let (apiFlags, file, thumb, mimeType, apiAttributes, videoCover, videoTimestamp, ttlSeconds) = (inputMediaUploadedDocumentData.flags, inputMediaUploadedDocumentData.file, inputMediaUploadedDocumentData.thumb, inputMediaUploadedDocumentData.mimeType, inputMediaUploadedDocumentData.attributes, inputMediaUploadedDocumentData.videoCover, inputMediaUploadedDocumentData.videoTimestamp, inputMediaUploadedDocumentData.ttlSeconds)
|
||||
var flags = apiFlags
|
||||
var attributes = apiAttributes
|
||||
if let _ = stickers {
|
||||
flags |= (1 << 0)
|
||||
attributes.append(.documentAttributeHasStickers)
|
||||
}
|
||||
return .inputMediaUploadedDocument(flags: flags, file: file, thumb: thumb, mimeType: mimeType, attributes: attributes, stickers: stickers, videoCover: videoCover, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds)
|
||||
case let .inputMediaUploadedPhoto(flags, file, _, ttlSeconds):
|
||||
var flags = flags
|
||||
return .inputMediaUploadedDocument(.init(flags: flags, file: file, thumb: thumb, mimeType: mimeType, attributes: attributes, stickers: stickers, videoCover: videoCover, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds))
|
||||
case let .inputMediaUploadedPhoto(inputMediaUploadedPhotoData):
|
||||
let (apiFlags, file, ttlSeconds) = (inputMediaUploadedPhotoData.flags, inputMediaUploadedPhotoData.file, inputMediaUploadedPhotoData.ttlSeconds)
|
||||
var flags = apiFlags
|
||||
if let _ = stickers {
|
||||
flags |= (1 << 0)
|
||||
}
|
||||
return .inputMediaUploadedPhoto(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds)
|
||||
return .inputMediaUploadedPhoto(.init(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds))
|
||||
default:
|
||||
return self
|
||||
}
|
||||
|
||||
@@ -32,10 +32,9 @@ public struct UserLimitsConfiguration: Equatable {
|
||||
|
||||
public static var defaultValue: UserLimitsConfiguration {
|
||||
return UserLimitsConfiguration(
|
||||
// GHOSTGRAM: Unlimited pinned chats bypass
|
||||
maxPinnedChatCount: 99,
|
||||
maxPinnedSavedChatCount: 99,
|
||||
maxArchivedPinnedChatCount: 99,
|
||||
maxPinnedChatCount: 5,
|
||||
maxPinnedSavedChatCount: 5,
|
||||
maxArchivedPinnedChatCount: 100,
|
||||
maxChannelsCount: 500,
|
||||
maxPublicLinksCount: 10,
|
||||
maxSavedGifCount: 200,
|
||||
@@ -146,10 +145,9 @@ extension UserLimitsConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
// GHOSTGRAM: Force unlimited pinned chats (ignore server limits)
|
||||
self.maxPinnedChatCount = 99
|
||||
self.maxPinnedSavedChatCount = 99
|
||||
self.maxArchivedPinnedChatCount = 99
|
||||
self.maxPinnedChatCount = getValue("dialogs_pinned_limit", orElse: defaultValue.maxPinnedChatCount)
|
||||
self.maxPinnedSavedChatCount = getValue("saved_dialogs_pinned_limit", orElse: defaultValue.maxPinnedSavedChatCount)
|
||||
self.maxArchivedPinnedChatCount = getValue("dialogs_folder_pinned_limit", orElse: defaultValue.maxArchivedPinnedChatCount)
|
||||
self.maxChannelsCount = getValue("channels_limit", orElse: defaultValue.maxChannelsCount)
|
||||
self.maxPublicLinksCount = getValue("channels_public_limit", orElse: defaultValue.maxPublicLinksCount)
|
||||
self.maxSavedGifCount = getValue("saved_gifs_limit", orElse: defaultValue.maxSavedGifCount)
|
||||
|
||||
Reference in New Issue
Block a user