mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Refactoring
This commit is contained in:
parent
bc108d8dc1
commit
1b48517f12
@ -619,7 +619,7 @@ class DefaultIntentHandler: INExtension, INSendMessageIntentHandling, INSearchFo
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (_, messageId) in maxMessageIdsToApply {
|
for (_, messageId) in maxMessageIdsToApply {
|
||||||
signals.append(applyMaxReadIndexInteractively(postbox: account.postbox, stateManager: account.stateManager, index: MessageIndex(id: messageId, timestamp: 0))
|
signals.append(TelegramEngine(account: account).messages.applyMaxReadIndexInteractively(index: MessageIndex(id: messageId, timestamp: 0))
|
||||||
|> castError(IntentHandlingError.self))
|
|> castError(IntentHandlingError.self))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ public final class BotCheckoutController: ViewController {
|
|||||||
"button_text_color": Int32(bitPattern: presentationData.theme.list.itemCheckColors.foregroundColor.argb)
|
"button_text_color": Int32(bitPattern: presentationData.theme.list.itemCheckColors.foregroundColor.argb)
|
||||||
]
|
]
|
||||||
|
|
||||||
return fetchBotPaymentForm(postbox: context.account.postbox, network: context.account.network, messageId: messageId, themeParams: themeParams)
|
return context.engine.payments.fetchBotPaymentForm(messageId: messageId, themeParams: themeParams)
|
||||||
|> mapError { _ -> FetchError in
|
|> mapError { _ -> FetchError in
|
||||||
return .generic
|
return .generic
|
||||||
}
|
}
|
||||||
|> mapToSignal { paymentForm -> Signal<InputData, FetchError> in
|
|> mapToSignal { paymentForm -> Signal<InputData, FetchError> in
|
||||||
if let current = paymentForm.savedInfo {
|
if let current = paymentForm.savedInfo {
|
||||||
return validateBotPaymentForm(account: context.account, saveInfo: true, messageId: messageId, formInfo: current)
|
return context.engine.payments.validateBotPaymentForm(saveInfo: true, messageId: messageId, formInfo: current)
|
||||||
|> mapError { _ -> FetchError in
|
|> mapError { _ -> FetchError in
|
||||||
return .generic
|
return .generic
|
||||||
}
|
}
|
||||||
|
@ -1229,7 +1229,7 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
|||||||
let totalAmount = currentTotalPrice(paymentForm: paymentForm, validatedFormInfo: self.currentValidatedFormInfo, currentShippingOptionId: self.currentShippingOptionId, currentTip: self.currentTipAmount)
|
let totalAmount = currentTotalPrice(paymentForm: paymentForm, validatedFormInfo: self.currentValidatedFormInfo, currentShippingOptionId: self.currentShippingOptionId, currentTip: self.currentTipAmount)
|
||||||
let currencyValue = formatCurrencyAmount(totalAmount, currency: paymentForm.invoice.currency)
|
let currencyValue = formatCurrencyAmount(totalAmount, currency: paymentForm.invoice.currency)
|
||||||
|
|
||||||
self.payDisposable.set((sendBotPaymentForm(account: self.context.account, messageId: self.messageId, formId: paymentForm.id, validatedInfoId: self.currentValidatedFormInfo?.id, shippingOptionId: self.currentShippingOptionId, tipAmount: tipAmount, credentials: credentials) |> deliverOnMainQueue).start(next: { [weak self] result in
|
self.payDisposable.set((self.context.engine.payments.sendBotPaymentForm(messageId: self.messageId, formId: paymentForm.id, validatedInfoId: self.currentValidatedFormInfo?.id, shippingOptionId: self.currentShippingOptionId, tipAmount: tipAmount, credentials: credentials) |> deliverOnMainQueue).start(next: { [weak self] result in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.inProgressDimNode.isUserInteractionEnabled = false
|
strongSelf.inProgressDimNode.isUserInteractionEnabled = false
|
||||||
strongSelf.inProgressDimNode.alpha = 0.0
|
strongSelf.inProgressDimNode.alpha = 0.0
|
||||||
|
@ -338,7 +338,7 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi
|
|||||||
func verify() {
|
func verify() {
|
||||||
self.isVerifying = true
|
self.isVerifying = true
|
||||||
let formInfo = self.collectFormInfo()
|
let formInfo = self.collectFormInfo()
|
||||||
self.verifyDisposable.set((validateBotPaymentForm(account: self.context.account, saveInfo: self.saveInfoItem.isOn, messageId: self.messageId, formInfo: formInfo) |> deliverOnMainQueue).start(next: { [weak self] result in
|
self.verifyDisposable.set((self.context.engine.payments.validateBotPaymentForm(saveInfo: self.saveInfoItem.isOn, messageId: self.messageId, formInfo: formInfo) |> deliverOnMainQueue).start(next: { [weak self] result in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.formInfoUpdated(formInfo, result)
|
strongSelf.formInfoUpdated(formInfo, result)
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ final class BotReceiptControllerNode: ItemListControllerNode {
|
|||||||
|
|
||||||
super.init(controller: controller, navigationBar: navigationBar, updateNavigationOffset: updateNavigationOffset, state: signal)
|
super.init(controller: controller, navigationBar: navigationBar, updateNavigationOffset: updateNavigationOffset, state: signal)
|
||||||
|
|
||||||
self.dataRequestDisposable = (requestBotPaymentReceipt(account: context.account, messageId: messageId) |> deliverOnMainQueue).start(next: { [weak self] receipt in
|
self.dataRequestDisposable = (context.engine.payments.requestBotPaymentReceipt(messageId: messageId) |> deliverOnMainQueue).start(next: { [weak self] receipt in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
UIView.transition(with: strongSelf.view, duration: 0.25, options: UIView.AnimationOptions.transitionCrossDissolve, animations: {
|
UIView.transition(with: strongSelf.view, duration: 0.25, options: UIView.AnimationOptions.transitionCrossDissolve, animations: {
|
||||||
}, completion: nil)
|
}, completion: nil)
|
||||||
|
@ -288,7 +288,7 @@ public final class CallListController: TelegramBaseController {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var signal = clearCallHistory(account: strongSelf.context.account, forEveryone: forEveryone)
|
var signal = strongSelf.context.engine.messages.clearCallHistory(forEveryone: forEveryone)
|
||||||
|
|
||||||
var cancelImpl: (() -> Void)?
|
var cancelImpl: (() -> Void)?
|
||||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
@ -343,7 +343,7 @@ final class CallListControllerNode: ASDisplayNode {
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: messageIds, type: .forEveryone).start()
|
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: messageIds, type: .forEveryone).start()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_DeleteMessagesForMe, color: .destructive, action: { [weak actionSheet] in
|
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_DeleteMessagesForMe, color: .destructive, action: { [weak actionSheet] in
|
||||||
@ -353,7 +353,7 @@ final class CallListControllerNode: ASDisplayNode {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: messageIds, type: .forLocalPeer).start()
|
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: messageIds, type: .forLocalPeer).start()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
actionSheet.setItemGroups([
|
actionSheet.setItemGroups([
|
||||||
|
@ -823,7 +823,7 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
|
|
||||||
let resolvedPeerId: Signal<PeerId, ImportManager.ImportError>
|
let resolvedPeerId: Signal<PeerId, ImportManager.ImportError>
|
||||||
if self.peerId.namespace == Namespaces.Peer.CloudGroup {
|
if self.peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||||
resolvedPeerId = convertGroupToSupergroup(account: self.context.account, peerId: self.peerId)
|
resolvedPeerId = self.context.engine.peers.convertGroupToSupergroup(peerId: self.peerId)
|
||||||
|> mapError { _ -> ImportManager.ImportError in
|
|> mapError { _ -> ImportManager.ImportError in
|
||||||
return .generic
|
return .generic
|
||||||
}
|
}
|
||||||
|
@ -1180,7 +1180,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
if !self.didSuggestLocalization {
|
if !self.didSuggestLocalization {
|
||||||
self.didSuggestLocalization = true
|
self.didSuggestLocalization = true
|
||||||
|
|
||||||
let network = self.context.account.network
|
let context = self.context
|
||||||
let signal = combineLatest(self.context.sharedContext.accountManager.transaction { transaction -> String in
|
let signal = combineLatest(self.context.sharedContext.accountManager.transaction { transaction -> String in
|
||||||
let languageCode: String
|
let languageCode: String
|
||||||
if let current = transaction.getSharedData(SharedDataKeys.localizationSettings) as? LocalizationSettings {
|
if let current = transaction.getSharedData(SharedDataKeys.localizationSettings) as? LocalizationSettings {
|
||||||
@ -1206,7 +1206,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
guard let suggestedLocalization = value.1, !suggestedLocalization.isSeen && suggestedLocalization.languageCode != "en" && suggestedLocalization.languageCode != value.0 else {
|
guard let suggestedLocalization = value.1, !suggestedLocalization.isSeen && suggestedLocalization.languageCode != "en" && suggestedLocalization.languageCode != value.0 else {
|
||||||
return .single(nil)
|
return .single(nil)
|
||||||
}
|
}
|
||||||
return suggestedLocalizationInfo(network: network, languageCode: suggestedLocalization.languageCode, extractKeys: LanguageSuggestionControllerStrings.keys)
|
return context.engine.localization.suggestedLocalizationInfo(languageCode: suggestedLocalization.languageCode, extractKeys: LanguageSuggestionControllerStrings.keys)
|
||||||
|> map({ suggestedLocalization -> (String, SuggestedLocalizationInfo)? in
|
|> map({ suggestedLocalization -> (String, SuggestedLocalizationInfo)? in
|
||||||
return (value.0, suggestedLocalization)
|
return (value.0, suggestedLocalization)
|
||||||
})
|
})
|
||||||
@ -1223,7 +1223,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
strongSelf.present(controller, in: .window(.root))
|
strongSelf.present(controller, in: .window(.root))
|
||||||
_ = markSuggestedLocalizationAsSeenInteractively(postbox: strongSelf.context.account.postbox, languageCode: suggestedLocalization.languageCode).start()
|
_ = strongSelf.context.engine.localization.markSuggestedLocalizationAsSeenInteractively(languageCode: suggestedLocalization.languageCode).start()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@ -2295,7 +2295,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if value == .commit {
|
if value == .commit {
|
||||||
let _ = clearHistoryInteractively(postbox: strongSelf.context.account.postbox, peerId: peerId, type: type).start(completed: {
|
let _ = strongSelf.context.engine.messages.clearHistoryInteractively(peerId: peerId, type: type).start(completed: {
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -844,7 +844,7 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
items.append(ActionSheetButtonItem(title: globalTitle, color: .destructive, action: { [weak actionSheet] in
|
items.append(ActionSheetButtonItem(title: globalTitle, color: .destructive, action: { [weak actionSheet] in
|
||||||
actionSheet?.dismissAnimated()
|
actionSheet?.dismissAnimated()
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forEveryone).start()
|
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: Array(messageIds), type: .forEveryone).start()
|
||||||
|
|
||||||
strongSelf.updateState { state in
|
strongSelf.updateState { state in
|
||||||
return state.withUpdatedSelectedMessageIds(nil)
|
return state.withUpdatedSelectedMessageIds(nil)
|
||||||
@ -867,7 +867,7 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
items.append(ActionSheetButtonItem(title: localOptionText, color: .destructive, action: { [weak actionSheet] in
|
items.append(ActionSheetButtonItem(title: localOptionText, color: .destructive, action: { [weak actionSheet] in
|
||||||
actionSheet?.dismissAnimated()
|
actionSheet?.dismissAnimated()
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forLocalPeer).start()
|
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: Array(messageIds), type: .forLocalPeer).start()
|
||||||
|
|
||||||
strongSelf.updateState { state in
|
strongSelf.updateState { state in
|
||||||
return state.withUpdatedSelectedMessageIds(nil)
|
return state.withUpdatedSelectedMessageIds(nil)
|
||||||
|
@ -920,7 +920,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
addAppLogEvent(postbox: context.account.postbox, type: "search_global_query")
|
addAppLogEvent(postbox: context.account.postbox, type: "search_global_query")
|
||||||
}
|
}
|
||||||
|
|
||||||
let searchSignal = searchMessages(account: context.account, location: location, query: finalQuery, state: nil, limit: 50)
|
let searchSignal = context.engine.messages.searchMessages(location: location, query: finalQuery, state: nil, limit: 50)
|
||||||
|> map { result, updatedState -> ChatListSearchMessagesResult in
|
|> map { result, updatedState -> ChatListSearchMessagesResult in
|
||||||
return ChatListSearchMessagesResult(query: finalQuery, messages: result.messages.sorted(by: { $0.index > $1.index }), readStates: result.readStates, hasMore: !result.completed, totalCount: result.totalCount, state: updatedState)
|
return ChatListSearchMessagesResult(query: finalQuery, messages: result.messages.sorted(by: { $0.index > $1.index }), readStates: result.readStates, hasMore: !result.completed, totalCount: result.totalCount, state: updatedState)
|
||||||
}
|
}
|
||||||
@ -929,7 +929,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
|> mapToSignal { searchContext -> Signal<(([Message], [PeerId: CombinedPeerReadState], Int32), Bool), NoError> in
|
|> mapToSignal { searchContext -> Signal<(([Message], [PeerId: CombinedPeerReadState], Int32), Bool), NoError> in
|
||||||
if let searchContext = searchContext, searchContext.result.hasMore {
|
if let searchContext = searchContext, searchContext.result.hasMore {
|
||||||
if let _ = searchContext.loadMoreIndex {
|
if let _ = searchContext.loadMoreIndex {
|
||||||
return searchMessages(account: context.account, location: location, query: finalQuery, state: searchContext.result.state, limit: 80)
|
return context.engine.messages.searchMessages(location: location, query: finalQuery, state: searchContext.result.state, limit: 80)
|
||||||
|> map { result, updatedState -> ChatListSearchMessagesResult in
|
|> map { result, updatedState -> ChatListSearchMessagesResult in
|
||||||
return ChatListSearchMessagesResult(query: finalQuery, messages: result.messages.sorted(by: { $0.index > $1.index }), readStates: result.readStates, hasMore: !result.completed, totalCount: result.totalCount, state: updatedState)
|
return ChatListSearchMessagesResult(query: finalQuery, messages: result.messages.sorted(by: { $0.index > $1.index }), readStates: result.readStates, hasMore: !result.completed, totalCount: result.totalCount, state: updatedState)
|
||||||
}
|
}
|
||||||
@ -966,7 +966,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
|> then(context.sharedContext.resolveUrl(context: context, peerId: nil, url: finalQuery, skipUrlAuth: true)
|
|> then(context.sharedContext.resolveUrl(context: context, peerId: nil, url: finalQuery, skipUrlAuth: true)
|
||||||
|> mapToSignal { resolvedUrl -> Signal<Message?, NoError> in
|
|> mapToSignal { resolvedUrl -> Signal<Message?, NoError> in
|
||||||
if case let .channelMessage(_, messageId) = resolvedUrl {
|
if case let .channelMessage(_, messageId) = resolvedUrl {
|
||||||
return downloadMessage(postbox: context.account.postbox, network: context.account.network, messageId: messageId)
|
return context.engine.messages.downloadMessage(messageId: messageId)
|
||||||
} else {
|
} else {
|
||||||
return .single(nil)
|
return .single(nil)
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func contactContextMenuItems(context: AccountContext, peerId: PeerId, contactsCo
|
|||||||
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(currentPeerId), peekData: nil))
|
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(currentPeerId), peekData: nil))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var createSignal = createSecretChat(account: context.account, peerId: peerId)
|
var createSignal = context.engine.peers.createSecretChat(peerId: peerId)
|
||||||
var cancelImpl: (() -> Void)?
|
var cancelImpl: (() -> Void)?
|
||||||
let progressSignal = Signal<Never, NoError> { subscriber in
|
let progressSignal = Signal<Never, NoError> { subscriber in
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
@ -998,7 +998,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
|||||||
items.append(ActionSheetButtonItem(title: globalTitle, color: .destructive, action: { [weak actionSheet] in
|
items.append(ActionSheetButtonItem(title: globalTitle, color: .destructive, action: { [weak actionSheet] in
|
||||||
actionSheet?.dismissAnimated()
|
actionSheet?.dismissAnimated()
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: messages.map { $0.id }, type: .forEveryone).start()
|
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: messages.map { $0.id }, type: .forEveryone).start()
|
||||||
strongSelf.controllerInteraction?.dismissController()
|
strongSelf.controllerInteraction?.dismissController()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
@ -1013,13 +1013,13 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
|||||||
items.append(ActionSheetButtonItem(title: localOptionText, color: .destructive, action: { [weak actionSheet] in
|
items.append(ActionSheetButtonItem(title: localOptionText, color: .destructive, action: { [weak actionSheet] in
|
||||||
actionSheet?.dismissAnimated()
|
actionSheet?.dismissAnimated()
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: messages.map { $0.id }, type: .forLocalPeer).start()
|
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: messages.map { $0.id }, type: .forLocalPeer).start()
|
||||||
strongSelf.controllerInteraction?.dismissController()
|
strongSelf.controllerInteraction?.dismissController()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
if !ask && items.count == 1 {
|
if !ask && items.count == 1 {
|
||||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: messages.map { $0.id }, type: .forEveryone).start()
|
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: messages.map { $0.id }, type: .forEveryone).start()
|
||||||
strongSelf.controllerInteraction?.dismissController()
|
strongSelf.controllerInteraction?.dismissController()
|
||||||
} else if !items.isEmpty {
|
} else if !items.isEmpty {
|
||||||
strongSelf.interacting?(true)
|
strongSelf.interacting?(true)
|
||||||
|
@ -43,7 +43,7 @@ public final class HashtagSearchController: TelegramBaseController {
|
|||||||
let chatListPresentationData = ChatListPresentationData(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: self.presentationData.disableAnimations)
|
let chatListPresentationData = ChatListPresentationData(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: self.presentationData.disableAnimations)
|
||||||
|
|
||||||
let location: SearchMessagesLocation = .general(tags: nil, minDate: nil, maxDate: nil)
|
let location: SearchMessagesLocation = .general(tags: nil, minDate: nil, maxDate: nil)
|
||||||
let search = searchMessages(account: context.account, location: location, query: query, state: nil)
|
let search = context.engine.messages.searchMessages(location: location, query: query, state: nil)
|
||||||
let foundMessages: Signal<[ChatListSearchEntry], NoError> = search
|
let foundMessages: Signal<[ChatListSearchEntry], NoError> = search
|
||||||
|> map { result, _ in
|
|> map { result, _ in
|
||||||
return result.messages.map({ .message($0, RenderedPeer(message: $0), result.readStates[$0.id.peerId], chatListPresentationData, result.totalCount, nil, false) })
|
return result.messages.map({ .message($0, RenderedPeer(message: $0), result.readStates[$0.id.peerId], chatListPresentationData, result.totalCount, nil, false) })
|
||||||
|
@ -65,7 +65,7 @@ public final class LanguageLinkPreviewController: ViewController {
|
|||||||
}
|
}
|
||||||
self.displayNodeDidLoad()
|
self.displayNodeDidLoad()
|
||||||
|
|
||||||
self.disposable.set((requestLocalizationPreview(network: self.context.account.network, identifier: self.identifier)
|
self.disposable.set((self.context.engine.localization.requestLocalizationPreview(identifier: self.identifier)
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] result in
|
|> deliverOnMainQueue).start(next: { [weak self] result in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
@ -115,7 +115,7 @@ public final class LanguageLinkPreviewController: ViewController {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.controllerNode.setInProgress(true)
|
self.controllerNode.setInProgress(true)
|
||||||
self.disposable.set((downloadAndApplyLocalization(accountManager: self.context.sharedContext.accountManager, postbox: self.context.account.postbox, network: self.context.account.network, languageCode: localizationInfo.languageCode)
|
self.disposable.set((self.context.engine.localization.downloadAndApplyLocalization(accountManager: self.context.sharedContext.accountManager, languageCode: localizationInfo.languageCode)
|
||||||
|> deliverOnMainQueue).start(error: { [weak self] _ in
|
|> deliverOnMainQueue).start(error: { [weak self] _ in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
|
@ -353,7 +353,7 @@ public func languageSuggestionController(context: AccountContext, suggestedLocal
|
|||||||
dismissImpl?(true)
|
dismissImpl?(true)
|
||||||
} else {
|
} else {
|
||||||
startActivity()
|
startActivity()
|
||||||
disposable.set((downloadAndApplyLocalization(accountManager: context.sharedContext.accountManager, postbox: context.account.postbox, network: context.account.network, languageCode: languageCode)
|
disposable.set((context.engine.localization.downloadAndApplyLocalization(accountManager: context.sharedContext.accountManager, languageCode: languageCode)
|
||||||
|> deliverOnMainQueue).start(completed: {
|
|> deliverOnMainQueue).start(completed: {
|
||||||
dismissImpl?(true)
|
dismissImpl?(true)
|
||||||
}))
|
}))
|
||||||
|
@ -10,9 +10,7 @@ import AccountContext
|
|||||||
public final class LiveLocationManagerImpl: LiveLocationManager {
|
public final class LiveLocationManagerImpl: LiveLocationManager {
|
||||||
private let queue = Queue.mainQueue()
|
private let queue = Queue.mainQueue()
|
||||||
|
|
||||||
private let postbox: Postbox
|
private let account: Account
|
||||||
private let network: Network
|
|
||||||
private let stateManager: AccountStateManager
|
|
||||||
private let locationManager: DeviceLocationManager
|
private let locationManager: DeviceLocationManager
|
||||||
|
|
||||||
private let summaryManagerImpl: LiveLocationSummaryManagerImpl
|
private let summaryManagerImpl: LiveLocationSummaryManagerImpl
|
||||||
@ -46,16 +44,14 @@ public final class LiveLocationManagerImpl: LiveLocationManager {
|
|||||||
|
|
||||||
private var invalidationTimer: (SwiftSignalKit.Timer, Int32)?
|
private var invalidationTimer: (SwiftSignalKit.Timer, Int32)?
|
||||||
|
|
||||||
public init(postbox: Postbox, network: Network, accountPeerId: PeerId, viewTracker: AccountViewTracker, stateManager: AccountStateManager, locationManager: DeviceLocationManager, inForeground: Signal<Bool, NoError>) {
|
public init(account: Account, locationManager: DeviceLocationManager, inForeground: Signal<Bool, NoError>) {
|
||||||
self.postbox = postbox
|
self.account = account
|
||||||
self.network = network
|
|
||||||
self.stateManager = stateManager
|
|
||||||
self.locationManager = locationManager
|
self.locationManager = locationManager
|
||||||
|
|
||||||
self.summaryManagerImpl = LiveLocationSummaryManagerImpl(queue: self.queue, postbox: postbox, accountPeerId: accountPeerId, viewTracker: viewTracker)
|
self.summaryManagerImpl = LiveLocationSummaryManagerImpl(queue: self.queue, postbox: account.postbox, accountPeerId: account.peerId, viewTracker: account.viewTracker)
|
||||||
|
|
||||||
let viewKey: PostboxViewKey = .localMessageTag(.OutgoingLiveLocation)
|
let viewKey: PostboxViewKey = .localMessageTag(.OutgoingLiveLocation)
|
||||||
self.messagesDisposable = (postbox.combinedView(keys: [viewKey])
|
self.messagesDisposable = (account.postbox.combinedView(keys: [viewKey])
|
||||||
|> deliverOn(self.queue)).start(next: { [weak self] view in
|
|> deliverOn(self.queue)).start(next: { [weak self] view in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
||||||
@ -175,7 +171,7 @@ public final class LiveLocationManagerImpl: LiveLocationManager {
|
|||||||
let addedStopped = stopMessageIds.subtracting(self.stopMessageIds)
|
let addedStopped = stopMessageIds.subtracting(self.stopMessageIds)
|
||||||
self.stopMessageIds = stopMessageIds
|
self.stopMessageIds = stopMessageIds
|
||||||
for id in addedStopped {
|
for id in addedStopped {
|
||||||
self.editMessageDisposables.set((requestEditLiveLocation(postbox: self.postbox, network: self.network, stateManager: self.stateManager, messageId: id, stop: true, coordinate: nil, heading: nil, proximityNotificationRadius: nil)
|
self.editMessageDisposables.set((TelegramEngine(account: self.account).messages.requestEditLiveLocation(messageId: id, stop: true, coordinate: nil, heading: nil, proximityNotificationRadius: nil)
|
||||||
|> deliverOn(self.queue)).start(completed: { [weak self] in
|
|> deliverOn(self.queue)).start(completed: { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.editMessageDisposables.set(nil, forKey: id)
|
strongSelf.editMessageDisposables.set(nil, forKey: id)
|
||||||
@ -230,7 +226,7 @@ public final class LiveLocationManagerImpl: LiveLocationManager {
|
|||||||
let ids = self.broadcastToMessageIds
|
let ids = self.broadcastToMessageIds
|
||||||
let remainingIds = Atomic<Set<MessageId>>(value: Set(ids.keys))
|
let remainingIds = Atomic<Set<MessageId>>(value: Set(ids.keys))
|
||||||
for id in ids.keys {
|
for id in ids.keys {
|
||||||
self.editMessageDisposables.set((requestEditLiveLocation(postbox: self.postbox, network: self.network, stateManager: self.stateManager, messageId: id, stop: false, coordinate: (latitude: coordinate.latitude, longitude: coordinate.longitude, accuracyRadius: Int32(accuracyRadius)), heading: heading.flatMap { Int32($0) }, proximityNotificationRadius: nil)
|
self.editMessageDisposables.set((TelegramEngine(account: self.account).messages.requestEditLiveLocation(messageId: id, stop: false, coordinate: (latitude: coordinate.latitude, longitude: coordinate.longitude, accuracyRadius: Int32(accuracyRadius)), heading: heading.flatMap { Int32($0) }, proximityNotificationRadius: nil)
|
||||||
|> deliverOn(self.queue)).start(completed: { [weak self] in
|
|> deliverOn(self.queue)).start(completed: { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.editMessageDisposables.set(nil, forKey: id)
|
strongSelf.editMessageDisposables.set(nil, forKey: id)
|
||||||
@ -253,7 +249,7 @@ public final class LiveLocationManagerImpl: LiveLocationManager {
|
|||||||
|
|
||||||
let ids = self.broadcastToMessageIds.keys.filter({ $0.peerId == peerId })
|
let ids = self.broadcastToMessageIds.keys.filter({ $0.peerId == peerId })
|
||||||
if !ids.isEmpty {
|
if !ids.isEmpty {
|
||||||
let _ = self.postbox.transaction({ transaction -> Void in
|
let _ = self.account.postbox.transaction({ transaction -> Void in
|
||||||
for id in ids {
|
for id in ids {
|
||||||
transaction.updateMessage(id, update: { currentMessage in
|
transaction.updateMessage(id, update: { currentMessage in
|
||||||
var storeForwardInfo: StoreMessageForwardInfo?
|
var storeForwardInfo: StoreMessageForwardInfo?
|
||||||
|
@ -192,7 +192,7 @@ public final class LocationViewController: ViewController {
|
|||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = requestEditLiveLocation(postbox: context.account.postbox, network: context.account.network, stateManager: context.account.stateManager, messageId: messageId, stop: false, coordinate: nil, heading: nil, proximityNotificationRadius: 0).start(completed: { [weak self] in
|
let _ = context.engine.messages.requestEditLiveLocation(messageId: messageId, stop: false, coordinate: nil, heading: nil, proximityNotificationRadius: 0).start(completed: { [weak self] in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -261,7 +261,7 @@ public final class LocationViewController: ViewController {
|
|||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = requestEditLiveLocation(postbox: context.account.postbox, network: context.account.network, stateManager: context.account.stateManager, messageId: messageId, stop: false, coordinate: nil, heading: nil, proximityNotificationRadius: distance).start(completed: { [weak self] in
|
let _ = context.engine.messages.requestEditLiveLocation(messageId: messageId, stop: false, coordinate: nil, heading: nil, proximityNotificationRadius: distance).start(completed: { [weak self] in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -885,7 +885,7 @@ public class AvatarGalleryController: ViewController, StandalonePresentableContr
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let messageId = messageId {
|
if let messageId = messageId {
|
||||||
let _ = deleteMessagesInteractively(account: self.context.account, messageIds: [messageId], type: .forEveryone).start()
|
let _ = self.context.engine.messages.deleteMessagesInteractively(messageIds: [messageId], type: .forEveryone).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
if entry == self.entries.first {
|
if entry == self.entries.first {
|
||||||
|
@ -1220,7 +1220,7 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
|
|||||||
case conversionFailed
|
case conversionFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
let signal = convertGroupToSupergroup(account: context.account, peerId: peerId)
|
let signal = context.engine.peers.convertGroupToSupergroup(peerId: peerId)
|
||||||
|> map(Optional.init)
|
|> map(Optional.init)
|
||||||
|> `catch` { error -> Signal<PeerId?, WrappedUpdateChannelAdminRightsError> in
|
|> `catch` { error -> Signal<PeerId?, WrappedUpdateChannelAdminRightsError> in
|
||||||
switch error {
|
switch error {
|
||||||
|
@ -650,7 +650,7 @@ public func channelBannedMemberController(context: AccountContext, peerId: PeerI
|
|||||||
}
|
}
|
||||||
|
|
||||||
if peerId.namespace == Namespaces.Peer.CloudGroup {
|
if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||||
let signal = convertGroupToSupergroup(account: context.account, peerId: peerId)
|
let signal = context.engine.peers.convertGroupToSupergroup(peerId: peerId)
|
||||||
|> map(Optional.init)
|
|> map(Optional.init)
|
||||||
|> `catch` { error -> Signal<PeerId?, NoError> in
|
|> `catch` { error -> Signal<PeerId?, NoError> in
|
||||||
switch error {
|
switch error {
|
||||||
|
@ -327,7 +327,7 @@ public func channelDiscussionGroupSetupController(context: AccountContext, peerI
|
|||||||
var applySignal: Signal<Bool, ChannelDiscussionGroupError>
|
var applySignal: Signal<Bool, ChannelDiscussionGroupError>
|
||||||
var updatedPeerId: PeerId? = nil
|
var updatedPeerId: PeerId? = nil
|
||||||
if let legacyGroup = groupPeer as? TelegramGroup {
|
if let legacyGroup = groupPeer as? TelegramGroup {
|
||||||
applySignal = convertGroupToSupergroup(account: context.account, peerId: legacyGroup.id)
|
applySignal = context.engine.peers.convertGroupToSupergroup(peerId: legacyGroup.id)
|
||||||
|> mapError { error -> ChannelDiscussionGroupError in
|
|> mapError { error -> ChannelDiscussionGroupError in
|
||||||
switch error {
|
switch error {
|
||||||
case .tooManyChannels:
|
case .tooManyChannels:
|
||||||
|
@ -460,7 +460,7 @@ private func commitChannelOwnershipTransferController(context: AccountContext, p
|
|||||||
}
|
}
|
||||||
|> then(.single(nil))
|
|> then(.single(nil))
|
||||||
} else if let peer = peer as? TelegramGroup {
|
} else if let peer = peer as? TelegramGroup {
|
||||||
signal = convertGroupToSupergroup(account: context.account, peerId: peer.id)
|
signal = context.engine.peers.convertGroupToSupergroup(peerId: peer.id)
|
||||||
|> map(Optional.init)
|
|> map(Optional.init)
|
||||||
|> mapError { error -> ChannelOwnershipTransferError in
|
|> mapError { error -> ChannelOwnershipTransferError in
|
||||||
switch error {
|
switch error {
|
||||||
|
@ -797,7 +797,7 @@ public func channelPermissionsController(context: AccountContext, peerId origina
|
|||||||
let progress = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil))
|
let progress = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil))
|
||||||
presentControllerImpl?(progress, nil)
|
presentControllerImpl?(progress, nil)
|
||||||
|
|
||||||
let signal = convertGroupToSupergroup(account: context.account, peerId: view.peerId)
|
let signal = context.engine.peers.convertGroupToSupergroup(peerId: view.peerId)
|
||||||
|> mapError { error -> UpdateChannelSlowModeError in
|
|> mapError { error -> UpdateChannelSlowModeError in
|
||||||
switch error {
|
switch error {
|
||||||
case .tooManyChannels:
|
case .tooManyChannels:
|
||||||
|
@ -1171,7 +1171,7 @@ public func channelVisibilityController(context: AccountContext, peerId: PeerId,
|
|||||||
}
|
}
|
||||||
_ = ApplicationSpecificNotice.markAsSeenSetPublicChannelLink(accountManager: context.sharedContext.accountManager).start()
|
_ = ApplicationSpecificNotice.markAsSeenSetPublicChannelLink(accountManager: context.sharedContext.accountManager).start()
|
||||||
|
|
||||||
let signal = convertGroupToSupergroup(account: context.account, peerId: peerId)
|
let signal = context.engine.peers.convertGroupToSupergroup(peerId: peerId)
|
||||||
|> mapToSignal { upgradedPeerId -> Signal<PeerId?, ConvertGroupToSupergroupError> in
|
|> mapToSignal { upgradedPeerId -> Signal<PeerId?, ConvertGroupToSupergroupError> in
|
||||||
return context.engine.peers.updateAddressName(domain: .peer(upgradedPeerId), name: updatedAddressNameValue.isEmpty ? nil : updatedAddressNameValue)
|
return context.engine.peers.updateAddressName(domain: .peer(upgradedPeerId), name: updatedAddressNameValue.isEmpty ? nil : updatedAddressNameValue)
|
||||||
|> `catch` { _ -> Signal<Void, NoError> in
|
|> `catch` { _ -> Signal<Void, NoError> in
|
||||||
|
@ -149,7 +149,7 @@ public func convertToSupergroupController(context: AccountContext, peerId: PeerI
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !alreadyConverting {
|
if !alreadyConverting {
|
||||||
convertDisposable.set((convertGroupToSupergroup(account: context.account, peerId: peerId)
|
convertDisposable.set((context.engine.peers.convertGroupToSupergroup(peerId: peerId)
|
||||||
|> deliverOnMainQueue).start(next: { createdPeerId in
|
|> deliverOnMainQueue).start(next: { createdPeerId in
|
||||||
replaceControllerImpl?(context.sharedContext.makeChatController(context: context, chatLocation: .peer(createdPeerId), subject: nil, botStart: nil, mode: .standard(previewing: false)))
|
replaceControllerImpl?(context.sharedContext.makeChatController(context: context, chatLocation: .peer(createdPeerId), subject: nil, botStart: nil, mode: .standard(previewing: false)))
|
||||||
}))
|
}))
|
||||||
|
@ -161,7 +161,7 @@ public func groupPreHistorySetupController(context: AccountContext, peerId: Peer
|
|||||||
}
|
}
|
||||||
if let value = value, value != defaultValue {
|
if let value = value, value != defaultValue {
|
||||||
if peerId.namespace == Namespaces.Peer.CloudGroup {
|
if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||||
let signal = convertGroupToSupergroup(account: context.account, peerId: peerId)
|
let signal = context.engine.peers.convertGroupToSupergroup(peerId: peerId)
|
||||||
|> mapToSignal { upgradedPeerId -> Signal<PeerId?, ConvertGroupToSupergroupError> in
|
|> mapToSignal { upgradedPeerId -> Signal<PeerId?, ConvertGroupToSupergroupError> in
|
||||||
return updateChannelHistoryAvailabilitySettingsInteractively(postbox: context.account.postbox, network: context.account.network, accountStateManager: context.account.stateManager, peerId: upgradedPeerId, historyAvailableForNewMembers: value)
|
return updateChannelHistoryAvailabilitySettingsInteractively(postbox: context.account.postbox, network: context.account.network, accountStateManager: context.account.stateManager, peerId: upgradedPeerId, historyAvailableForNewMembers: value)
|
||||||
|> `catch` { _ -> Signal<Void, NoError> in
|
|> `catch` { _ -> Signal<Void, NoError> in
|
||||||
|
@ -212,7 +212,7 @@ public func peerAutoremoveSetupScreen(context: AccountContext, peerId: PeerId, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
if updated {
|
if updated {
|
||||||
let signal = setChatMessageAutoremoveTimeoutInteractively(account: context.account, peerId: peerId, timeout: resolvedValue)
|
let signal = context.engine.peers.setChatMessageAutoremoveTimeoutInteractively(peerId: peerId, timeout: resolvedValue)
|
||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|
|
||||||
applyDisposable.set((signal
|
applyDisposable.set((signal
|
||||||
|
@ -418,7 +418,7 @@ final class LocalizationListControllerNode: ViewControllerTracingNode {
|
|||||||
let transition = preparedLanguageListNodeTransition(presentationData: presentationData, from: previousEntriesAndPresentationData?.0 ?? [], to: entries, openSearch: openSearch, selectLocalization: { [weak self] info in self?.selectLocalization(info) }, setItemWithRevealedOptions: setItemWithRevealedOptions, removeItem: removeItem, firstTime: previousEntriesAndPresentationData == nil, isLoading: entries.isEmpty, forceUpdate: previousEntriesAndPresentationData?.1 !== presentationData.theme || previousEntriesAndPresentationData?.2 !== presentationData.strings, animated: (previousEntriesAndPresentationData?.0.count ?? 0) >= entries.count, crossfade: (previousState == nil) != (localizationListState == nil))
|
let transition = preparedLanguageListNodeTransition(presentationData: presentationData, from: previousEntriesAndPresentationData?.0 ?? [], to: entries, openSearch: openSearch, selectLocalization: { [weak self] info in self?.selectLocalization(info) }, setItemWithRevealedOptions: setItemWithRevealedOptions, removeItem: removeItem, firstTime: previousEntriesAndPresentationData == nil, isLoading: entries.isEmpty, forceUpdate: previousEntriesAndPresentationData?.1 !== presentationData.theme || previousEntriesAndPresentationData?.2 !== presentationData.strings, animated: (previousEntriesAndPresentationData?.0.count ?? 0) >= entries.count, crossfade: (previousState == nil) != (localizationListState == nil))
|
||||||
strongSelf.enqueueTransition(transition)
|
strongSelf.enqueueTransition(transition)
|
||||||
})
|
})
|
||||||
self.updatedDisposable = synchronizedLocalizationListState(postbox: context.account.postbox, network: context.account.network).start()
|
self.updatedDisposable = context.engine.localization.synchronizedLocalizationListState().start()
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
@ -501,7 +501,7 @@ final class LocalizationListControllerNode: ViewControllerTracingNode {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.applyingCode.set(.single(info.languageCode))
|
strongSelf.applyingCode.set(.single(info.languageCode))
|
||||||
strongSelf.applyDisposable.set((downloadAndApplyLocalization(accountManager: strongSelf.context.sharedContext.accountManager, postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network, languageCode: info.languageCode)
|
strongSelf.applyDisposable.set((strongSelf.context.engine.localization.downloadAndApplyLocalization(accountManager: strongSelf.context.sharedContext.accountManager, languageCode: info.languageCode)
|
||||||
|> deliverOnMainQueue).start(completed: {
|
|> deliverOnMainQueue).start(completed: {
|
||||||
self?.applyingCode.set(.single(nil))
|
self?.applyingCode.set(.single(nil))
|
||||||
}))
|
}))
|
||||||
|
@ -360,7 +360,7 @@ public func dataPrivacyController(context: AccountContext) -> ViewController {
|
|||||||
info.insert(.shippingInfo)
|
info.insert(.shippingInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
clearPaymentInfoDisposable.set((clearBotPaymentInfo(network: context.account.network, info: info)
|
clearPaymentInfoDisposable.set((context.engine.payments.clearBotPaymentInfo(info: info)
|
||||||
|> deliverOnMainQueue).start(completed: {
|
|> deliverOnMainQueue).start(completed: {
|
||||||
updateState { state in
|
updateState { state in
|
||||||
var state = state
|
var state = state
|
||||||
@ -482,7 +482,7 @@ public func dataPrivacyController(context: AccountContext) -> ViewController {
|
|||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
if clear {
|
if clear {
|
||||||
clearPaymentInfoDisposable.set((clearCloudDraftsInteractively(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId)
|
clearPaymentInfoDisposable.set((context.engine.messages.clearCloudDraftsInteractively()
|
||||||
|> deliverOnMainQueue).start(completed: {
|
|> deliverOnMainQueue).start(completed: {
|
||||||
updateState { state in
|
updateState { state in
|
||||||
var state = state
|
var state = state
|
||||||
|
@ -708,7 +708,7 @@ private func languageSearchableItems(context: AccountContext, localizations: [Lo
|
|||||||
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil))
|
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil))
|
||||||
present(.immediate, controller)
|
present(.immediate, controller)
|
||||||
|
|
||||||
let _ = (downloadAndApplyLocalization(accountManager: context.sharedContext.accountManager, postbox: context.account.postbox, network: context.account.network, languageCode: languageCode)
|
let _ = (context.engine.localization.downloadAndApplyLocalization(accountManager: context.sharedContext.accountManager, languageCode: languageCode)
|
||||||
|> deliverOnMainQueue).start(completed: { [weak controller] in
|
|> deliverOnMainQueue).start(completed: { [weak controller] in
|
||||||
controller?.dismiss()
|
controller?.dismiss()
|
||||||
present(.dismiss, nil)
|
present(.dismiss, nil)
|
||||||
|
@ -618,7 +618,7 @@ public final class ShareController: ViewController {
|
|||||||
if let error = error {
|
if let error = error {
|
||||||
Queue.mainQueue().async {
|
Queue.mainQueue().async {
|
||||||
let _ = (account.postbox.transaction { transaction -> Peer? in
|
let _ = (account.postbox.transaction { transaction -> Peer? in
|
||||||
deleteMessages(transaction: transaction, mediaBox: account.postbox.mediaBox, ids: [id])
|
TelegramEngine(account: account).messages.deleteMessages(transaction: transaction, ids: [id])
|
||||||
return transaction.getPeer(id.peerId)
|
return transaction.getPeer(id.peerId)
|
||||||
}
|
}
|
||||||
|> deliverOnMainQueue).start(next: { peer in
|
|> deliverOnMainQueue).start(next: { peer in
|
||||||
|
@ -215,13 +215,13 @@ public func messageStatsController(context: AccountContext, messageId: MessageId
|
|||||||
|
|
||||||
let previousData = Atomic<MessageStats?>(value: nil)
|
let previousData = Atomic<MessageStats?>(value: nil)
|
||||||
|
|
||||||
let searchSignal = searchMessages(account: context.account, location: .publicForwards(messageId: messageId, datacenterId: Int(datacenterId)), query: "", state: nil)
|
let searchSignal = context.engine.messages.searchMessages(location: .publicForwards(messageId: messageId, datacenterId: Int(datacenterId)), query: "", state: nil)
|
||||||
|> map(Optional.init)
|
|> map(Optional.init)
|
||||||
|> afterNext { result in
|
|> afterNext { result in
|
||||||
if let result = result {
|
if let result = result {
|
||||||
for message in result.0.messages {
|
for message in result.0.messages {
|
||||||
if let peer = message.peers[message.id.peerId], let peerReference = PeerReference(peer) {
|
if let peer = message.peers[message.id.peerId], let peerReference = PeerReference(peer) {
|
||||||
let _ = updatedRemotePeer(postbox: context.account.postbox, network: context.account.network, peer: peerReference).start()
|
let _ = context.engine.peers.updatedRemotePeer(peer: peerReference).start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,44 @@ func switchToAuthorizedAccount(transaction: AccountManagerModifier, account: Una
|
|||||||
transaction.removeAuth()
|
transaction.removeAuth()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private struct Regex {
|
||||||
|
let pattern: String
|
||||||
|
let options: NSRegularExpression.Options!
|
||||||
|
|
||||||
|
private var matcher: NSRegularExpression {
|
||||||
|
return try! NSRegularExpression(pattern: self.pattern, options: self.options)
|
||||||
|
}
|
||||||
|
|
||||||
|
init(_ pattern: String) {
|
||||||
|
self.pattern = pattern
|
||||||
|
self.options = []
|
||||||
|
}
|
||||||
|
|
||||||
|
func match(_ string: String, options: NSRegularExpression.MatchingOptions = []) -> Bool {
|
||||||
|
return self.matcher.numberOfMatches(in: string, options: options, range: NSMakeRange(0, string.utf16.count)) != 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private protocol RegularExpressionMatchable {
|
||||||
|
func match(_ regex: Regex) -> Bool
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct MatchString: RegularExpressionMatchable {
|
||||||
|
private let string: String
|
||||||
|
|
||||||
|
init(_ string: String) {
|
||||||
|
self.string = string
|
||||||
|
}
|
||||||
|
|
||||||
|
func match(_ regex: Regex) -> Bool {
|
||||||
|
return regex.match(self.string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func ~=<T: RegularExpressionMatchable>(pattern: Regex, matchable: T) -> Bool {
|
||||||
|
return matchable.match(pattern)
|
||||||
|
}
|
||||||
|
|
||||||
public func sendAuthorizationCode(accountManager: AccountManager, account: UnauthorizedAccount, phoneNumber: String, apiId: Int32, apiHash: String, syncContacts: Bool) -> Signal<UnauthorizedAccount, AuthorizationCodeRequestError> {
|
public func sendAuthorizationCode(accountManager: AccountManager, account: UnauthorizedAccount, phoneNumber: String, apiId: Int32, apiHash: String, syncContacts: Bool) -> Signal<UnauthorizedAccount, AuthorizationCodeRequestError> {
|
||||||
let sendCode = Api.functions.auth.sendCode(phoneNumber: phoneNumber, apiId: apiId, apiHash: apiHash, settings: .codeSettings(flags: 0))
|
let sendCode = Api.functions.auth.sendCode(phoneNumber: phoneNumber, apiId: apiId, apiHash: apiHash, settings: .codeSettings(flags: 0))
|
||||||
|
|
||||||
@ -39,7 +77,7 @@ public func sendAuthorizationCode(accountManager: AccountManager, account: Unaut
|
|||||||
return (result, account)
|
return (result, account)
|
||||||
}
|
}
|
||||||
|> `catch` { error -> Signal<(Api.auth.SentCode, UnauthorizedAccount), MTRpcError> in
|
|> `catch` { error -> Signal<(Api.auth.SentCode, UnauthorizedAccount), MTRpcError> in
|
||||||
switch (error.errorDescription ?? "") {
|
switch MatchString(error.errorDescription ?? "") {
|
||||||
case Regex("(PHONE_|USER_|NETWORK_)MIGRATE_(\\d+)"):
|
case Regex("(PHONE_|USER_|NETWORK_)MIGRATE_(\\d+)"):
|
||||||
let range = error.errorDescription.range(of: "MIGRATE_")!
|
let range = error.errorDescription.range(of: "MIGRATE_")!
|
||||||
let updatedMasterDatacenterId = Int32(error.errorDescription[range.upperBound ..< error.errorDescription.endIndex])!
|
let updatedMasterDatacenterId = Int32(error.errorDescription[range.upperBound ..< error.errorDescription.endIndex])!
|
||||||
@ -85,7 +123,6 @@ public func sendAuthorizationCode(accountManager: AccountManager, account: Unaut
|
|||||||
return account
|
return account
|
||||||
}
|
}
|
||||||
|> mapError { _ -> AuthorizationCodeRequestError in
|
|> mapError { _ -> AuthorizationCodeRequestError in
|
||||||
return .generic(info: nil)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,7 +160,7 @@ public func resendAuthorizationCode(account: UnauthorizedAccount) -> Signal<Void
|
|||||||
transaction.setState(UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .confirmationCodeEntry(number: number, type: SentAuthorizationCodeType(apiType: type), hash: phoneCodeHash, timeout: timeout, nextType: parsedNextType, syncContacts: syncContacts)))
|
transaction.setState(UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .confirmationCodeEntry(number: number, type: SentAuthorizationCodeType(apiType: type), hash: phoneCodeHash, timeout: timeout, nextType: parsedNextType, syncContacts: syncContacts)))
|
||||||
|
|
||||||
}
|
}
|
||||||
} |> mapError { _ -> AuthorizationCodeRequestError in return .generic(info: nil) }
|
} |> mapError { _ -> AuthorizationCodeRequestError in }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return .fail(.generic(info: nil))
|
return .fail(.generic(info: nil))
|
||||||
@ -136,7 +173,6 @@ public func resendAuthorizationCode(account: UnauthorizedAccount) -> Signal<Void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> mapError { _ -> AuthorizationCodeRequestError in
|
|> mapError { _ -> AuthorizationCodeRequestError in
|
||||||
return .generic(info: nil)
|
|
||||||
}
|
}
|
||||||
|> switchToLatest
|
|> switchToLatest
|
||||||
}
|
}
|
||||||
@ -233,7 +269,6 @@ public func authorizeWithCode(accountManager: AccountManager, account: Unauthori
|
|||||||
}
|
}
|
||||||
|> switchToLatest
|
|> switchToLatest
|
||||||
|> mapError { _ -> AuthorizationCodeVerificationError in
|
|> mapError { _ -> AuthorizationCodeVerificationError in
|
||||||
return .generic
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -244,7 +279,6 @@ public func authorizeWithCode(accountManager: AccountManager, account: Unauthori
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> mapError { _ -> AuthorizationCodeVerificationError in
|
|> mapError { _ -> AuthorizationCodeVerificationError in
|
||||||
return .generic
|
|
||||||
}
|
}
|
||||||
|> switchToLatest
|
|> switchToLatest
|
||||||
}
|
}
|
||||||
@ -294,7 +328,6 @@ public func authorizeWithPassword(accountManager: AccountManager, account: Unaut
|
|||||||
}
|
}
|
||||||
|> switchToLatest
|
|> switchToLatest
|
||||||
|> mapError { _ -> AuthorizationPasswordVerificationError in
|
|> mapError { _ -> AuthorizationPasswordVerificationError in
|
||||||
return .generic
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -369,7 +402,7 @@ public func performPasswordRecovery(accountManager: AccountManager, account: Una
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> switchToLatest
|
|> switchToLatest
|
||||||
|> mapError { _ in return PasswordRecoveryError.expired }
|
|> mapError { _ -> PasswordRecoveryError in }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +451,7 @@ public func performAccountReset(account: UnauthorizedAccount) -> Signal<Void, Ac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> mapError { _ in return AccountResetError.generic }
|
|> mapError { _ -> AccountResetError in }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,7 +530,6 @@ public func signUpWithName(accountManager: AccountManager, account: Unauthorized
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> mapError { _ -> SignUpError in
|
|> mapError { _ -> SignUpError in
|
||||||
return .generic
|
|
||||||
}
|
}
|
||||||
|> switchToLatest
|
|> switchToLatest
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ final class MediaReferenceRevalidationContext {
|
|||||||
|
|
||||||
func peer(postbox: Postbox, network: Network, background: Bool, peer: PeerReference) -> Signal<Peer, RevalidateMediaReferenceError> {
|
func peer(postbox: Postbox, network: Network, background: Bool, peer: PeerReference) -> Signal<Peer, RevalidateMediaReferenceError> {
|
||||||
return self.genericItem(key: .peer(peer: peer), background: background, request: { next, error in
|
return self.genericItem(key: .peer(peer: peer), background: background, request: { next, error in
|
||||||
return (updatedRemotePeer(postbox: postbox, network: network, peer: peer)
|
return (_internal_updatedRemotePeer(postbox: postbox, network: network, peer: peer)
|
||||||
|> mapError { _ -> RevalidateMediaReferenceError in
|
|> mapError { _ -> RevalidateMediaReferenceError in
|
||||||
return .generic
|
return .generic
|
||||||
}).start(next: { value in
|
}).start(next: { value in
|
||||||
|
@ -832,7 +832,7 @@ private func validateBatch(postbox: Postbox, network: Network, transaction: Tran
|
|||||||
return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, threadId: currentMessage.threadId, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: updatedTags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: attributes, media: currentMessage.media))
|
return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, threadId: currentMessage.threadId, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: updatedTags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: attributes, media: currentMessage.media))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
deleteMessages(transaction: transaction, mediaBox: postbox.mediaBox, ids: [id])
|
_internal_deleteMessages(transaction: transaction, mediaBox: postbox.mediaBox, ids: [id])
|
||||||
Logger.shared.log("HistoryValidation", "deleting message \(id) in \(id.peerId)")
|
Logger.shared.log("HistoryValidation", "deleting message \(id) in \(id.peerId)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1011,7 +1011,7 @@ private func validateReplyThreadBatch(postbox: Postbox, network: Network, transa
|
|||||||
|
|
||||||
for id in removedMessageIds {
|
for id in removedMessageIds {
|
||||||
if !validMessageIds.contains(id) {
|
if !validMessageIds.contains(id) {
|
||||||
deleteMessages(transaction: transaction, mediaBox: postbox.mediaBox, ids: [id])
|
_internal_deleteMessages(transaction: transaction, mediaBox: postbox.mediaBox, ids: [id])
|
||||||
Logger.shared.log("HistoryValidation", "deleting thread message \(id) in \(id.peerId)")
|
Logger.shared.log("HistoryValidation", "deleting thread message \(id) in \(id.peerId)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public func installInteractiveReadMessagesAction(postbox: Postbox, stateManager:
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (_, index) in readMessageIndexByNamespace {
|
for (_, index) in readMessageIndexByNamespace {
|
||||||
applyMaxReadIndexInteractively(transaction: transaction, stateManager: stateManager, index: index)
|
_internal_applyMaxReadIndexInteractively(transaction: transaction, stateManager: stateManager, index: index)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ public func resendMessages(account: Account, messageIds: [MessageId]) -> Signal<
|
|||||||
}
|
}
|
||||||
let _ = enqueueMessages(transaction: transaction, account: account, peerId: peerId, messages: messages.map { (false, $0) })
|
let _ = enqueueMessages(transaction: transaction, account: account, peerId: peerId, messages: messages.map { (false, $0) })
|
||||||
}
|
}
|
||||||
deleteMessages(transaction: transaction, mediaBox: account.postbox.mediaBox, ids: removeMessageIds, deleteMedia: false)
|
_internal_deleteMessages(transaction: transaction, mediaBox: account.postbox.mediaBox, ids: removeMessageIds, deleteMedia: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -28,7 +28,7 @@ public enum RequestEditMessageError {
|
|||||||
case invalidGrouping
|
case invalidGrouping
|
||||||
}
|
}
|
||||||
|
|
||||||
public func requestEditMessage(account: Account, messageId: MessageId, text: String, media: RequestEditMessageMedia, entities: TextEntitiesMessageAttribute? = nil, disableUrlPreview: Bool = false, scheduleTime: Int32? = nil) -> Signal<RequestEditMessageResult, RequestEditMessageError> {
|
func _internal_requestEditMessage(account: Account, messageId: MessageId, text: String, media: RequestEditMessageMedia, entities: TextEntitiesMessageAttribute? = nil, disableUrlPreview: Bool = false, scheduleTime: Int32? = nil) -> Signal<RequestEditMessageResult, RequestEditMessageError> {
|
||||||
return requestEditMessage(postbox: account.postbox, network: account.network, stateManager: account.stateManager, transformOutgoingMessageMedia: account.transformOutgoingMessageMedia, messageMediaPreuploadManager: account.messageMediaPreuploadManager, mediaReferenceRevalidationContext: account.mediaReferenceRevalidationContext, messageId: messageId, text: text, media: media, entities: entities, disableUrlPreview: disableUrlPreview, scheduleTime: scheduleTime)
|
return requestEditMessage(postbox: account.postbox, network: account.network, stateManager: account.stateManager, transformOutgoingMessageMedia: account.transformOutgoingMessageMedia, messageMediaPreuploadManager: account.messageMediaPreuploadManager, mediaReferenceRevalidationContext: account.mediaReferenceRevalidationContext, messageId: messageId, text: text, media: media, entities: entities, disableUrlPreview: disableUrlPreview, scheduleTime: scheduleTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ private func requestEditMessageInternal(postbox: Postbox, network: Network, stat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func requestEditLiveLocation(postbox: Postbox, network: Network, stateManager: AccountStateManager, messageId: MessageId, stop: Bool, coordinate: (latitude: Double, longitude: Double, accuracyRadius: Int32?)?, heading: Int32?, proximityNotificationRadius: Int32?) -> Signal<Void, NoError> {
|
func _internal_requestEditLiveLocation(postbox: Postbox, network: Network, stateManager: AccountStateManager, messageId: MessageId, stop: Bool, coordinate: (latitude: Double, longitude: Double, accuracyRadius: Int32?)?, heading: Int32?, proximityNotificationRadius: Int32?) -> Signal<Void, NoError> {
|
||||||
return postbox.transaction { transaction -> (Api.InputPeer, TelegramMediaMap)? in
|
return postbox.transaction { transaction -> (Api.InputPeer, TelegramMediaMap)? in
|
||||||
guard let inputPeer = transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) else {
|
guard let inputPeer = transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) else {
|
||||||
return nil
|
return nil
|
@ -1,33 +0,0 @@
|
|||||||
import Foundation
|
|
||||||
|
|
||||||
public struct Regex {
|
|
||||||
let pattern: String
|
|
||||||
let options: NSRegularExpression.Options!
|
|
||||||
|
|
||||||
private var matcher: NSRegularExpression {
|
|
||||||
return try! NSRegularExpression(pattern: self.pattern, options: self.options)
|
|
||||||
}
|
|
||||||
|
|
||||||
public init(_ pattern: String) {
|
|
||||||
self.pattern = pattern
|
|
||||||
self.options = []
|
|
||||||
}
|
|
||||||
|
|
||||||
public func match(_ string: String, options: NSRegularExpression.MatchingOptions = []) -> Bool {
|
|
||||||
return self.matcher.numberOfMatches(in: string, options: options, range: NSMakeRange(0, string.utf16.count)) != 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public protocol RegularExpressionMatchable {
|
|
||||||
func match(_ regex: Regex) -> Bool
|
|
||||||
}
|
|
||||||
|
|
||||||
extension String: RegularExpressionMatchable {
|
|
||||||
public func match(_ regex: Regex) -> Bool {
|
|
||||||
return regex.match(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func ~=<T: RegularExpressionMatchable>(pattern: Regex, matchable: T) -> Bool {
|
|
||||||
return matchable.match(pattern)
|
|
||||||
}
|
|
@ -58,17 +58,17 @@ public func removePeerChat(account: Account, transaction: Transaction, mediaBox:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clearHistory(transaction: transaction, mediaBox: mediaBox, peerId: peerId, namespaces: .all)
|
_internal_clearHistory(transaction: transaction, mediaBox: mediaBox, peerId: peerId, namespaces: .all)
|
||||||
transaction.updatePeerChatListInclusion(peerId, inclusion: .notIncluded)
|
transaction.updatePeerChatListInclusion(peerId, inclusion: .notIncluded)
|
||||||
transaction.removeOrderedItemListItem(collectionId: Namespaces.OrderedItemList.RecentlySearchedPeerIds, itemId: RecentPeerItemId(peerId).rawValue)
|
transaction.removeOrderedItemListItem(collectionId: Namespaces.OrderedItemList.RecentlySearchedPeerIds, itemId: RecentPeerItemId(peerId).rawValue)
|
||||||
} else {
|
} else {
|
||||||
cloudChatAddRemoveChatOperation(transaction: transaction, peerId: peerId, reportChatSpam: reportChatSpam, deleteGloballyIfPossible: deleteGloballyIfPossible)
|
cloudChatAddRemoveChatOperation(transaction: transaction, peerId: peerId, reportChatSpam: reportChatSpam, deleteGloballyIfPossible: deleteGloballyIfPossible)
|
||||||
if peerId.namespace == Namespaces.Peer.CloudUser {
|
if peerId.namespace == Namespaces.Peer.CloudUser {
|
||||||
transaction.updatePeerChatListInclusion(peerId, inclusion: .notIncluded)
|
transaction.updatePeerChatListInclusion(peerId, inclusion: .notIncluded)
|
||||||
clearHistory(transaction: transaction, mediaBox: mediaBox, peerId: peerId, namespaces: .all)
|
_internal_clearHistory(transaction: transaction, mediaBox: mediaBox, peerId: peerId, namespaces: .all)
|
||||||
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
|
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||||
transaction.updatePeerChatListInclusion(peerId, inclusion: .notIncluded)
|
transaction.updatePeerChatListInclusion(peerId, inclusion: .notIncluded)
|
||||||
clearHistory(transaction: transaction, mediaBox: mediaBox, peerId: peerId, namespaces: .all)
|
_internal_clearHistory(transaction: transaction, mediaBox: mediaBox, peerId: peerId, namespaces: .all)
|
||||||
} else {
|
} else {
|
||||||
transaction.updatePeerChatListInclusion(peerId, inclusion: .notIncluded)
|
transaction.updatePeerChatListInclusion(peerId, inclusion: .notIncluded)
|
||||||
}
|
}
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
import Foundation
|
|
||||||
import Postbox
|
|
||||||
import SwiftSignalKit
|
|
||||||
import TelegramApi
|
|
||||||
|
|
||||||
public func requestPhoneNumber(account: Account, peerId: PeerId) -> Signal<Never, NoError> {
|
|
||||||
return .never()
|
|
||||||
/*return account.postbox.transaction { transaction -> Api.InputPeer? in
|
|
||||||
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
|
||||||
}
|
|
||||||
|> mapToSignal { inputPeer -> Signal<Never, NoError> in
|
|
||||||
guard let inputPeer = inputPeer else {
|
|
||||||
return .complete()
|
|
||||||
}
|
|
||||||
return account.network.request(Api.functions.messages.sendPhoneNumberRequest(peer: inputPeer, randomId: Int64.random(in: Int64.min ... Int64.max)))
|
|
||||||
|> map(Optional.init)
|
|
||||||
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
|
|
||||||
return .single(nil)
|
|
||||||
}
|
|
||||||
|> mapToSignal { updates -> Signal<Never, NoError> in
|
|
||||||
if let updates = updates {
|
|
||||||
account.stateManager.addUpdates(updates)
|
|
||||||
}
|
|
||||||
return .complete()
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
@ -78,7 +78,7 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee
|
|||||||
|
|
||||||
if isRemoved {
|
if isRemoved {
|
||||||
let peerId = currentPeer.id
|
let peerId = currentPeer.id
|
||||||
clearHistory(transaction: transaction, mediaBox: mediaBox, peerId: peerId, namespaces: .all)
|
_internal_clearHistory(transaction: transaction, mediaBox: mediaBox, peerId: peerId, namespaces: .all)
|
||||||
transaction.updatePeerChatListInclusion(peerId, inclusion: .notIncluded)
|
transaction.updatePeerChatListInclusion(peerId, inclusion: .notIncluded)
|
||||||
transaction.removeOrderedItemListItem(collectionId: Namespaces.OrderedItemList.RecentlySearchedPeerIds, itemId: RecentPeerItemId(peerId).rawValue)
|
transaction.removeOrderedItemListItem(collectionId: Namespaces.OrderedItemList.RecentlySearchedPeerIds, itemId: RecentPeerItemId(peerId).rawValue)
|
||||||
}
|
}
|
||||||
|
@ -1,105 +0,0 @@
|
|||||||
import Foundation
|
|
||||||
import Postbox
|
|
||||||
import SwiftSignalKit
|
|
||||||
import TelegramApi
|
|
||||||
import MtProtoKit
|
|
||||||
|
|
||||||
import SyncCore
|
|
||||||
|
|
||||||
public func singleMessageView(account: Account, messageId: MessageId, loadIfNotExists: Bool) -> Signal<MessageView, NoError> {
|
|
||||||
return Signal { subscriber in
|
|
||||||
let loadedMessage = account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
|
||||||
if transaction.getMessage(messageId) == nil, loadIfNotExists {
|
|
||||||
return fetchMessage(transaction: transaction, account: account, messageId: messageId)
|
|
||||||
} else {
|
|
||||||
return .complete()
|
|
||||||
}
|
|
||||||
} |> switchToLatest
|
|
||||||
|
|
||||||
let disposable = loadedMessage.start()
|
|
||||||
let viewDisposable = account.postbox.messageView(messageId).start(next: { view in
|
|
||||||
subscriber.putNext(view)
|
|
||||||
})
|
|
||||||
|
|
||||||
return ActionDisposable {
|
|
||||||
disposable.dispose()
|
|
||||||
viewDisposable.dispose()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func fetchMessage(transaction: Transaction, account: Account, messageId: MessageId) -> Signal<Void, NoError> {
|
|
||||||
if let peer = transaction.getPeer(messageId.peerId) {
|
|
||||||
var signal: Signal<Api.messages.Messages, MTRpcError>?
|
|
||||||
if messageId.namespace == Namespaces.Message.ScheduledCloud {
|
|
||||||
if let inputPeer = apiInputPeer(peer) {
|
|
||||||
signal = account.network.request(Api.functions.messages.getScheduledMessages(peer: inputPeer, id: [messageId.id]))
|
|
||||||
}
|
|
||||||
} else if messageId.peerId.namespace == Namespaces.Peer.CloudUser || messageId.peerId.namespace == Namespaces.Peer.CloudGroup {
|
|
||||||
signal = account.network.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(id: messageId.id)]))
|
|
||||||
} else if messageId.peerId.namespace == Namespaces.Peer.CloudChannel {
|
|
||||||
if let inputChannel = apiInputChannel(peer) {
|
|
||||||
signal = account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: [Api.InputMessage.inputMessageID(id: messageId.id)]))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let signal = signal {
|
|
||||||
return signal
|
|
||||||
|> `catch` { _ -> Signal<Api.messages.Messages, NoError> in
|
|
||||||
return .single(.messages(messages: [], chats: [], users: []))
|
|
||||||
}
|
|
||||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
|
||||||
return account.postbox.transaction { transaction -> Void in
|
|
||||||
let apiMessages: [Api.Message]
|
|
||||||
let apiChats: [Api.Chat]
|
|
||||||
let apiUsers: [Api.User]
|
|
||||||
switch result {
|
|
||||||
case let .messages(messages, chats, users):
|
|
||||||
apiMessages = messages
|
|
||||||
apiChats = chats
|
|
||||||
apiUsers = users
|
|
||||||
case let .messagesSlice(_, _, _, _, messages, chats, users):
|
|
||||||
apiMessages = messages
|
|
||||||
apiChats = chats
|
|
||||||
apiUsers = users
|
|
||||||
case let .channelMessages(_, _, _, _, messages, chats, users):
|
|
||||||
apiMessages = messages
|
|
||||||
apiChats = chats
|
|
||||||
apiUsers = users
|
|
||||||
case .messagesNotModified:
|
|
||||||
apiMessages = []
|
|
||||||
apiChats = []
|
|
||||||
apiUsers = []
|
|
||||||
}
|
|
||||||
|
|
||||||
var peers: [PeerId: Peer] = [:]
|
|
||||||
|
|
||||||
for user in apiUsers {
|
|
||||||
if let user = TelegramUser.merge(transaction.getPeer(user.peerId) as? TelegramUser, rhs: user) {
|
|
||||||
peers[user.id] = user
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for chat in apiChats {
|
|
||||||
if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) {
|
|
||||||
peers[groupOrChannel.id] = groupOrChannel
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updatePeers(transaction: transaction, peers: Array(peers.values), update: { _, updated in
|
|
||||||
return updated
|
|
||||||
})
|
|
||||||
|
|
||||||
for message in apiMessages {
|
|
||||||
if let message = StoreMessage(apiMessage: message, namespace: messageId.namespace) {
|
|
||||||
let _ = transaction.addMessages([message], location: .Random)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return .complete()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return .complete()
|
|
||||||
}
|
|
||||||
}
|
|
@ -2490,7 +2490,7 @@ func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountP
|
|||||||
}
|
}
|
||||||
deletedMessageIds.append(contentsOf: ids.map { .global($0) })
|
deletedMessageIds.append(contentsOf: ids.map { .global($0) })
|
||||||
case let .DeleteMessages(ids):
|
case let .DeleteMessages(ids):
|
||||||
deleteMessages(transaction: transaction, mediaBox: mediaBox, ids: ids, manualAddMessageThreadStatsDifference: { id, add, remove in
|
_internal_deleteMessages(transaction: transaction, mediaBox: mediaBox, ids: ids, manualAddMessageThreadStatsDifference: { id, add, remove in
|
||||||
addMessageThreadStatsDifference(threadMessageId: id, remove: remove, addedMessagePeer: nil, addedMessageId: nil, isOutgoing: false)
|
addMessageThreadStatsDifference(threadMessageId: id, remove: remove, addedMessagePeer: nil, addedMessageId: nil, isOutgoing: false)
|
||||||
})
|
})
|
||||||
deletedMessageIds.append(contentsOf: ids.map { .messageId($0) })
|
deletedMessageIds.append(contentsOf: ids.map { .messageId($0) })
|
||||||
|
@ -83,7 +83,7 @@ func managedAutoremoveMessageOperations(network: Network, postbox: Postbox, isRe
|
|||||||
|
|
||||||
if let message = transaction.getMessage(entry.messageId) {
|
if let message = transaction.getMessage(entry.messageId) {
|
||||||
if message.id.peerId.namespace == Namespaces.Peer.SecretChat || isRemove {
|
if message.id.peerId.namespace == Namespaces.Peer.SecretChat || isRemove {
|
||||||
deleteMessages(transaction: transaction, mediaBox: postbox.mediaBox, ids: [entry.messageId])
|
_internal_deleteMessages(transaction: transaction, mediaBox: postbox.mediaBox, ids: [entry.messageId])
|
||||||
} else {
|
} else {
|
||||||
transaction.updateMessage(message.id, update: { currentMessage in
|
transaction.updateMessage(message.id, update: { currentMessage in
|
||||||
var storeForwardInfo: StoreMessageForwardInfo?
|
var storeForwardInfo: StoreMessageForwardInfo?
|
||||||
|
@ -96,7 +96,7 @@ func managedCloudChatRemoveMessagesOperations(postbox: Postbox, network: Network
|
|||||||
}
|
}
|
||||||
} else if let operation = entry.contents as? CloudChatClearHistoryOperation {
|
} else if let operation = entry.contents as? CloudChatClearHistoryOperation {
|
||||||
if let peer = transaction.getPeer(entry.peerId) {
|
if let peer = transaction.getPeer(entry.peerId) {
|
||||||
return clearHistory(transaction: transaction, postbox: postbox, network: network, stateManager: stateManager, peer: peer, operation: operation)
|
return _internal_clearHistory(transaction: transaction, postbox: postbox, network: network, stateManager: stateManager, peer: peer, operation: operation)
|
||||||
} else {
|
} else {
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -311,7 +311,7 @@ private func removeChat(transaction: Transaction, postbox: Postbox, network: Net
|
|||||||
|> then(deleteUser)
|
|> then(deleteUser)
|
||||||
|> then(reportSignal)
|
|> then(reportSignal)
|
||||||
|> then(postbox.transaction { transaction -> Void in
|
|> then(postbox.transaction { transaction -> Void in
|
||||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peer.id, namespaces: .all)
|
_internal_clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peer.id, namespaces: .all)
|
||||||
})
|
})
|
||||||
} else if peer.id.namespace == Namespaces.Peer.CloudUser {
|
} else if peer.id.namespace == Namespaces.Peer.CloudUser {
|
||||||
if let inputPeer = apiInputPeer(peer) {
|
if let inputPeer = apiInputPeer(peer) {
|
||||||
@ -330,7 +330,7 @@ private func removeChat(transaction: Transaction, postbox: Postbox, network: Net
|
|||||||
return requestClearHistory(postbox: postbox, network: network, stateManager: stateManager, inputPeer: inputPeer, maxId: operation.topMessageId?.id ?? Int32.max - 1, justClear: false, type: operation.deleteGloballyIfPossible ? .forEveryone : .forLocalPeer)
|
return requestClearHistory(postbox: postbox, network: network, stateManager: stateManager, inputPeer: inputPeer, maxId: operation.topMessageId?.id ?? Int32.max - 1, justClear: false, type: operation.deleteGloballyIfPossible ? .forEveryone : .forLocalPeer)
|
||||||
|> then(reportSignal)
|
|> then(reportSignal)
|
||||||
|> then(postbox.transaction { transaction -> Void in
|
|> then(postbox.transaction { transaction -> Void in
|
||||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peer.id, namespaces: .not(Namespaces.Message.allScheduled))
|
_internal_clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peer.id, namespaces: .not(Namespaces.Message.allScheduled))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return .complete()
|
return .complete()
|
||||||
@ -376,7 +376,7 @@ private func requestClearHistory(postbox: Postbox, network: Network, stateManage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func clearHistory(transaction: Transaction, postbox: Postbox, network: Network, stateManager: AccountStateManager, peer: Peer, operation: CloudChatClearHistoryOperation) -> Signal<Void, NoError> {
|
private func _internal_clearHistory(transaction: Transaction, postbox: Postbox, network: Network, stateManager: AccountStateManager, peer: Peer, operation: CloudChatClearHistoryOperation) -> Signal<Void, NoError> {
|
||||||
if peer.id.namespace == Namespaces.Peer.CloudGroup || peer.id.namespace == Namespaces.Peer.CloudUser {
|
if peer.id.namespace == Namespaces.Peer.CloudGroup || peer.id.namespace == Namespaces.Peer.CloudUser {
|
||||||
if let inputPeer = apiInputPeer(peer) {
|
if let inputPeer = apiInputPeer(peer) {
|
||||||
return requestClearHistory(postbox: postbox, network: network, stateManager: stateManager, inputPeer: inputPeer, maxId: operation.topMessageId.id, justClear: true, type: operation.type)
|
return requestClearHistory(postbox: postbox, network: network, stateManager: stateManager, inputPeer: inputPeer, maxId: operation.topMessageId.id, justClear: true, type: operation.type)
|
||||||
|
@ -228,7 +228,7 @@ private func synchronizeLocalizationUpdates(accountManager: AccountManager, post
|
|||||||
case .reset:
|
case .reset:
|
||||||
return accountManager.transaction { transaction -> Signal<Void, Void> in
|
return accountManager.transaction { transaction -> Signal<Void, Void> in
|
||||||
let (primary, _) = getLocalization(transaction)
|
let (primary, _) = getLocalization(transaction)
|
||||||
return downloadAndApplyLocalization(accountManager: accountManager, postbox: postbox, network: network, languageCode: primary.code)
|
return _internal_downloadAndApplyLocalization(accountManager: accountManager, postbox: postbox, network: network, languageCode: primary.code)
|
||||||
|> mapError { _ -> Void in
|
|> mapError { _ -> Void in
|
||||||
return Void()
|
return Void()
|
||||||
}
|
}
|
||||||
|
@ -1520,7 +1520,7 @@ private func sendMessage(auxiliaryMethods: AccountAuxiliaryMethods, postbox: Pos
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
replaceOutgoingOperationWithEmptyMessage(transaction: transaction, peerId: messageId.peerId, tagLocalIndex: tagLocalIndex, globallyUniqueId: Int64.random(in: Int64.min ... Int64.max))
|
replaceOutgoingOperationWithEmptyMessage(transaction: transaction, peerId: messageId.peerId, tagLocalIndex: tagLocalIndex, globallyUniqueId: Int64.random(in: Int64.min ... Int64.max))
|
||||||
deleteMessages(transaction: transaction, mediaBox: postbox.mediaBox, ids: [messageId])
|
_internal_deleteMessages(transaction: transaction, mediaBox: postbox.mediaBox, ids: [messageId])
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -276,10 +276,10 @@ func processSecretChatIncomingDecryptedOperations(encryptionProvider: Encryption
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteMessages(transaction: transaction, mediaBox: mediaBox, ids: filteredMessageIds)
|
_internal_deleteMessages(transaction: transaction, mediaBox: mediaBox, ids: filteredMessageIds)
|
||||||
}
|
}
|
||||||
case .clearHistory:
|
case .clearHistory:
|
||||||
clearHistory(transaction: transaction, mediaBox: mediaBox, peerId: peerId, namespaces: .all)
|
_internal_clearHistory(transaction: transaction, mediaBox: mediaBox, peerId: peerId, namespaces: .all)
|
||||||
case let .markMessagesContentAsConsumed(globallyUniqueIds):
|
case let .markMessagesContentAsConsumed(globallyUniqueIds):
|
||||||
var messageIds: [MessageId] = []
|
var messageIds: [MessageId] = []
|
||||||
for id in globallyUniqueIds {
|
for id in globallyUniqueIds {
|
@ -90,7 +90,7 @@ public func preloadedFeaturedStickerSet(network: Network, postbox: Postbox, id:
|
|||||||
return postbox.transaction { transaction -> Signal<Void, NoError> in
|
return postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||||
if let pack = transaction.getOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudFeaturedStickerPacks, itemId: FeaturedStickerPackItemId(id.id).rawValue)?.contents as? FeaturedStickerPackItem {
|
if let pack = transaction.getOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudFeaturedStickerPacks, itemId: FeaturedStickerPackItemId(id.id).rawValue)?.contents as? FeaturedStickerPackItem {
|
||||||
if pack.topItems.count < 5 && pack.topItems.count < pack.info.count {
|
if pack.topItems.count < 5 && pack.topItems.count < pack.info.count {
|
||||||
return requestStickerSet(postbox: postbox, network: network, reference: .id(id: pack.info.id.id, accessHash: pack.info.accessHash))
|
return _internal_requestStickerSet(postbox: postbox, network: network, reference: .id(id: pack.info.id.id, accessHash: pack.info.accessHash))
|
||||||
|> map(Optional.init)
|
|> map(Optional.init)
|
||||||
|> `catch` { _ -> Signal<RequestStickerSetResult?, NoError> in
|
|> `catch` { _ -> Signal<RequestStickerSetResult?, NoError> in
|
||||||
return .single(nil)
|
return .single(nil)
|
||||||
|
@ -1 +0,0 @@
|
|||||||
import Foundation
|
|
@ -51,7 +51,7 @@ func updateLocalizationListStateInteractively(transaction: Transaction, _ f: @es
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public func synchronizedLocalizationListState(postbox: Postbox, network: Network) -> Signal<Never, NoError> {
|
func _internal_synchronizedLocalizationListState(postbox: Postbox, network: Network) -> Signal<Never, NoError> {
|
||||||
return network.request(Api.functions.langpack.getLanguages(langPack: ""))
|
return network.request(Api.functions.langpack.getLanguages(langPack: ""))
|
||||||
|> retryRequest
|
|> retryRequest
|
||||||
|> mapToSignal { languages -> Signal<Never, NoError> in
|
|> mapToSignal { languages -> Signal<Never, NoError> in
|
@ -9,7 +9,7 @@ public enum RequestLocalizationPreviewError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
public func requestLocalizationPreview(network: Network, identifier: String) -> Signal<LocalizationInfo, RequestLocalizationPreviewError> {
|
func _internal_requestLocalizationPreview(network: Network, identifier: String) -> Signal<LocalizationInfo, RequestLocalizationPreviewError> {
|
||||||
return network.request(Api.functions.langpack.getLanguage(langPack: "", langCode: identifier))
|
return network.request(Api.functions.langpack.getLanguage(langPack: "", langCode: identifier))
|
||||||
|> mapError { _ -> RequestLocalizationPreviewError in
|
|> mapError { _ -> RequestLocalizationPreviewError in
|
||||||
return .generic
|
return .generic
|
@ -5,14 +5,14 @@ import SwiftSignalKit
|
|||||||
|
|
||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
public func currentlySuggestedLocalization(network: Network, extractKeys: [String]) -> Signal<SuggestedLocalizationInfo?, NoError> {
|
func _internal_currentlySuggestedLocalization(network: Network, extractKeys: [String]) -> Signal<SuggestedLocalizationInfo?, NoError> {
|
||||||
return network.request(Api.functions.help.getConfig())
|
return network.request(Api.functions.help.getConfig())
|
||||||
|> retryRequest
|
|> retryRequest
|
||||||
|> mapToSignal { result -> Signal<SuggestedLocalizationInfo?, NoError> in
|
|> mapToSignal { result -> Signal<SuggestedLocalizationInfo?, NoError> in
|
||||||
switch result {
|
switch result {
|
||||||
case let .config(config):
|
case let .config(config):
|
||||||
if let suggestedLangCode = config.suggestedLangCode {
|
if let suggestedLangCode = config.suggestedLangCode {
|
||||||
return suggestedLocalizationInfo(network: network, languageCode: suggestedLangCode, extractKeys: extractKeys) |> map(Optional.init)
|
return _internal_suggestedLocalizationInfo(network: network, languageCode: suggestedLangCode, extractKeys: extractKeys) |> map(Optional.init)
|
||||||
} else {
|
} else {
|
||||||
return .single(nil)
|
return .single(nil)
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ public func currentlySuggestedLocalization(network: Network, extractKeys: [Strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func suggestedLocalizationInfo(network: Network, languageCode: String, extractKeys: [String]) -> Signal<SuggestedLocalizationInfo, NoError> {
|
func _internal_suggestedLocalizationInfo(network: Network, languageCode: String, extractKeys: [String]) -> Signal<SuggestedLocalizationInfo, NoError> {
|
||||||
return combineLatest(network.request(Api.functions.langpack.getLanguages(langPack: "")), network.request(Api.functions.langpack.getStrings(langPack: "", langCode: languageCode, keys: extractKeys)))
|
return combineLatest(network.request(Api.functions.langpack.getLanguages(langPack: "")), network.request(Api.functions.langpack.getStrings(langPack: "", langCode: languageCode, keys: extractKeys)))
|
||||||
|> retryRequest
|
|> retryRequest
|
||||||
|> map { languages, strings -> SuggestedLocalizationInfo in
|
|> map { languages, strings -> SuggestedLocalizationInfo in
|
||||||
@ -40,7 +40,7 @@ public func suggestedLocalizationInfo(network: Network, languageCode: String, ex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func availableLocalizations(postbox: Postbox, network: Network, allowCached: Bool) -> Signal<[LocalizationInfo], NoError> {
|
func _internal_availableLocalizations(postbox: Postbox, network: Network, allowCached: Bool) -> Signal<[LocalizationInfo], NoError> {
|
||||||
let cached: Signal<[LocalizationInfo], NoError>
|
let cached: Signal<[LocalizationInfo], NoError>
|
||||||
if allowCached {
|
if allowCached {
|
||||||
cached = postbox.transaction { transaction -> Signal<[LocalizationInfo], NoError> in
|
cached = postbox.transaction { transaction -> Signal<[LocalizationInfo], NoError> in
|
||||||
@ -69,7 +69,7 @@ public enum DownloadLocalizationError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
public func downloadLocalization(network: Network, languageCode: String) -> Signal<Localization, DownloadLocalizationError> {
|
func _internal_downloadLocalization(network: Network, languageCode: String) -> Signal<Localization, DownloadLocalizationError> {
|
||||||
return network.request(Api.functions.langpack.getLangPack(langPack: "", langCode: languageCode))
|
return network.request(Api.functions.langpack.getLangPack(langPack: "", langCode: languageCode))
|
||||||
|> mapError { _ -> DownloadLocalizationError in
|
|> mapError { _ -> DownloadLocalizationError in
|
||||||
return .generic
|
return .generic
|
||||||
@ -100,16 +100,16 @@ public enum DownloadAndApplyLocalizationError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
public func downloadAndApplyLocalization(accountManager: AccountManager, postbox: Postbox, network: Network, languageCode: String) -> Signal<Void, DownloadAndApplyLocalizationError> {
|
func _internal_downloadAndApplyLocalization(accountManager: AccountManager, postbox: Postbox, network: Network, languageCode: String) -> Signal<Void, DownloadAndApplyLocalizationError> {
|
||||||
return requestLocalizationPreview(network: network, identifier: languageCode)
|
return _internal_requestLocalizationPreview(network: network, identifier: languageCode)
|
||||||
|> mapError { _ -> DownloadAndApplyLocalizationError in
|
|> mapError { _ -> DownloadAndApplyLocalizationError in
|
||||||
return .generic
|
return .generic
|
||||||
}
|
}
|
||||||
|> mapToSignal { preview -> Signal<Void, DownloadAndApplyLocalizationError> in
|
|> mapToSignal { preview -> Signal<Void, DownloadAndApplyLocalizationError> in
|
||||||
var primaryAndSecondaryLocalizations: [Signal<Localization, DownloadLocalizationError>] = []
|
var primaryAndSecondaryLocalizations: [Signal<Localization, DownloadLocalizationError>] = []
|
||||||
primaryAndSecondaryLocalizations.append(downloadLocalization(network: network, languageCode: preview.languageCode))
|
primaryAndSecondaryLocalizations.append(_internal_downloadLocalization(network: network, languageCode: preview.languageCode))
|
||||||
if let secondaryCode = preview.baseLanguageCode {
|
if let secondaryCode = preview.baseLanguageCode {
|
||||||
primaryAndSecondaryLocalizations.append(downloadLocalization(network: network, languageCode: secondaryCode))
|
primaryAndSecondaryLocalizations.append(_internal_downloadLocalization(network: network, languageCode: secondaryCode))
|
||||||
}
|
}
|
||||||
return combineLatest(primaryAndSecondaryLocalizations)
|
return combineLatest(primaryAndSecondaryLocalizations)
|
||||||
|> mapError { _ -> DownloadAndApplyLocalizationError in
|
|> mapError { _ -> DownloadAndApplyLocalizationError in
|
@ -4,7 +4,7 @@ import SwiftSignalKit
|
|||||||
|
|
||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
public func markSuggestedLocalizationAsSeenInteractively(postbox: Postbox, languageCode: String) -> Signal<Void, NoError> {
|
func _internal_markSuggestedLocalizationAsSeenInteractively(postbox: Postbox, languageCode: String) -> Signal<Void, NoError> {
|
||||||
return postbox.transaction { transaction -> Void in
|
return postbox.transaction { transaction -> Void in
|
||||||
transaction.updatePreferencesEntry(key: PreferencesKeys.suggestedLocalization, { current in
|
transaction.updatePreferencesEntry(key: PreferencesKeys.suggestedLocalization, { current in
|
||||||
if let current = current as? SuggestedLocalizationEntry {
|
if let current = current as? SuggestedLocalizationEntry {
|
@ -1,5 +1,6 @@
|
|||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
import Postbox
|
||||||
|
import SyncCore
|
||||||
|
|
||||||
public extension TelegramEngine {
|
public extension TelegramEngine {
|
||||||
final class Localization {
|
final class Localization {
|
||||||
@ -12,6 +13,26 @@ public extension TelegramEngine {
|
|||||||
public func getCountriesList(accountManager: AccountManager, langCode: String?, forceUpdate: Bool = false) -> Signal<[Country], NoError> {
|
public func getCountriesList(accountManager: AccountManager, langCode: String?, forceUpdate: Bool = false) -> Signal<[Country], NoError> {
|
||||||
return _internal_getCountriesList(accountManager: accountManager, network: self.account.network, langCode: langCode, forceUpdate: forceUpdate)
|
return _internal_getCountriesList(accountManager: accountManager, network: self.account.network, langCode: langCode, forceUpdate: forceUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func markSuggestedLocalizationAsSeenInteractively(languageCode: String) -> Signal<Void, NoError> {
|
||||||
|
return _internal_markSuggestedLocalizationAsSeenInteractively(postbox: self.account.postbox, languageCode: languageCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func synchronizedLocalizationListState() -> Signal<Never, NoError> {
|
||||||
|
return _internal_synchronizedLocalizationListState(postbox: self.account.postbox, network: self.account.network)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func suggestedLocalizationInfo(languageCode: String, extractKeys: [String]) -> Signal<SuggestedLocalizationInfo, NoError> {
|
||||||
|
return _internal_suggestedLocalizationInfo(network: self.account.network, languageCode: languageCode, extractKeys: extractKeys)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func requestLocalizationPreview(identifier: String) -> Signal<LocalizationInfo, RequestLocalizationPreviewError> {
|
||||||
|
return _internal_requestLocalizationPreview(network: self.account.network, identifier: identifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func downloadAndApplyLocalization(accountManager: AccountManager, languageCode: String) -> Signal<Void, DownloadAndApplyLocalizationError> {
|
||||||
|
return _internal_downloadAndApplyLocalization(accountManager: accountManager, postbox: self.account.postbox, network: self.account.network, languageCode: languageCode)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,5 +47,17 @@ public extension TelegramEngineUnauthorized {
|
|||||||
public func getCountriesList(accountManager: AccountManager, langCode: String?, forceUpdate: Bool = false) -> Signal<[Country], NoError> {
|
public func getCountriesList(accountManager: AccountManager, langCode: String?, forceUpdate: Bool = false) -> Signal<[Country], NoError> {
|
||||||
return _internal_getCountriesList(accountManager: accountManager, network: self.account.network, langCode: langCode, forceUpdate: forceUpdate)
|
return _internal_getCountriesList(accountManager: accountManager, network: self.account.network, langCode: langCode, forceUpdate: forceUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func markSuggestedLocalizationAsSeenInteractively(languageCode: String) -> Signal<Void, NoError> {
|
||||||
|
return _internal_markSuggestedLocalizationAsSeenInteractively(postbox: self.account.postbox, languageCode: languageCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func currentlySuggestedLocalization(extractKeys: [String]) -> Signal<SuggestedLocalizationInfo?, NoError> {
|
||||||
|
return _internal_currentlySuggestedLocalization(network: self.account.network, extractKeys: extractKeys)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func downloadAndApplyLocalization(accountManager: AccountManager, languageCode: String) -> Signal<Void, DownloadAndApplyLocalizationError> {
|
||||||
|
return _internal_downloadAndApplyLocalization(accountManager: accountManager, postbox: self.account.postbox, network: self.account.network, languageCode: languageCode)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,13 @@ import SwiftSignalKit
|
|||||||
|
|
||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
public func applyMaxReadIndexInteractively(postbox: Postbox, stateManager: AccountStateManager, index: MessageIndex) -> Signal<Void, NoError> {
|
func _internal_applyMaxReadIndexInteractively(postbox: Postbox, stateManager: AccountStateManager, index: MessageIndex) -> Signal<Void, NoError> {
|
||||||
return postbox.transaction { transaction -> Void in
|
return postbox.transaction { transaction -> Void in
|
||||||
applyMaxReadIndexInteractively(transaction: transaction, stateManager: stateManager, index: index)
|
_internal_applyMaxReadIndexInteractively(transaction: transaction, stateManager: stateManager, index: index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyMaxReadIndexInteractively(transaction: Transaction, stateManager: AccountStateManager, index: MessageIndex) {
|
func _internal_applyMaxReadIndexInteractively(transaction: Transaction, stateManager: AccountStateManager, index: MessageIndex) {
|
||||||
let messageIds = transaction.applyInteractiveReadMaxIndex(index)
|
let messageIds = transaction.applyInteractiveReadMaxIndex(index)
|
||||||
if index.id.peerId.namespace == Namespaces.Peer.SecretChat {
|
if index.id.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||||
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970)
|
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970)
|
@ -5,7 +5,7 @@ import TelegramApi
|
|||||||
|
|
||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
public func clearCloudDraftsInteractively(postbox: Postbox, network: Network, accountPeerId: PeerId) -> Signal<Void, NoError> {
|
func _internal_clearCloudDraftsInteractively(postbox: Postbox, network: Network, accountPeerId: PeerId) -> Signal<Void, NoError> {
|
||||||
return network.request(Api.functions.messages.getAllDrafts())
|
return network.request(Api.functions.messages.getAllDrafts())
|
||||||
|> retryRequest
|
|> retryRequest
|
||||||
|> mapToSignal { updates -> Signal<Void, NoError> in
|
|> mapToSignal { updates -> Signal<Void, NoError> in
|
@ -23,7 +23,7 @@ func addMessageMediaResourceIdsToRemove(message: Message, resourceIds: inout [Wr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func deleteMessages(transaction: Transaction, mediaBox: MediaBox, ids: [MessageId], deleteMedia: Bool = true, manualAddMessageThreadStatsDifference: ((MessageId, Int, Int) -> Void)? = nil) {
|
func _internal_deleteMessages(transaction: Transaction, mediaBox: MediaBox, ids: [MessageId], deleteMedia: Bool = true, manualAddMessageThreadStatsDifference: ((MessageId, Int, Int) -> Void)? = nil) {
|
||||||
var resourceIds: [WrappedMediaResourceId] = []
|
var resourceIds: [WrappedMediaResourceId] = []
|
||||||
if deleteMedia {
|
if deleteMedia {
|
||||||
for id in ids {
|
for id in ids {
|
||||||
@ -57,7 +57,7 @@ public func deleteMessages(transaction: Transaction, mediaBox: MediaBox, ids: [M
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public func deleteAllMessagesWithAuthor(transaction: Transaction, mediaBox: MediaBox, peerId: PeerId, authorId: PeerId, namespace: MessageId.Namespace) {
|
func _internal_deleteAllMessagesWithAuthor(transaction: Transaction, mediaBox: MediaBox, peerId: PeerId, authorId: PeerId, namespace: MessageId.Namespace) {
|
||||||
var resourceIds: [WrappedMediaResourceId] = []
|
var resourceIds: [WrappedMediaResourceId] = []
|
||||||
transaction.removeAllMessagesWithAuthor(peerId, authorId: authorId, namespace: namespace, forEachMedia: { media in
|
transaction.removeAllMessagesWithAuthor(peerId, authorId: authorId, namespace: namespace, forEachMedia: { media in
|
||||||
addMessageMediaResourceIdsToRemove(media: media, resourceIds: &resourceIds)
|
addMessageMediaResourceIdsToRemove(media: media, resourceIds: &resourceIds)
|
||||||
@ -67,7 +67,7 @@ public func deleteAllMessagesWithAuthor(transaction: Transaction, mediaBox: Medi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func deleteAllMessagesWithForwardAuthor(transaction: Transaction, mediaBox: MediaBox, peerId: PeerId, forwardAuthorId: PeerId, namespace: MessageId.Namespace) {
|
func _internal_deleteAllMessagesWithForwardAuthor(transaction: Transaction, mediaBox: MediaBox, peerId: PeerId, forwardAuthorId: PeerId, namespace: MessageId.Namespace) {
|
||||||
var resourceIds: [WrappedMediaResourceId] = []
|
var resourceIds: [WrappedMediaResourceId] = []
|
||||||
transaction.removeAllMessagesWithForwardAuthor(peerId, forwardAuthorId: forwardAuthorId, namespace: namespace, forEachMedia: { media in
|
transaction.removeAllMessagesWithForwardAuthor(peerId, forwardAuthorId: forwardAuthorId, namespace: namespace, forEachMedia: { media in
|
||||||
addMessageMediaResourceIdsToRemove(media: media, resourceIds: &resourceIds)
|
addMessageMediaResourceIdsToRemove(media: media, resourceIds: &resourceIds)
|
||||||
@ -77,7 +77,7 @@ public func deleteAllMessagesWithForwardAuthor(transaction: Transaction, mediaBo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func clearHistory(transaction: Transaction, mediaBox: MediaBox, peerId: PeerId, namespaces: MessageIdNamespaces) {
|
func _internal_clearHistory(transaction: Transaction, mediaBox: MediaBox, peerId: PeerId, namespaces: MessageIdNamespaces) {
|
||||||
if peerId.namespace == Namespaces.Peer.SecretChat {
|
if peerId.namespace == Namespaces.Peer.SecretChat {
|
||||||
var resourceIds: [WrappedMediaResourceId] = []
|
var resourceIds: [WrappedMediaResourceId] = []
|
||||||
transaction.withAllMessages(peerId: peerId, { message in
|
transaction.withAllMessages(peerId: peerId, { message in
|
||||||
@ -96,7 +96,7 @@ public enum ClearCallHistoryError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
public func clearCallHistory(account: Account, forEveryone: Bool) -> Signal<Never, ClearCallHistoryError> {
|
func _internal_clearCallHistory(account: Account, forEveryone: Bool) -> Signal<Never, ClearCallHistoryError> {
|
||||||
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||||
var flags: Int32 = 0
|
var flags: Int32 = 0
|
||||||
if forEveryone {
|
if forEveryone {
|
||||||
@ -146,7 +146,7 @@ public enum SetChatMessageAutoremoveTimeoutError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
public func setChatMessageAutoremoveTimeoutInteractively(account: Account, peerId: PeerId, timeout: Int32?) -> Signal<Never, SetChatMessageAutoremoveTimeoutError> {
|
func _internal_setChatMessageAutoremoveTimeoutInteractively(account: Account, peerId: PeerId, timeout: Int32?) -> Signal<Never, SetChatMessageAutoremoveTimeoutError> {
|
||||||
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||||
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ import MtProtoKit
|
|||||||
|
|
||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
public func deleteMessagesInteractively(account: Account, messageIds: [MessageId], type: InteractiveMessagesDeletionType, deleteAllInGroup: Bool = false) -> Signal<Void, NoError> {
|
func _internal_deleteMessagesInteractively(account: Account, messageIds: [MessageId], type: InteractiveMessagesDeletionType, deleteAllInGroup: Bool = false) -> Signal<Void, NoError> {
|
||||||
return account.postbox.transaction { transaction -> Void in
|
return account.postbox.transaction { transaction -> Void in
|
||||||
deleteMessagesInteractively(transaction: transaction, stateManager: account.stateManager, postbox: account.postbox, messageIds: messageIds, type: type, removeIfPossiblyDelivered: true)
|
deleteMessagesInteractively(transaction: transaction, stateManager: account.stateManager, postbox: account.postbox, messageIds: messageIds, type: type, removeIfPossiblyDelivered: true)
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ func deleteMessagesInteractively(transaction: Transaction, stateManager: Account
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteMessages(transaction: transaction, mediaBox: postbox.mediaBox, ids: messageIds)
|
_internal_deleteMessages(transaction: transaction, mediaBox: postbox.mediaBox, ids: messageIds)
|
||||||
|
|
||||||
stateManager?.notifyDeletedMessages(messageIds: messageIds)
|
stateManager?.notifyDeletedMessages(messageIds: messageIds)
|
||||||
|
|
||||||
@ -97,22 +97,22 @@ func deleteMessagesInteractively(transaction: Transaction, stateManager: Account
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func clearHistoryInteractively(postbox: Postbox, peerId: PeerId, type: InteractiveHistoryClearingType) -> Signal<Void, NoError> {
|
func _internal_clearHistoryInteractively(postbox: Postbox, peerId: PeerId, type: InteractiveHistoryClearingType) -> Signal<Void, NoError> {
|
||||||
return postbox.transaction { transaction -> Void in
|
return postbox.transaction { transaction -> Void in
|
||||||
if peerId.namespace == Namespaces.Peer.CloudUser || peerId.namespace == Namespaces.Peer.CloudGroup || peerId.namespace == Namespaces.Peer.CloudChannel {
|
if peerId.namespace == Namespaces.Peer.CloudUser || peerId.namespace == Namespaces.Peer.CloudGroup || peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||||
cloudChatAddClearHistoryOperation(transaction: transaction, peerId: peerId, explicitTopMessageId: nil, type: CloudChatClearHistoryType(type))
|
cloudChatAddClearHistoryOperation(transaction: transaction, peerId: peerId, explicitTopMessageId: nil, type: CloudChatClearHistoryType(type))
|
||||||
if type == .scheduledMessages {
|
if type == .scheduledMessages {
|
||||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peerId, namespaces: .just(Namespaces.Message.allScheduled))
|
_internal_clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peerId, namespaces: .just(Namespaces.Message.allScheduled))
|
||||||
} else {
|
} else {
|
||||||
var topIndex: MessageIndex?
|
var topIndex: MessageIndex?
|
||||||
if let topMessageId = transaction.getTopPeerMessageId(peerId: peerId, namespace: Namespaces.Message.Cloud), let topMessage = transaction.getMessage(topMessageId) {
|
if let topMessageId = transaction.getTopPeerMessageId(peerId: peerId, namespace: Namespaces.Message.Cloud), let topMessage = transaction.getMessage(topMessageId) {
|
||||||
topIndex = topMessage.index
|
topIndex = topMessage.index
|
||||||
}
|
}
|
||||||
|
|
||||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peerId, namespaces: .not(Namespaces.Message.allScheduled))
|
_internal_clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peerId, namespaces: .not(Namespaces.Message.allScheduled))
|
||||||
if let cachedData = transaction.getPeerCachedData(peerId: peerId) as? CachedChannelData, let migrationReference = cachedData.migrationReference {
|
if let cachedData = transaction.getPeerCachedData(peerId: peerId) as? CachedChannelData, let migrationReference = cachedData.migrationReference {
|
||||||
cloudChatAddClearHistoryOperation(transaction: transaction, peerId: migrationReference.maxMessageId.peerId, explicitTopMessageId: MessageId(peerId: migrationReference.maxMessageId.peerId, namespace: migrationReference.maxMessageId.namespace, id: migrationReference.maxMessageId.id + 1), type: CloudChatClearHistoryType(type))
|
cloudChatAddClearHistoryOperation(transaction: transaction, peerId: migrationReference.maxMessageId.peerId, explicitTopMessageId: MessageId(peerId: migrationReference.maxMessageId.peerId, namespace: migrationReference.maxMessageId.namespace, id: migrationReference.maxMessageId.id + 1), type: CloudChatClearHistoryType(type))
|
||||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: migrationReference.maxMessageId.peerId, namespaces: .all)
|
_internal_clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: migrationReference.maxMessageId.peerId, namespaces: .all)
|
||||||
}
|
}
|
||||||
if let topIndex = topIndex {
|
if let topIndex = topIndex {
|
||||||
if peerId.namespace == Namespaces.Peer.CloudUser {
|
if peerId.namespace == Namespaces.Peer.CloudUser {
|
||||||
@ -123,7 +123,7 @@ public func clearHistoryInteractively(postbox: Postbox, peerId: PeerId, type: In
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if peerId.namespace == Namespaces.Peer.SecretChat {
|
} else if peerId.namespace == Namespaces.Peer.SecretChat {
|
||||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peerId, namespaces: .all)
|
_internal_clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peerId, namespaces: .all)
|
||||||
|
|
||||||
if let state = transaction.getPeerChatState(peerId) as? SecretChatState {
|
if let state = transaction.getPeerChatState(peerId) as? SecretChatState {
|
||||||
var layer: SecretChatLayer?
|
var layer: SecretChatLayer?
|
||||||
@ -147,7 +147,7 @@ public func clearHistoryInteractively(postbox: Postbox, peerId: PeerId, type: In
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func clearAuthorHistory(account: Account, peerId: PeerId, memberId: PeerId) -> Signal<Void, NoError> {
|
func _internal_clearAuthorHistory(account: Account, peerId: PeerId, memberId: PeerId) -> Signal<Void, NoError> {
|
||||||
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||||
if let peer = transaction.getPeer(peerId), let memberPeer = transaction.getPeer(memberId), let inputChannel = apiInputChannel(peer), let inputUser = apiInputUser(memberPeer) {
|
if let peer = transaction.getPeer(peerId), let memberPeer = transaction.getPeer(memberId), let inputChannel = apiInputChannel(peer), let inputUser = apiInputUser(memberPeer) {
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ public func clearAuthorHistory(account: Account, peerId: PeerId, memberId: PeerI
|
|||||||
|> `catch` { success -> Signal<Void, NoError> in
|
|> `catch` { success -> Signal<Void, NoError> in
|
||||||
if success {
|
if success {
|
||||||
return account.postbox.transaction { transaction -> Void in
|
return account.postbox.transaction { transaction -> Void in
|
||||||
deleteAllMessagesWithAuthor(transaction: transaction, mediaBox: account.postbox.mediaBox, peerId: peerId, authorId: memberId, namespace: Namespaces.Message.Cloud)
|
_internal_deleteAllMessagesWithAuthor(transaction: transaction, mediaBox: account.postbox.mediaBox, peerId: peerId, authorId: memberId, namespace: Namespaces.Message.Cloud)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return .complete()
|
return .complete()
|
@ -24,7 +24,7 @@ public enum MessageActionCallbackError {
|
|||||||
case userBlocked
|
case userBlocked
|
||||||
}
|
}
|
||||||
|
|
||||||
public func requestMessageActionCallbackPasswordCheck(account: Account, messageId: MessageId, isGame: Bool, data: MemoryBuffer?) -> Signal<Never, MessageActionCallbackError> {
|
func _internal_requestMessageActionCallbackPasswordCheck(account: Account, messageId: MessageId, isGame: Bool, data: MemoryBuffer?) -> Signal<Never, MessageActionCallbackError> {
|
||||||
return account.postbox.loadedPeerWithId(messageId.peerId)
|
return account.postbox.loadedPeerWithId(messageId.peerId)
|
||||||
|> castError(MessageActionCallbackError.self)
|
|> castError(MessageActionCallbackError.self)
|
||||||
|> take(1)
|
|> take(1)
|
||||||
@ -72,7 +72,7 @@ public func requestMessageActionCallbackPasswordCheck(account: Account, messageI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func requestMessageActionCallback(account: Account, messageId: MessageId, isGame :Bool, password: String?, data: MemoryBuffer?) -> Signal<MessageActionCallbackResult, MessageActionCallbackError> {
|
func _internal_requestMessageActionCallback(account: Account, messageId: MessageId, isGame :Bool, password: String?, data: MemoryBuffer?) -> Signal<MessageActionCallbackResult, MessageActionCallbackError> {
|
||||||
return account.postbox.loadedPeerWithId(messageId.peerId)
|
return account.postbox.loadedPeerWithId(messageId.peerId)
|
||||||
|> castError(MessageActionCallbackError.self)
|
|> castError(MessageActionCallbackError.self)
|
||||||
|> take(1)
|
|> take(1)
|
||||||
@ -179,7 +179,7 @@ public enum MessageActionUrlSubject {
|
|||||||
case url(String)
|
case url(String)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func requestMessageActionUrlAuth(account: Account, subject: MessageActionUrlSubject) -> Signal<MessageActionUrlAuthResult, NoError> {
|
func _internal_requestMessageActionUrlAuth(account: Account, subject: MessageActionUrlSubject) -> Signal<MessageActionUrlAuthResult, NoError> {
|
||||||
let request: Signal<Api.UrlAuthResult?, MTRpcError>
|
let request: Signal<Api.UrlAuthResult?, MTRpcError>
|
||||||
var flags: Int32 = 0
|
var flags: Int32 = 0
|
||||||
switch subject {
|
switch subject {
|
||||||
@ -221,7 +221,7 @@ public func requestMessageActionUrlAuth(account: Account, subject: MessageAction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func acceptMessageActionUrlAuth(account: Account, subject: MessageActionUrlSubject, allowWriteAccess: Bool) -> Signal<MessageActionUrlAuthResult, NoError> {
|
func _internal_acceptMessageActionUrlAuth(account: Account, subject: MessageActionUrlSubject, allowWriteAccess: Bool) -> Signal<MessageActionUrlAuthResult, NoError> {
|
||||||
var flags: Int32 = 0
|
var flags: Int32 = 0
|
||||||
if allowWriteAccess {
|
if allowWriteAccess {
|
||||||
flags |= Int32(1 << 0)
|
flags |= Int32(1 << 0)
|
@ -5,7 +5,7 @@ import TelegramApi
|
|||||||
|
|
||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
public func sendScheduledMessageNowInteractively(postbox: Postbox, messageId: MessageId) -> Signal<Never, NoError> {
|
func _internal_sendScheduledMessageNowInteractively(postbox: Postbox, messageId: MessageId) -> Signal<Never, NoError> {
|
||||||
return postbox.transaction { transaction -> Void in
|
return postbox.transaction { transaction -> Void in
|
||||||
transaction.setPendingMessageAction(type: .sendScheduledMessageImmediately, id: messageId, action: SendScheduledMessageImmediatelyAction())
|
transaction.setPendingMessageAction(type: .sendScheduledMessageImmediately, id: messageId, action: SendScheduledMessageImmediatelyAction())
|
||||||
}
|
}
|
@ -184,7 +184,7 @@ private func mergedResult(_ state: SearchMessagesState) -> SearchMessagesResult
|
|||||||
return SearchMessagesResult(messages: messages, readStates: readStates, totalCount: state.main.totalCount + (state.additional?.totalCount ?? 0), completed: state.main.completed && (state.additional?.completed ?? true))
|
return SearchMessagesResult(messages: messages, readStates: readStates, totalCount: state.main.totalCount + (state.additional?.totalCount ?? 0), completed: state.main.completed && (state.additional?.completed ?? true))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func searchMessages(account: Account, location: SearchMessagesLocation, query: String, state: SearchMessagesState?, limit: Int32 = 100) -> Signal<(SearchMessagesResult, SearchMessagesState), NoError> {
|
func _internal_searchMessages(account: Account, location: SearchMessagesLocation, query: String, state: SearchMessagesState?, limit: Int32 = 100) -> Signal<(SearchMessagesResult, SearchMessagesState), NoError> {
|
||||||
let remoteSearchResult: Signal<(Api.messages.Messages?, Api.messages.Messages?), NoError>
|
let remoteSearchResult: Signal<(Api.messages.Messages?, Api.messages.Messages?), NoError>
|
||||||
switch location {
|
switch location {
|
||||||
case let .peer(peerId, fromId, tags, topMsgId, minDate, maxDate):
|
case let .peer(peerId, fromId, tags, topMsgId, minDate, maxDate):
|
||||||
@ -379,7 +379,7 @@ public func searchMessages(account: Account, location: SearchMessagesLocation, q
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func downloadMessage(postbox: Postbox, network: Network, messageId: MessageId) -> Signal<Message?, NoError> {
|
func _internal_downloadMessage(postbox: Postbox, network: Network, messageId: MessageId) -> Signal<Message?, NoError> {
|
||||||
return postbox.transaction { transaction -> Message? in
|
return postbox.transaction { transaction -> Message? in
|
||||||
return transaction.getMessage(messageId)
|
return transaction.getMessage(messageId)
|
||||||
} |> mapToSignal { message in
|
} |> mapToSignal { message in
|
||||||
@ -562,7 +562,7 @@ func fetchRemoteMessage(postbox: Postbox, source: FetchMessageHistoryHoleSource,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func searchMessageIdByTimestamp(account: Account, peerId: PeerId, threadId: Int64?, timestamp: Int32) -> Signal<MessageId?, NoError> {
|
func _internal_searchMessageIdByTimestamp(account: Account, peerId: PeerId, threadId: Int64?, timestamp: Int32) -> Signal<MessageId?, NoError> {
|
||||||
return account.postbox.transaction { transaction -> Signal<MessageId?, NoError> in
|
return account.postbox.transaction { transaction -> Signal<MessageId?, NoError> in
|
||||||
if peerId.namespace == Namespaces.Peer.SecretChat {
|
if peerId.namespace == Namespaces.Peer.SecretChat {
|
||||||
return .single(transaction.findClosestMessageIdByTimestamp(peerId: peerId, timestamp: timestamp))
|
return .single(transaction.findClosestMessageIdByTimestamp(peerId: peerId, timestamp: timestamp))
|
||||||
@ -672,7 +672,7 @@ public enum UpdatedRemotePeerError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
public func updatedRemotePeer(postbox: Postbox, network: Network, peer: PeerReference) -> Signal<Peer, UpdatedRemotePeerError> {
|
func _internal_updatedRemotePeer(postbox: Postbox, network: Network, peer: PeerReference) -> Signal<Peer, UpdatedRemotePeerError> {
|
||||||
if let inputUser = peer.inputUser {
|
if let inputUser = peer.inputUser {
|
||||||
return network.request(Api.functions.users.getUsers(id: [inputUser]))
|
return network.request(Api.functions.users.getUsers(id: [inputUser]))
|
||||||
|> mapError { _ -> UpdatedRemotePeerError in
|
|> mapError { _ -> UpdatedRemotePeerError in
|
@ -0,0 +1,89 @@
|
|||||||
|
import SwiftSignalKit
|
||||||
|
import Postbox
|
||||||
|
import SyncCore
|
||||||
|
|
||||||
|
public extension TelegramEngine {
|
||||||
|
final class Messages {
|
||||||
|
private let account: Account
|
||||||
|
|
||||||
|
init(account: Account) {
|
||||||
|
self.account = account
|
||||||
|
}
|
||||||
|
|
||||||
|
public func clearCloudDraftsInteractively() -> Signal<Void, NoError> {
|
||||||
|
return _internal_clearCloudDraftsInteractively(postbox: self.account.postbox, network: self.account.network, accountPeerId: self.account.peerId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func applyMaxReadIndexInteractively(index: MessageIndex) -> Signal<Void, NoError> {
|
||||||
|
return _internal_applyMaxReadIndexInteractively(postbox: self.account.postbox, stateManager: self.account.stateManager, index: index)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func sendScheduledMessageNowInteractively(messageId: MessageId) -> Signal<Never, NoError> {
|
||||||
|
return _internal_sendScheduledMessageNowInteractively(postbox: self.account.postbox, messageId: messageId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func requestMessageActionCallbackPasswordCheck(messageId: MessageId, isGame: Bool, data: MemoryBuffer?) -> Signal<Never, MessageActionCallbackError> {
|
||||||
|
return _internal_requestMessageActionCallbackPasswordCheck(account: self.account, messageId: messageId, isGame: isGame, data: data)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func requestMessageActionCallback(messageId: MessageId, isGame: Bool, password: String?, data: MemoryBuffer?) -> Signal<MessageActionCallbackResult, MessageActionCallbackError> {
|
||||||
|
return _internal_requestMessageActionCallback(account: self.account, messageId: messageId, isGame: isGame, password: password, data: data)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func requestMessageActionUrlAuth(subject: MessageActionUrlSubject) -> Signal<MessageActionUrlAuthResult, NoError> {
|
||||||
|
_internal_requestMessageActionUrlAuth(account: self.account, subject: subject)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func acceptMessageActionUrlAuth(subject: MessageActionUrlSubject, allowWriteAccess: Bool) -> Signal<MessageActionUrlAuthResult, NoError> {
|
||||||
|
return _internal_acceptMessageActionUrlAuth(account: self.account, subject: subject, allowWriteAccess: allowWriteAccess)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func searchMessages(location: SearchMessagesLocation, query: String, state: SearchMessagesState?, limit: Int32 = 100) -> Signal<(SearchMessagesResult, SearchMessagesState), NoError> {
|
||||||
|
return _internal_searchMessages(account: self.account, location: location, query: query, state: state, limit: limit)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func downloadMessage(messageId: MessageId) -> Signal<Message?, NoError> {
|
||||||
|
return _internal_downloadMessage(postbox: self.account.postbox, network: self.account.network, messageId: messageId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func searchMessageIdByTimestamp(peerId: PeerId, threadId: Int64?, timestamp: Int32) -> Signal<MessageId?, NoError> {
|
||||||
|
return _internal_searchMessageIdByTimestamp(account: self.account, peerId: peerId, threadId: threadId, timestamp: timestamp)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func deleteMessages(transaction: Transaction, ids: [MessageId], deleteMedia: Bool = true, manualAddMessageThreadStatsDifference: ((MessageId, Int, Int) -> Void)? = nil) {
|
||||||
|
return _internal_deleteMessages(transaction: transaction, mediaBox: self.account.postbox.mediaBox, ids: ids, deleteMedia: deleteMedia, manualAddMessageThreadStatsDifference: manualAddMessageThreadStatsDifference)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func deleteAllMessagesWithAuthor(transaction: Transaction, peerId: PeerId, authorId: PeerId, namespace: MessageId.Namespace) {
|
||||||
|
return _internal_deleteAllMessagesWithAuthor(transaction: transaction, mediaBox: self.account.postbox.mediaBox, peerId: peerId, authorId: authorId, namespace: namespace)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func deleteAllMessagesWithForwardAuthor(transaction: Transaction, peerId: PeerId, forwardAuthorId: PeerId, namespace: MessageId.Namespace) {
|
||||||
|
return _internal_deleteAllMessagesWithForwardAuthor(transaction: transaction, mediaBox: self.account.postbox.mediaBox, peerId: peerId, forwardAuthorId: forwardAuthorId, namespace: namespace)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func clearCallHistory(forEveryone: Bool) -> Signal<Never, ClearCallHistoryError> {
|
||||||
|
return _internal_clearCallHistory(account: self.account, forEveryone: forEveryone)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func deleteMessagesInteractively(messageIds: [MessageId], type: InteractiveMessagesDeletionType, deleteAllInGroup: Bool = false) -> Signal<Void, NoError> {
|
||||||
|
return _internal_deleteMessagesInteractively(account: self.account, messageIds: messageIds, type: type, deleteAllInGroup: deleteAllInGroup)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func clearHistoryInteractively(peerId: PeerId, type: InteractiveHistoryClearingType) -> Signal<Void, NoError> {
|
||||||
|
return _internal_clearHistoryInteractively(postbox: self.account.postbox, peerId: peerId, type: type)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func clearAuthorHistory(peerId: PeerId, memberId: PeerId) -> Signal<Void, NoError> {
|
||||||
|
return _internal_clearAuthorHistory(account: self.account, peerId: peerId, memberId: memberId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func requestEditMessage(messageId: MessageId, text: String, media: RequestEditMessageMedia, entities: TextEntitiesMessageAttribute? = nil, disableUrlPreview: Bool = false, scheduleTime: Int32? = nil) -> Signal<RequestEditMessageResult, RequestEditMessageError> {
|
||||||
|
return _internal_requestEditMessage(account: self.account, messageId: messageId, text: text, media: media, entities: entities, disableUrlPreview: disableUrlPreview, scheduleTime: scheduleTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func requestEditLiveLocation(messageId: MessageId, stop: Bool, coordinate: (latitude: Double, longitude: Double, accuracyRadius: Int32?)?, heading: Int32?, proximityNotificationRadius: Int32?) -> Signal<Void, NoError> {
|
||||||
|
return _internal_requestEditLiveLocation(postbox: self.account.postbox, network: self.account.network, stateManager: self.account.stateManager, messageId: messageId, stop: stop, coordinate: coordinate, heading: heading, proximityNotificationRadius: proximityNotificationRadius)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -174,7 +174,7 @@ extension BotPaymentRequestedInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func fetchBotPaymentForm(postbox: Postbox, network: Network, messageId: MessageId, themeParams: [String: Any]?) -> Signal<BotPaymentForm, BotPaymentFormRequestError> {
|
func _internal_fetchBotPaymentForm(postbox: Postbox, network: Network, messageId: MessageId, themeParams: [String: Any]?) -> Signal<BotPaymentForm, BotPaymentFormRequestError> {
|
||||||
return postbox.transaction { transaction -> Api.InputPeer? in
|
return postbox.transaction { transaction -> Api.InputPeer? in
|
||||||
return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer)
|
return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer)
|
||||||
}
|
}
|
||||||
@ -269,7 +269,7 @@ extension BotPaymentShippingOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func validateBotPaymentForm(account: Account, saveInfo: Bool, messageId: MessageId, formInfo: BotPaymentRequestedInfo) -> Signal<BotPaymentValidatedFormInfo, ValidateBotPaymentFormError> {
|
func _internal_validateBotPaymentForm(account: Account, saveInfo: Bool, messageId: MessageId, formInfo: BotPaymentRequestedInfo) -> Signal<BotPaymentValidatedFormInfo, ValidateBotPaymentFormError> {
|
||||||
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||||
return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer)
|
return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer)
|
||||||
}
|
}
|
||||||
@ -347,7 +347,7 @@ public enum SendBotPaymentResult {
|
|||||||
case externalVerificationRequired(url: String)
|
case externalVerificationRequired(url: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func sendBotPaymentForm(account: Account, messageId: MessageId, formId: Int64, validatedInfoId: String?, shippingOptionId: String?, tipAmount: Int64?, credentials: BotPaymentCredentials) -> Signal<SendBotPaymentResult, SendBotPaymentFormError> {
|
func _internal_sendBotPaymentForm(account: Account, messageId: MessageId, formId: Int64, validatedInfoId: String?, shippingOptionId: String?, tipAmount: Int64?, credentials: BotPaymentCredentials) -> Signal<SendBotPaymentResult, SendBotPaymentFormError> {
|
||||||
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||||
return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer)
|
return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer)
|
||||||
}
|
}
|
||||||
@ -461,7 +461,7 @@ public enum RequestBotPaymentReceiptError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
public func requestBotPaymentReceipt(account: Account, messageId: MessageId) -> Signal<BotPaymentReceipt, RequestBotPaymentReceiptError> {
|
func _internal_requestBotPaymentReceipt(account: Account, messageId: MessageId) -> Signal<BotPaymentReceipt, RequestBotPaymentReceiptError> {
|
||||||
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||||
return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer)
|
return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer)
|
||||||
}
|
}
|
||||||
@ -545,7 +545,7 @@ public struct BotPaymentInfo: OptionSet {
|
|||||||
public static let shippingInfo = BotPaymentInfo(rawValue: 1 << 1)
|
public static let shippingInfo = BotPaymentInfo(rawValue: 1 << 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func clearBotPaymentInfo(network: Network, info: BotPaymentInfo) -> Signal<Void, NoError> {
|
func _internal_clearBotPaymentInfo(network: Network, info: BotPaymentInfo) -> Signal<Void, NoError> {
|
||||||
var flags: Int32 = 0
|
var flags: Int32 = 0
|
||||||
if info.contains(.paymentInfo) {
|
if info.contains(.paymentInfo) {
|
||||||
flags |= (1 << 0)
|
flags |= (1 << 0)
|
@ -1,4 +1,5 @@
|
|||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
import Postbox
|
||||||
|
|
||||||
public extension TelegramEngine {
|
public extension TelegramEngine {
|
||||||
final class Payments {
|
final class Payments {
|
||||||
@ -11,5 +12,25 @@ public extension TelegramEngine {
|
|||||||
public func getBankCardInfo(cardNumber: String) -> Signal<BankCardInfo?, NoError> {
|
public func getBankCardInfo(cardNumber: String) -> Signal<BankCardInfo?, NoError> {
|
||||||
return _internal_getBankCardInfo(account: self.account, cardNumber: cardNumber)
|
return _internal_getBankCardInfo(account: self.account, cardNumber: cardNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func fetchBotPaymentForm(messageId: MessageId, themeParams: [String: Any]?) -> Signal<BotPaymentForm, BotPaymentFormRequestError> {
|
||||||
|
return _internal_fetchBotPaymentForm(postbox: self.account.postbox, network: self.account.network, messageId: messageId, themeParams: themeParams)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func validateBotPaymentForm(saveInfo: Bool, messageId: MessageId, formInfo: BotPaymentRequestedInfo) -> Signal<BotPaymentValidatedFormInfo, ValidateBotPaymentFormError> {
|
||||||
|
return _internal_validateBotPaymentForm(account: self.account, saveInfo: saveInfo, messageId: messageId, formInfo: formInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func sendBotPaymentForm(messageId: MessageId, formId: Int64, validatedInfoId: String?, shippingOptionId: String?, tipAmount: Int64?, credentials: BotPaymentCredentials) -> Signal<SendBotPaymentResult, SendBotPaymentFormError> {
|
||||||
|
return _internal_sendBotPaymentForm(account: self.account, messageId: messageId, formId: formId, validatedInfoId: validatedInfoId, shippingOptionId: shippingOptionId, tipAmount: tipAmount, credentials: credentials)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func requestBotPaymentReceipt(messageId: MessageId) -> Signal<BotPaymentReceipt, RequestBotPaymentReceiptError> {
|
||||||
|
return _internal_requestBotPaymentReceipt(account: self.account, messageId: messageId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func clearBotPaymentInfo(info: BotPaymentInfo) -> Signal<Void, NoError> {
|
||||||
|
return _internal_clearBotPaymentInfo(network: self.account.network, info: info)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import SwiftSignalKit
|
|||||||
import Postbox
|
import Postbox
|
||||||
import TelegramApi
|
import TelegramApi
|
||||||
|
|
||||||
public func chatOnlineMembers(postbox: Postbox, network: Network, peerId: PeerId) -> Signal<Int32, NoError> {
|
func _internal_chatOnlineMembers(postbox: Postbox, network: Network, peerId: PeerId) -> Signal<Int32, NoError> {
|
||||||
return postbox.transaction { transaction -> Api.InputPeer? in
|
return postbox.transaction { transaction -> Api.InputPeer? in
|
||||||
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ public enum ConvertGroupToSupergroupError {
|
|||||||
case tooManyChannels
|
case tooManyChannels
|
||||||
}
|
}
|
||||||
|
|
||||||
public func convertGroupToSupergroup(account: Account, peerId: PeerId) -> Signal<PeerId, ConvertGroupToSupergroupError> {
|
func _internal_convertGroupToSupergroup(account: Account, peerId: PeerId) -> Signal<PeerId, ConvertGroupToSupergroupError> {
|
||||||
return account.network.request(Api.functions.messages.migrateChat(chatId: peerId.id._internalGetInt32Value()))
|
return account.network.request(Api.functions.messages.migrateChat(chatId: peerId.id._internalGetInt32Value()))
|
||||||
|> mapError { error -> ConvertGroupToSupergroupError in
|
|> mapError { error -> ConvertGroupToSupergroupError in
|
||||||
if error.errorDescription == "CHANNELS_TOO_MUCH" {
|
if error.errorDescription == "CHANNELS_TOO_MUCH" {
|
@ -13,7 +13,7 @@ public enum CreateGroupError {
|
|||||||
case serverProvided(String)
|
case serverProvided(String)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func createGroup(account: Account, title: String, peerIds: [PeerId]) -> Signal<PeerId?, CreateGroupError> {
|
func _internal_createGroup(account: Account, title: String, peerIds: [PeerId]) -> Signal<PeerId?, CreateGroupError> {
|
||||||
return account.postbox.transaction { transaction -> Signal<PeerId?, CreateGroupError> in
|
return account.postbox.transaction { transaction -> Signal<PeerId?, CreateGroupError> in
|
||||||
var inputUsers: [Api.InputUser] = []
|
var inputUsers: [Api.InputUser] = []
|
||||||
for peerId in peerIds {
|
for peerId in peerIds {
|
@ -9,7 +9,7 @@ public enum CreateSecretChatError {
|
|||||||
case limitExceeded
|
case limitExceeded
|
||||||
}
|
}
|
||||||
|
|
||||||
public func createSecretChat(account: Account, peerId: PeerId) -> Signal<PeerId, CreateSecretChatError> {
|
func _internal_createSecretChat(account: Account, peerId: PeerId) -> Signal<PeerId, CreateSecretChatError> {
|
||||||
return account.postbox.transaction { transaction -> Signal<PeerId, CreateSecretChatError> in
|
return account.postbox.transaction { transaction -> Signal<PeerId, CreateSecretChatError> in
|
||||||
if let peer = transaction.getPeer(peerId), let inputUser = apiInputUser(peer) {
|
if let peer = transaction.getPeer(peerId), let inputUser = apiInputUser(peer) {
|
||||||
return validatedEncryptionConfig(postbox: account.postbox, network: account.network)
|
return validatedEncryptionConfig(postbox: account.postbox, network: account.network)
|
@ -1,5 +1,6 @@
|
|||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
import Postbox
|
||||||
|
import SyncCore
|
||||||
|
|
||||||
public enum AddressNameValidationStatus: Equatable {
|
public enum AddressNameValidationStatus: Equatable {
|
||||||
case checking
|
case checking
|
||||||
@ -69,5 +70,29 @@ public extension TelegramEngine {
|
|||||||
public func searchPeers(query: String) -> Signal<([FoundPeer], [FoundPeer]), NoError> {
|
public func searchPeers(query: String) -> Signal<([FoundPeer], [FoundPeer]), NoError> {
|
||||||
return _internal_searchPeers(account: self.account, query: query)
|
return _internal_searchPeers(account: self.account, query: query)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func updatedRemotePeer(peer: PeerReference) -> Signal<Peer, UpdatedRemotePeerError> {
|
||||||
|
return _internal_updatedRemotePeer(postbox: self.account.postbox, network: self.account.network, peer: peer)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func chatOnlineMembers(peerId: PeerId) -> Signal<Int32, NoError> {
|
||||||
|
return _internal_chatOnlineMembers(postbox: self.account.postbox, network: self.account.network, peerId: peerId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func convertGroupToSupergroup(peerId: PeerId) -> Signal<PeerId, ConvertGroupToSupergroupError> {
|
||||||
|
return _internal_convertGroupToSupergroup(account: self.account, peerId: peerId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func createGroup(title: String, peerIds: [PeerId]) -> Signal<PeerId?, CreateGroupError> {
|
||||||
|
return _internal_createGroup(account: self.account, title: title, peerIds: peerIds)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func createSecretChat(peerId: PeerId) -> Signal<PeerId, CreateSecretChatError> {
|
||||||
|
return _internal_createSecretChat(account: self.account, peerId: peerId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func setChatMessageAutoremoveTimeoutInteractively(peerId: PeerId, timeout: Int32?) -> Signal<Never, SetChatMessageAutoremoveTimeoutError> {
|
||||||
|
return _internal_setChatMessageAutoremoveTimeoutInteractively(account: self.account, peerId: peerId, timeout: timeout)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user