diff --git a/submodules/TelegramCore/Sources/InvitationLinks.swift b/submodules/TelegramCore/Sources/InvitationLinks.swift index 760780660e..a452722179 100644 --- a/submodules/TelegramCore/Sources/InvitationLinks.swift +++ b/submodules/TelegramCore/Sources/InvitationLinks.swift @@ -12,7 +12,7 @@ public func ensuredExistingPeerExportedInvitation(account: Account, peerId: Peer var flags: Int32 = (1 << 2) if let _ = peer as? TelegramChannel { if let cachedData = transaction.getPeerCachedData(peerId: peerId) as? CachedChannelData, cachedData.exportedInvitation != nil && !revokeExisted { - return .complete() + return .single(cachedData.exportedInvitation) } else { return account.network.request(Api.functions.messages.exportChatInvite(flags: flags, peer: inputPeer, expireDate: nil, usageLimit: nil)) |> retryRequest @@ -90,17 +90,26 @@ public func createPeerExportedInvitation(account: Account, peerId: PeerId, expir } |> switchToLatest } -public func peerExportedInvitations(account: Account, peerId: PeerId) -> Signal<[ExportedInvitation]?, NoError> { - return account.postbox.transaction { transaction -> Signal<[ExportedInvitation]?, NoError> in +public struct ExportedInvitations : Equatable { + public let list: [ExportedInvitation]? + public let totalCount: Int32 +} + +public func peerExportedInvitations(account: Account, peerId: PeerId, offsetLink: String? = nil) -> Signal { + return account.postbox.transaction { transaction -> Signal in if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) { - return account.network.request(Api.functions.messages.getExportedChatInvites(flags: 0, peer: inputPeer, adminId: nil, offsetLink: nil, limit: 100)) + var flags: Int32 = 0 + if let _ = offsetLink { + flags |= (1 << 2) + } + return account.network.request(Api.functions.messages.getExportedChatInvites(flags: 0, peer: inputPeer, adminId: nil, offsetLink: offsetLink, limit: 100)) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) } - |> mapToSignal { result -> Signal<[ExportedInvitation]?, NoError> in - return account.postbox.transaction { transaction -> [ExportedInvitation]? in - if let result = result, case let .exportedChatInvites(_, apiInvites, users) = result { + |> mapToSignal { result -> Signal in + return account.postbox.transaction { transaction -> ExportedInvitations? in + if let result = result, case let .exportedChatInvites(count, apiInvites, users) = result { var peers: [Peer] = [] var peersMap: [PeerId: Peer] = [:] for user in users { @@ -118,7 +127,7 @@ public func peerExportedInvitations(account: Account, peerId: PeerId) -> Signal< invites.append(invite) } } - return invites + return ExportedInvitations(list: invites, totalCount: count) } else { return nil } @@ -146,20 +155,22 @@ public func editPeerExportedInvitation(account: Account, peerId: PeerId, link: S } return account.network.request(Api.functions.messages.editExportedChatInvite(flags: flags, peer: inputPeer, link: link, expireDate: expireDate, usageLimit: usageLimit)) |> mapError { _ in return EditPeerExportedInvitationError.generic } - |> map { result -> ExportedInvitation? in - if case let .exportedChatInvite(invite, users) = result { - var peers: [Peer] = [] - for user in users { - let telegramUser = TelegramUser(user: user) - peers.append(telegramUser) + |> mapToSignal { result -> Signal in + return account.postbox.transaction { transaction in + if case let .exportedChatInvite(invite, users) = result { + var peers: [Peer] = [] + for user in users { + let telegramUser = TelegramUser(user: user) + peers.append(telegramUser) + } + updatePeers(transaction: transaction, peers: peers, update: { _, updated -> Peer in + return updated + }) + return ExportedInvitation(apiExportedInvite: invite) + } else { + return nil } - updatePeers(transaction: transaction, peers: peers, update: { _, updated -> Peer in - return updated - }) - return ExportedInvitation(apiExportedInvite: invite) - } else { - return nil - } + } |> mapError { _ in .generic } } } else { return .complete() @@ -173,13 +184,29 @@ public enum RevokePeerExportedInvitationError { case generic } -public func revokePeerExportedInvitation(account: Account, peerId: PeerId, link: String) -> Signal { - return account.postbox.transaction { transaction -> Signal in +public func revokePeerExportedInvitation(account: Account, peerId: PeerId, link: String) -> Signal { + return account.postbox.transaction { transaction -> Signal in if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) { let flags: Int32 = (1 << 2) return account.network.request(Api.functions.messages.editExportedChatInvite(flags: flags, peer: inputPeer, link: link, expireDate: nil, usageLimit: nil)) |> mapError { _ in return RevokePeerExportedInvitationError.generic } - |> ignoreValues + |> mapToSignal { result -> Signal in + return account.postbox.transaction { transaction in + if case let .exportedChatInvite(invite, users) = result { + var peers: [Peer] = [] + for user in users { + let telegramUser = TelegramUser(user: user) + peers.append(telegramUser) + } + updatePeers(transaction: transaction, peers: peers, update: { _, updated -> Peer in + return updated + }) + return ExportedInvitation(apiExportedInvite: invite) + } else { + return nil + } + } |> mapError { _ in .generic } + } } else { return .complete() } diff --git a/third-party/mozjpeg/mozjpeg/src/jconfig.h b/third-party/mozjpeg/mozjpeg/src/jconfig.h new file mode 100644 index 0000000000..beccc163e6 --- /dev/null +++ b/third-party/mozjpeg/mozjpeg/src/jconfig.h @@ -0,0 +1,73 @@ +/* Version ID for the JPEG library. + * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". + */ +#define JPEG_LIB_VERSION 80 + +/* libjpeg-turbo version */ +#define LIBJPEG_TURBO_VERSION 4.0.0 + +/* libjpeg-turbo version in integer form */ +#define LIBJPEG_TURBO_VERSION_NUMBER 4000000 + +/* Support arithmetic encoding */ +#define C_ARITH_CODING_SUPPORTED 1 + +/* Support arithmetic decoding */ +#define D_ARITH_CODING_SUPPORTED 1 + +/* Support in-memory source/destination managers */ +/* #undef MEM_SRCDST_SUPPORTED */ + +/* Use accelerated SIMD routines. */ +#define WITH_SIMD 1 + +/* + * Define BITS_IN_JSAMPLE as either + * 8 for 8-bit sample values (the usual setting) + * 12 for 12-bit sample values + * Only 8 and 12 are legal data precisions for lossy JPEG according to the + * JPEG standard, and the IJG code does not support anything else! + * We do not support run-time selection of data precision, sorry. + */ + +#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define if you need to include to get size_t. */ +#define NEED_SYS_TYPES_H 1 + +/* Define if you have BSD-like bzero and bcopy in rather than + memset/memcpy in . */ +/* #undef NEED_BSD_STRINGS */ + +/* Define to 1 if the system has the type `unsigned char'. */ +#define HAVE_UNSIGNED_CHAR 1 + +/* Define to 1 if the system has the type `unsigned short'. */ +#define HAVE_UNSIGNED_SHORT 1 + +/* Compiler does not support pointers to undefined structures. */ +/* #undef INCOMPLETE_TYPES_BROKEN */ + +/* Define if your (broken) compiler shifts signed values as if they were + unsigned. */ +/* #undef RIGHT_SHIFT_IS_UNSIGNED */ + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* #undef __CHAR_UNSIGNED__ */ +#endif + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ diff --git a/third-party/mozjpeg/mozjpeg/src/jconfigint.h b/third-party/mozjpeg/mozjpeg/src/jconfigint.h new file mode 100644 index 0000000000..4d0059156a --- /dev/null +++ b/third-party/mozjpeg/mozjpeg/src/jconfigint.h @@ -0,0 +1,31 @@ +/* libjpeg-turbo build number */ +#define BUILD "20201129" + +/* Compiler's inline keyword */ +#undef inline + +/* How to obtain function inlining. */ +#define INLINE __inline__ __attribute__((always_inline)) + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "mozjpeg" + +/* Version number of package */ +#define VERSION "4.0.0" + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 8 + +/* Define if your compiler has __builtin_ctzl() and sizeof(unsigned long) == sizeof(size_t). */ +#define HAVE_BUILTIN_CTZL + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_INTRIN_H */ + +#if defined(_MSC_VER) && defined(HAVE_INTRIN_H) +#if (SIZEOF_SIZE_T == 8) +#define HAVE_BITSCANFORWARD64 +#elif (SIZEOF_SIZE_T == 4) +#define HAVE_BITSCANFORWARD +#endif +#endif