mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-03 11:21:06 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
27ae29592b
@ -903,7 +903,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[1301522832] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
|
dict[1301522832] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
|
||||||
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
|
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
|
||||||
dict[1237678029] = { return Api.StarGift.parse_starGift($0) }
|
dict[1237678029] = { return Api.StarGift.parse_starGift($0) }
|
||||||
dict[708628759] = { return Api.StarRefProgram.parse_starRefProgram($0) }
|
dict[-586389774] = { return Api.StarRefProgram.parse_starRefProgram($0) }
|
||||||
dict[-1145654109] = { return Api.StarsAmount.parse_starsAmount($0) }
|
dict[-1145654109] = { return Api.StarsAmount.parse_starsAmount($0) }
|
||||||
dict[1577421297] = { return Api.StarsGiftOption.parse_starsGiftOption($0) }
|
dict[1577421297] = { return Api.StarsGiftOption.parse_starsGiftOption($0) }
|
||||||
dict[-1798404822] = { return Api.StarsGiveawayOption.parse_starsGiveawayOption($0) }
|
dict[-1798404822] = { return Api.StarsGiveawayOption.parse_starsGiveawayOption($0) }
|
||||||
@ -950,7 +950,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[-1870436597] = { return Api.StoryView.parse_storyViewPublicForward($0) }
|
dict[-1870436597] = { return Api.StoryView.parse_storyViewPublicForward($0) }
|
||||||
dict[-1116418231] = { return Api.StoryView.parse_storyViewPublicRepost($0) }
|
dict[-1116418231] = { return Api.StoryView.parse_storyViewPublicRepost($0) }
|
||||||
dict[-1923523370] = { return Api.StoryViews.parse_storyViews($0) }
|
dict[-1923523370] = { return Api.StoryViews.parse_storyViews($0) }
|
||||||
dict[642695037] = { return Api.SuggestedBotStarRef.parse_suggestedBotStarRef($0) }
|
|
||||||
dict[1964978502] = { return Api.TextWithEntities.parse_textWithEntities($0) }
|
dict[1964978502] = { return Api.TextWithEntities.parse_textWithEntities($0) }
|
||||||
dict[-1609668650] = { return Api.Theme.parse_theme($0) }
|
dict[-1609668650] = { return Api.Theme.parse_theme($0) }
|
||||||
dict[-94849324] = { return Api.ThemeSettings.parse_themeSettings($0) }
|
dict[-94849324] = { return Api.ThemeSettings.parse_themeSettings($0) }
|
||||||
@ -1371,7 +1370,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[-919881925] = { return Api.payments.StarsRevenueStats.parse_starsRevenueStats($0) }
|
dict[-919881925] = { return Api.payments.StarsRevenueStats.parse_starsRevenueStats($0) }
|
||||||
dict[497778871] = { return Api.payments.StarsRevenueWithdrawalUrl.parse_starsRevenueWithdrawalUrl($0) }
|
dict[497778871] = { return Api.payments.StarsRevenueWithdrawalUrl.parse_starsRevenueWithdrawalUrl($0) }
|
||||||
dict[1822222573] = { return Api.payments.StarsStatus.parse_starsStatus($0) }
|
dict[1822222573] = { return Api.payments.StarsStatus.parse_starsStatus($0) }
|
||||||
dict[-937776981] = { return Api.payments.SuggestedStarRefBots.parse_suggestedStarRefBots($0) }
|
dict[-1261053863] = { return Api.payments.SuggestedStarRefBots.parse_suggestedStarRefBots($0) }
|
||||||
dict[1801827607] = { return Api.payments.UserStarGifts.parse_userStarGifts($0) }
|
dict[1801827607] = { return Api.payments.UserStarGifts.parse_userStarGifts($0) }
|
||||||
dict[-784000893] = { return Api.payments.ValidatedRequestedInfo.parse_validatedRequestedInfo($0) }
|
dict[-784000893] = { return Api.payments.ValidatedRequestedInfo.parse_validatedRequestedInfo($0) }
|
||||||
dict[541839704] = { return Api.phone.ExportedGroupCallInvite.parse_exportedGroupCallInvite($0) }
|
dict[541839704] = { return Api.phone.ExportedGroupCallInvite.parse_exportedGroupCallInvite($0) }
|
||||||
@ -2111,8 +2110,6 @@ public extension Api {
|
|||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.StoryViews:
|
case let _1 as Api.StoryViews:
|
||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.SuggestedBotStarRef:
|
|
||||||
_1.serialize(buffer, boxed)
|
|
||||||
case let _1 as Api.TextWithEntities:
|
case let _1 as Api.TextWithEntities:
|
||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.Theme:
|
case let _1 as Api.Theme:
|
||||||
|
@ -644,44 +644,54 @@ public extension Api {
|
|||||||
}
|
}
|
||||||
public extension Api {
|
public extension Api {
|
||||||
enum StarRefProgram: TypeConstructorDescription {
|
enum StarRefProgram: TypeConstructorDescription {
|
||||||
case starRefProgram(flags: Int32, commissionPermille: Int32, durationMonths: Int32?, endDate: Int32?)
|
case starRefProgram(flags: Int32, botId: Int64, commissionPermille: Int32, durationMonths: Int32?, endDate: Int32?, dailyRevenuePerUser: Api.StarsAmount?)
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
switch self {
|
switch self {
|
||||||
case .starRefProgram(let flags, let commissionPermille, let durationMonths, let endDate):
|
case .starRefProgram(let flags, let botId, let commissionPermille, let durationMonths, let endDate, let dailyRevenuePerUser):
|
||||||
if boxed {
|
if boxed {
|
||||||
buffer.appendInt32(708628759)
|
buffer.appendInt32(-586389774)
|
||||||
}
|
}
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
|
serializeInt64(botId, buffer: buffer, boxed: false)
|
||||||
serializeInt32(commissionPermille, buffer: buffer, boxed: false)
|
serializeInt32(commissionPermille, buffer: buffer, boxed: false)
|
||||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(durationMonths!, buffer: buffer, boxed: false)}
|
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(durationMonths!, buffer: buffer, boxed: false)}
|
||||||
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(endDate!, buffer: buffer, boxed: false)}
|
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(endDate!, buffer: buffer, boxed: false)}
|
||||||
|
if Int(flags) & Int(1 << 2) != 0 {dailyRevenuePerUser!.serialize(buffer, true)}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||||
switch self {
|
switch self {
|
||||||
case .starRefProgram(let flags, let commissionPermille, let durationMonths, let endDate):
|
case .starRefProgram(let flags, let botId, let commissionPermille, let durationMonths, let endDate, let dailyRevenuePerUser):
|
||||||
return ("starRefProgram", [("flags", flags as Any), ("commissionPermille", commissionPermille as Any), ("durationMonths", durationMonths as Any), ("endDate", endDate as Any)])
|
return ("starRefProgram", [("flags", flags as Any), ("botId", botId as Any), ("commissionPermille", commissionPermille as Any), ("durationMonths", durationMonths as Any), ("endDate", endDate as Any), ("dailyRevenuePerUser", dailyRevenuePerUser as Any)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func parse_starRefProgram(_ reader: BufferReader) -> StarRefProgram? {
|
public static func parse_starRefProgram(_ reader: BufferReader) -> StarRefProgram? {
|
||||||
var _1: Int32?
|
var _1: Int32?
|
||||||
_1 = reader.readInt32()
|
_1 = reader.readInt32()
|
||||||
var _2: Int32?
|
var _2: Int64?
|
||||||
_2 = reader.readInt32()
|
_2 = reader.readInt64()
|
||||||
var _3: Int32?
|
var _3: Int32?
|
||||||
if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() }
|
_3 = reader.readInt32()
|
||||||
var _4: Int32?
|
var _4: Int32?
|
||||||
if Int(_1!) & Int(1 << 1) != 0 {_4 = reader.readInt32() }
|
if Int(_1!) & Int(1 << 0) != 0 {_4 = reader.readInt32() }
|
||||||
|
var _5: Int32?
|
||||||
|
if Int(_1!) & Int(1 << 1) != 0 {_5 = reader.readInt32() }
|
||||||
|
var _6: Api.StarsAmount?
|
||||||
|
if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() {
|
||||||
|
_6 = Api.parse(reader, signature: signature) as? Api.StarsAmount
|
||||||
|
} }
|
||||||
let _c1 = _1 != nil
|
let _c1 = _1 != nil
|
||||||
let _c2 = _2 != nil
|
let _c2 = _2 != nil
|
||||||
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
|
let _c3 = _3 != nil
|
||||||
let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil
|
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
|
||||||
if _c1 && _c2 && _c3 && _c4 {
|
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
|
||||||
return Api.StarRefProgram.starRefProgram(flags: _1!, commissionPermille: _2!, durationMonths: _3, endDate: _4)
|
let _c6 = (Int(_1!) & Int(1 << 2) == 0) || _6 != nil
|
||||||
|
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||||
|
return Api.StarRefProgram.starRefProgram(flags: _1!, botId: _2!, commissionPermille: _3!, durationMonths: _4, endDate: _5, dailyRevenuePerUser: _6)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -272,54 +272,6 @@ public extension Api {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public extension Api {
|
|
||||||
enum SuggestedBotStarRef: TypeConstructorDescription {
|
|
||||||
case suggestedBotStarRef(flags: Int32, botId: Int64, commissionPermille: Int32, durationMonths: Int32?)
|
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
|
||||||
switch self {
|
|
||||||
case .suggestedBotStarRef(let flags, let botId, let commissionPermille, let durationMonths):
|
|
||||||
if boxed {
|
|
||||||
buffer.appendInt32(642695037)
|
|
||||||
}
|
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
|
||||||
serializeInt64(botId, buffer: buffer, boxed: false)
|
|
||||||
serializeInt32(commissionPermille, buffer: buffer, boxed: false)
|
|
||||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(durationMonths!, buffer: buffer, boxed: false)}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
|
||||||
switch self {
|
|
||||||
case .suggestedBotStarRef(let flags, let botId, let commissionPermille, let durationMonths):
|
|
||||||
return ("suggestedBotStarRef", [("flags", flags as Any), ("botId", botId as Any), ("commissionPermille", commissionPermille as Any), ("durationMonths", durationMonths as Any)])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func parse_suggestedBotStarRef(_ reader: BufferReader) -> SuggestedBotStarRef? {
|
|
||||||
var _1: Int32?
|
|
||||||
_1 = reader.readInt32()
|
|
||||||
var _2: Int64?
|
|
||||||
_2 = reader.readInt64()
|
|
||||||
var _3: Int32?
|
|
||||||
_3 = reader.readInt32()
|
|
||||||
var _4: Int32?
|
|
||||||
if Int(_1!) & Int(1 << 0) != 0 {_4 = reader.readInt32() }
|
|
||||||
let _c1 = _1 != nil
|
|
||||||
let _c2 = _2 != nil
|
|
||||||
let _c3 = _3 != nil
|
|
||||||
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
|
|
||||||
if _c1 && _c2 && _c3 && _c4 {
|
|
||||||
return Api.SuggestedBotStarRef.suggestedBotStarRef(flags: _1!, botId: _2!, commissionPermille: _3!, durationMonths: _4)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public extension Api {
|
public extension Api {
|
||||||
enum TextWithEntities: TypeConstructorDescription {
|
enum TextWithEntities: TypeConstructorDescription {
|
||||||
case textWithEntities(text: String, entities: [Api.MessageEntity])
|
case textWithEntities(text: String, entities: [Api.MessageEntity])
|
||||||
|
@ -214,13 +214,13 @@ public extension Api.payments {
|
|||||||
}
|
}
|
||||||
public extension Api.payments {
|
public extension Api.payments {
|
||||||
enum SuggestedStarRefBots: TypeConstructorDescription {
|
enum SuggestedStarRefBots: TypeConstructorDescription {
|
||||||
case suggestedStarRefBots(flags: Int32, count: Int32, suggestedBots: [Api.SuggestedBotStarRef], users: [Api.User], nextOffset: String?)
|
case suggestedStarRefBots(flags: Int32, count: Int32, suggestedBots: [Api.StarRefProgram], users: [Api.User], nextOffset: String?)
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
switch self {
|
switch self {
|
||||||
case .suggestedStarRefBots(let flags, let count, let suggestedBots, let users, let nextOffset):
|
case .suggestedStarRefBots(let flags, let count, let suggestedBots, let users, let nextOffset):
|
||||||
if boxed {
|
if boxed {
|
||||||
buffer.appendInt32(-937776981)
|
buffer.appendInt32(-1261053863)
|
||||||
}
|
}
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
serializeInt32(count, buffer: buffer, boxed: false)
|
serializeInt32(count, buffer: buffer, boxed: false)
|
||||||
@ -251,9 +251,9 @@ public extension Api.payments {
|
|||||||
_1 = reader.readInt32()
|
_1 = reader.readInt32()
|
||||||
var _2: Int32?
|
var _2: Int32?
|
||||||
_2 = reader.readInt32()
|
_2 = reader.readInt32()
|
||||||
var _3: [Api.SuggestedBotStarRef]?
|
var _3: [Api.StarRefProgram]?
|
||||||
if let _ = reader.readInt32() {
|
if let _ = reader.readInt32() {
|
||||||
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SuggestedBotStarRef.self)
|
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StarRefProgram.self)
|
||||||
}
|
}
|
||||||
var _4: [Api.User]?
|
var _4: [Api.User]?
|
||||||
if let _ = reader.readInt32() {
|
if let _ = reader.readInt32() {
|
||||||
|
@ -627,17 +627,24 @@ extension TelegramBusinessChatLinks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class TelegramStarRefProgram: Codable, Equatable {
|
public final class TelegramStarRefProgram: Codable, Equatable {
|
||||||
|
public let botId: PeerId
|
||||||
public let commissionPermille: Int32
|
public let commissionPermille: Int32
|
||||||
public let durationMonths: Int32?
|
public let durationMonths: Int32?
|
||||||
public let endDate: Int32?
|
public let endDate: Int32?
|
||||||
|
public let dailyRevenuePerUser: StarsAmount?
|
||||||
|
|
||||||
public init(commissionPermille: Int32, durationMonths: Int32?, endDate: Int32?) {
|
public init(botId: PeerId, commissionPermille: Int32, durationMonths: Int32?, endDate: Int32?, dailyRevenuePerUser: StarsAmount?) {
|
||||||
|
self.botId = botId
|
||||||
self.commissionPermille = commissionPermille
|
self.commissionPermille = commissionPermille
|
||||||
self.durationMonths = durationMonths
|
self.durationMonths = durationMonths
|
||||||
self.endDate = endDate
|
self.endDate = endDate
|
||||||
|
self.dailyRevenuePerUser = dailyRevenuePerUser
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func ==(lhs: TelegramStarRefProgram, rhs: TelegramStarRefProgram) -> Bool {
|
public static func ==(lhs: TelegramStarRefProgram, rhs: TelegramStarRefProgram) -> Bool {
|
||||||
|
if lhs.botId != rhs.botId {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if lhs.commissionPermille != rhs.commissionPermille {
|
if lhs.commissionPermille != rhs.commissionPermille {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -647,6 +654,9 @@ public final class TelegramStarRefProgram: Codable, Equatable {
|
|||||||
if lhs.endDate != rhs.endDate {
|
if lhs.endDate != rhs.endDate {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.dailyRevenuePerUser != rhs.dailyRevenuePerUser {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -654,8 +664,8 @@ public final class TelegramStarRefProgram: Codable, Equatable {
|
|||||||
extension TelegramStarRefProgram {
|
extension TelegramStarRefProgram {
|
||||||
convenience init(apiStarRefProgram: Api.StarRefProgram) {
|
convenience init(apiStarRefProgram: Api.StarRefProgram) {
|
||||||
switch apiStarRefProgram {
|
switch apiStarRefProgram {
|
||||||
case let .starRefProgram(_, commissionPermille, durationMonths, endDate):
|
case let .starRefProgram(_, botId, commissionPermille, durationMonths, endDate, dailyRevenuePerUser):
|
||||||
self.init(commissionPermille: commissionPermille, durationMonths: durationMonths, endDate: endDate)
|
self.init(botId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)), commissionPermille: commissionPermille, durationMonths: durationMonths, endDate: endDate, dailyRevenuePerUser: dailyRevenuePerUser.flatMap(StarsAmount.init(apiAmount:)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -752,28 +752,24 @@ func _internal_requestConnectedStarRefBots(account: Account, id: EnginePeer.Id,
|
|||||||
public final class TelegramSuggestedStarRefBotList: Equatable {
|
public final class TelegramSuggestedStarRefBotList: Equatable {
|
||||||
public enum SortMode {
|
public enum SortMode {
|
||||||
case date
|
case date
|
||||||
case commission
|
case profitability
|
||||||
|
case revenue
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class Item: Equatable {
|
public final class Item: Equatable {
|
||||||
public let peer: EnginePeer
|
public let peer: EnginePeer
|
||||||
public let commissionPermille: Int32
|
public let program: TelegramStarRefProgram
|
||||||
public let durationMonths: Int32?
|
|
||||||
|
|
||||||
public init(peer: EnginePeer, commissionPermille: Int32, durationMonths: Int32?) {
|
public init(peer: EnginePeer, program: TelegramStarRefProgram) {
|
||||||
self.peer = peer
|
self.peer = peer
|
||||||
self.commissionPermille = commissionPermille
|
self.program = program
|
||||||
self.durationMonths = durationMonths
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func ==(lhs: Item, rhs: Item) -> Bool {
|
public static func ==(lhs: Item, rhs: Item) -> Bool {
|
||||||
if lhs.peer != rhs.peer {
|
if lhs.peer != rhs.peer {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if lhs.commissionPermille != rhs.commissionPermille {
|
if lhs.program != rhs.program {
|
||||||
return false
|
|
||||||
}
|
|
||||||
if lhs.durationMonths != rhs.durationMonths {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -795,7 +791,7 @@ public final class TelegramSuggestedStarRefBotList: Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func _internal_requestSuggestedStarRefBots(account: Account, id: EnginePeer.Id, orderByCommission: Bool, offset: String?, limit: Int) -> Signal<TelegramSuggestedStarRefBotList?, NoError> {
|
func _internal_requestSuggestedStarRefBots(account: Account, id: EnginePeer.Id, sortMode: TelegramSuggestedStarRefBotList.SortMode, offset: String?, limit: Int) -> Signal<TelegramSuggestedStarRefBotList?, NoError> {
|
||||||
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||||
return transaction.getPeer(id).flatMap(apiInputPeer)
|
return transaction.getPeer(id).flatMap(apiInputPeer)
|
||||||
}
|
}
|
||||||
@ -804,8 +800,13 @@ func _internal_requestSuggestedStarRefBots(account: Account, id: EnginePeer.Id,
|
|||||||
return .single(nil)
|
return .single(nil)
|
||||||
}
|
}
|
||||||
var flags: Int32 = 0
|
var flags: Int32 = 0
|
||||||
if orderByCommission {
|
switch sortMode {
|
||||||
flags |= 1 << 2
|
case .revenue:
|
||||||
|
flags |= 1 << 0
|
||||||
|
case .date:
|
||||||
|
flags |= 1 << 1
|
||||||
|
case .profitability:
|
||||||
|
break
|
||||||
}
|
}
|
||||||
return account.network.request(Api.functions.payments.getSuggestedStarRefBots(
|
return account.network.request(Api.functions.payments.getSuggestedStarRefBots(
|
||||||
flags: flags,
|
flags: flags,
|
||||||
@ -827,18 +828,15 @@ func _internal_requestSuggestedStarRefBots(account: Account, id: EnginePeer.Id,
|
|||||||
updatePeers(transaction: transaction, accountPeerId: account.peerId, peers: AccumulatedPeers(users: users))
|
updatePeers(transaction: transaction, accountPeerId: account.peerId, peers: AccumulatedPeers(users: users))
|
||||||
|
|
||||||
var items: [TelegramSuggestedStarRefBotList.Item] = []
|
var items: [TelegramSuggestedStarRefBotList.Item] = []
|
||||||
for suggestedBot in suggestedBots {
|
for starRefProgram in suggestedBots {
|
||||||
switch suggestedBot {
|
let parsedProgram = TelegramStarRefProgram(apiStarRefProgram: starRefProgram)
|
||||||
case let .suggestedBotStarRef(_, botId, commissionPermille, durationMonths):
|
guard let botPeer = transaction.getPeer(parsedProgram.botId) else {
|
||||||
guard let botPeer = transaction.getPeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId))) else {
|
continue
|
||||||
continue
|
|
||||||
}
|
|
||||||
items.append(TelegramSuggestedStarRefBotList.Item(
|
|
||||||
peer: EnginePeer(botPeer),
|
|
||||||
commissionPermille: commissionPermille,
|
|
||||||
durationMonths: durationMonths
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
items.append(TelegramSuggestedStarRefBotList.Item(
|
||||||
|
peer: EnginePeer(botPeer),
|
||||||
|
program: parsedProgram
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
return TelegramSuggestedStarRefBotList(items: items, totalCount: Int(count), nextOffset: nextOffset)
|
return TelegramSuggestedStarRefBotList(items: items, totalCount: Int(count), nextOffset: nextOffset)
|
||||||
@ -1010,3 +1008,48 @@ func _internal_getStarRefBotConnection(account: Account, id: EnginePeer.Id, targ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _internal_getPossibleStarRefBotTargets(account: Account) -> Signal<[EnginePeer], NoError> {
|
||||||
|
return combineLatest(
|
||||||
|
account.network.request(Api.functions.bots.getAdminedBots())
|
||||||
|
|> `catch` { _ -> Signal<[Api.User], NoError> in
|
||||||
|
return .single([])
|
||||||
|
},
|
||||||
|
account.network.request(Api.functions.channels.getAdminedPublicChannels(flags: 0))
|
||||||
|
|> map(Optional.init)
|
||||||
|
|> `catch` { _ -> Signal<Api.messages.Chats?, NoError> in
|
||||||
|
return .single(nil)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|> mapToSignal { apiBots, apiChannels -> Signal<[EnginePeer], NoError> in
|
||||||
|
return account.postbox.transaction { transaction -> [EnginePeer] in
|
||||||
|
var result: [EnginePeer] = []
|
||||||
|
|
||||||
|
if let peer = transaction.getPeer(account.peerId) {
|
||||||
|
result.append(EnginePeer(peer))
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePeers(transaction: transaction, accountPeerId: account.peerId, peers: AccumulatedPeers(users: apiBots))
|
||||||
|
for bot in apiBots {
|
||||||
|
if let peer = transaction.getPeer(bot.peerId) {
|
||||||
|
result.append(EnginePeer(peer))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let apiChannels {
|
||||||
|
switch apiChannels {
|
||||||
|
case let .chats(chats), let .chatsSlice(_, chats):
|
||||||
|
updatePeers(transaction: transaction, accountPeerId: account.peerId, peers: AccumulatedPeers(chats: chats, users: []))
|
||||||
|
|
||||||
|
for chat in chats {
|
||||||
|
if let peer = transaction.getPeer(chat.peerId) {
|
||||||
|
result.append(EnginePeer(peer))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1641,8 +1641,8 @@ public extension TelegramEngine {
|
|||||||
return _internal_requestConnectedStarRefBots(account: self.account, id: id, offset: offset, limit: limit)
|
return _internal_requestConnectedStarRefBots(account: self.account, id: id, offset: offset, limit: limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func requestSuggestedStarRefBots(id: EnginePeer.Id, orderByCommission: Bool, offset: String?, limit: Int) -> Signal<TelegramSuggestedStarRefBotList?, NoError> {
|
public func requestSuggestedStarRefBots(id: EnginePeer.Id, sortMode: TelegramSuggestedStarRefBotList.SortMode, offset: String?, limit: Int) -> Signal<TelegramSuggestedStarRefBotList?, NoError> {
|
||||||
return _internal_requestSuggestedStarRefBots(account: self.account, id: id, orderByCommission: orderByCommission, offset: offset, limit: limit)
|
return _internal_requestSuggestedStarRefBots(account: self.account, id: id, sortMode: sortMode, offset: offset, limit: limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func connectStarRefBot(id: EnginePeer.Id, botId: EnginePeer.Id) -> Signal<TelegramConnectedStarRefBotList.Item, ConnectStarRefBotError> {
|
public func connectStarRefBot(id: EnginePeer.Id, botId: EnginePeer.Id) -> Signal<TelegramConnectedStarRefBotList.Item, ConnectStarRefBotError> {
|
||||||
@ -1656,6 +1656,10 @@ public extension TelegramEngine {
|
|||||||
public func getStarRefBotConnection(id: EnginePeer.Id, targetId: EnginePeer.Id) -> Signal<TelegramConnectedStarRefBotList.Item?, NoError> {
|
public func getStarRefBotConnection(id: EnginePeer.Id, targetId: EnginePeer.Id) -> Signal<TelegramConnectedStarRefBotList.Item?, NoError> {
|
||||||
return _internal_getStarRefBotConnection(account: self.account, id: id, targetId: targetId)
|
return _internal_getStarRefBotConnection(account: self.account, id: id, targetId: targetId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func getPossibleStarRefBotTargets() -> Signal<[EnginePeer], NoError> {
|
||||||
|
return _internal_getPossibleStarRefBotTargets(account: self.account)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +412,8 @@ If you end your affiliate program:
|
|||||||
|
|
||||||
let availableModes: [(TelegramSuggestedStarRefBotList.SortMode, String)] = [
|
let availableModes: [(TelegramSuggestedStarRefBotList.SortMode, String)] = [
|
||||||
(.date, "Date"),
|
(.date, "Date"),
|
||||||
(.commission, "Commission")
|
(.revenue, "Revenue"),
|
||||||
|
(.profitability, "Profitability")
|
||||||
]
|
]
|
||||||
for (mode, title) in availableModes {
|
for (mode, title) in availableModes {
|
||||||
let isSelected = mode == self.suggestedSortMode
|
let isSelected = mode == self.suggestedSortMode
|
||||||
@ -436,7 +437,7 @@ If you end your affiliate program:
|
|||||||
self.suggestedStarBotListDisposable?.dispose()
|
self.suggestedStarBotListDisposable?.dispose()
|
||||||
self.suggestedStarBotListDisposable = (component.context.engine.peers.requestSuggestedStarRefBots(
|
self.suggestedStarBotListDisposable = (component.context.engine.peers.requestSuggestedStarRefBots(
|
||||||
id: component.initialContent.peerId,
|
id: component.initialContent.peerId,
|
||||||
orderByCommission: self.suggestedSortMode == .commission,
|
sortMode: self.suggestedSortMode,
|
||||||
offset: nil,
|
offset: nil,
|
||||||
limit: 100)
|
limit: 100)
|
||||||
|> deliverOnMainQueue).startStrict(next: { [weak self] list in
|
|> deliverOnMainQueue).startStrict(next: { [weak self] list in
|
||||||
@ -559,7 +560,7 @@ If you end your affiliate program:
|
|||||||
|
|
||||||
self.suggestedStarBotListDisposable = (component.context.engine.peers.requestSuggestedStarRefBots(
|
self.suggestedStarBotListDisposable = (component.context.engine.peers.requestSuggestedStarRefBots(
|
||||||
id: component.initialContent.peerId,
|
id: component.initialContent.peerId,
|
||||||
orderByCommission: false,
|
sortMode: self.suggestedSortMode,
|
||||||
offset: nil,
|
offset: nil,
|
||||||
limit: 100)
|
limit: 100)
|
||||||
|> deliverOnMainQueue).startStrict(next: { [weak self] list in
|
|> deliverOnMainQueue).startStrict(next: { [weak self] list in
|
||||||
@ -1344,9 +1345,9 @@ If you end your affiliate program:
|
|||||||
do {
|
do {
|
||||||
var suggestedSectionItems: [AnyComponentWithIdentity<Empty>] = []
|
var suggestedSectionItems: [AnyComponentWithIdentity<Empty>] = []
|
||||||
for item in suggestedStarBotListItems {
|
for item in suggestedStarBotListItems {
|
||||||
let commissionTitle = "\(item.commissionPermille / 10)%"
|
let commissionTitle = "\(item.program.commissionPermille / 10)%"
|
||||||
let durationTitle: String
|
let durationTitle: String
|
||||||
if let durationMonths = item.durationMonths {
|
if let durationMonths = item.program.durationMonths {
|
||||||
durationTitle = timeIntervalString(strings: environment.strings, value: durationMonths * (24 * 60 * 60))
|
durationTitle = timeIntervalString(strings: environment.strings, value: durationMonths * (24 * 60 * 60))
|
||||||
} else {
|
} else {
|
||||||
durationTitle = "Lifetime"
|
durationTitle = "Lifetime"
|
||||||
@ -1401,8 +1402,8 @@ If you end your affiliate program:
|
|||||||
self.environment?.controller()?.push(JoinAffiliateProgramScreen(
|
self.environment?.controller()?.push(JoinAffiliateProgramScreen(
|
||||||
context: component.context,
|
context: component.context,
|
||||||
sourcePeer: botPeer,
|
sourcePeer: botPeer,
|
||||||
commissionPermille: item.commissionPermille,
|
commissionPermille: item.program.commissionPermille,
|
||||||
programDuration: item.durationMonths,
|
programDuration: item.program.durationMonths,
|
||||||
mode: .join(JoinAffiliateProgramScreenMode.Join(
|
mode: .join(JoinAffiliateProgramScreenMode.Join(
|
||||||
initialTargetPeer: targetPeer,
|
initialTargetPeer: targetPeer,
|
||||||
canSelectTargetPeer: false,
|
canSelectTargetPeer: false,
|
||||||
|
@ -120,6 +120,9 @@ private final class JoinAffiliateProgramScreenComponent: Component {
|
|||||||
|
|
||||||
private var currentTargetPeer: EnginePeer?
|
private var currentTargetPeer: EnginePeer?
|
||||||
|
|
||||||
|
private var possibleTargetPeers: [EnginePeer] = []
|
||||||
|
private var possibleTargetPeersDisposable: Disposable?
|
||||||
|
|
||||||
private var cachedCloseImage: UIImage?
|
private var cachedCloseImage: UIImage?
|
||||||
|
|
||||||
override init(frame: CGRect) {
|
override init(frame: CGRect) {
|
||||||
@ -189,6 +192,10 @@ private final class JoinAffiliateProgramScreenComponent: Component {
|
|||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
self.possibleTargetPeersDisposable?.dispose()
|
||||||
|
}
|
||||||
|
|
||||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||||
if !self.ignoreScrolling {
|
if !self.ignoreScrolling {
|
||||||
self.updateScrolling(transition: .immediate)
|
self.updateScrolling(transition: .immediate)
|
||||||
@ -338,9 +345,9 @@ private final class JoinAffiliateProgramScreenComponent: Component {
|
|||||||
|
|
||||||
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 })
|
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 })
|
||||||
|
|
||||||
let peers: [EnginePeer] = [
|
let peers: [EnginePeer] = self.possibleTargetPeers.isEmpty ? [
|
||||||
join.initialTargetPeer
|
join.initialTargetPeer
|
||||||
]
|
] : self.possibleTargetPeers
|
||||||
|
|
||||||
let avatarSize = CGSize(width: 30.0, height: 30.0)
|
let avatarSize = CGSize(width: 30.0, height: 30.0)
|
||||||
|
|
||||||
@ -383,11 +390,24 @@ private final class JoinAffiliateProgramScreenComponent: Component {
|
|||||||
let sideInset: CGFloat = 16.0 + environment.safeInsets.left
|
let sideInset: CGFloat = 16.0 + environment.safeInsets.left
|
||||||
|
|
||||||
if self.component == nil {
|
if self.component == nil {
|
||||||
|
var loadPossibleTargetPeers = false
|
||||||
switch component.mode {
|
switch component.mode {
|
||||||
case let .join(join):
|
case let .join(join):
|
||||||
self.currentTargetPeer = join.initialTargetPeer
|
self.currentTargetPeer = join.initialTargetPeer
|
||||||
|
loadPossibleTargetPeers = join.canSelectTargetPeer
|
||||||
case let .active(active):
|
case let .active(active):
|
||||||
self.currentTargetPeer = active.targetPeer
|
self.currentTargetPeer = active.targetPeer
|
||||||
|
loadPossibleTargetPeers = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if loadPossibleTargetPeers {
|
||||||
|
self.possibleTargetPeersDisposable = (component.context.engine.peers.getPossibleStarRefBotTargets()
|
||||||
|
|> deliverOnMainQueue).startStrict(next: { [weak self] result in
|
||||||
|
guard let self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.possibleTargetPeers = result
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,6 +721,7 @@ private final class JoinAffiliateProgramScreenComponent: Component {
|
|||||||
isTargetPeerSelectable = join.canSelectTargetPeer
|
isTargetPeerSelectable = join.canSelectTargetPeer
|
||||||
case .active:
|
case .active:
|
||||||
displayTargetPeer = true
|
displayTargetPeer = true
|
||||||
|
isTargetPeerSelectable = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if displayTargetPeer {
|
if displayTargetPeer {
|
||||||
@ -1154,7 +1175,7 @@ private final class PeerBadgeComponent: Component {
|
|||||||
if let current = self.avatarNode {
|
if let current = self.avatarNode {
|
||||||
avatarNode = current
|
avatarNode = current
|
||||||
} else {
|
} else {
|
||||||
avatarNode = AvatarNode(font: avatarPlaceholderFont(size: 15.0))
|
avatarNode = AvatarNode(font: avatarPlaceholderFont(size: floor(avatarDiameter * 0.5)))
|
||||||
avatarNode.isUserInteractionEnabled = false
|
avatarNode.isUserInteractionEnabled = false
|
||||||
avatarNode.displaysAsynchronously = false
|
avatarNode.displaysAsynchronously = false
|
||||||
self.avatarNode = avatarNode
|
self.avatarNode = avatarNode
|
||||||
@ -1252,18 +1273,13 @@ private final class AvatarComponent: Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class View: UIView {
|
final class View: UIView {
|
||||||
private let avatarNode: AvatarNode
|
private var avatarNode: AvatarNode?
|
||||||
|
|
||||||
private var component: AvatarComponent?
|
private var component: AvatarComponent?
|
||||||
private weak var state: EmptyComponentState?
|
private weak var state: EmptyComponentState?
|
||||||
|
|
||||||
override init(frame: CGRect) {
|
override init(frame: CGRect) {
|
||||||
self.avatarNode = AvatarNode(font: avatarPlaceholderFont(size: 18.0))
|
|
||||||
self.avatarNode.displaysAsynchronously = false
|
|
||||||
|
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
|
|
||||||
self.addSubnode(self.avatarNode)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
@ -1276,14 +1292,24 @@ private final class AvatarComponent: Component {
|
|||||||
|
|
||||||
let size = component.size ?? availableSize
|
let size = component.size ?? availableSize
|
||||||
|
|
||||||
self.avatarNode.frame = CGRect(origin: CGPoint(), size: size)
|
let avatarNode: AvatarNode
|
||||||
self.avatarNode.setPeer(
|
if let current = self.avatarNode {
|
||||||
|
avatarNode = current
|
||||||
|
} else {
|
||||||
|
avatarNode = AvatarNode(font: avatarPlaceholderFont(size: floor(size.width * 0.5)))
|
||||||
|
avatarNode.displaysAsynchronously = false
|
||||||
|
self.avatarNode = avatarNode
|
||||||
|
self.addSubview(avatarNode.view)
|
||||||
|
}
|
||||||
|
avatarNode.frame = CGRect(origin: CGPoint(), size: size)
|
||||||
|
avatarNode.setPeer(
|
||||||
context: component.context,
|
context: component.context,
|
||||||
theme: component.context.sharedContext.currentPresentationData.with({ $0 }).theme,
|
theme: component.context.sharedContext.currentPresentationData.with({ $0 }).theme,
|
||||||
peer: component.peer,
|
peer: component.peer,
|
||||||
synchronousLoad: true,
|
synchronousLoad: true,
|
||||||
displayDimensions: size
|
displayDimensions: size
|
||||||
)
|
)
|
||||||
|
avatarNode.updateSize(size: size)
|
||||||
|
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
@ -1634,8 +1660,10 @@ final class BotSectionSortButtonComponent: Component {
|
|||||||
switch component.sortMode {
|
switch component.sortMode {
|
||||||
case .date:
|
case .date:
|
||||||
sortByString = "SORT BY [DATE]()"
|
sortByString = "SORT BY [DATE]()"
|
||||||
case .commission:
|
case .profitability:
|
||||||
sortByString = "SORT BY [COMMISSION]()"
|
sortByString = "SORT BY [PROFITABILITY]()"
|
||||||
|
case .revenue:
|
||||||
|
sortByString = "SORT BY [REVENUE]()"
|
||||||
}
|
}
|
||||||
let textSize = self.text.update(
|
let textSize = self.text.update(
|
||||||
transition: .immediate,
|
transition: .immediate,
|
||||||
@ -1730,7 +1758,7 @@ final class PeerBadgeAvatarComponent: Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class View: UIView {
|
final class View: UIView {
|
||||||
private let avatarNode: AvatarNode
|
private var avatarNode: AvatarNode?
|
||||||
|
|
||||||
private let badgeBackground = UIImageView()
|
private let badgeBackground = UIImageView()
|
||||||
private let badgeIcon = UIImageView()
|
private let badgeIcon = UIImageView()
|
||||||
@ -1742,12 +1770,7 @@ final class PeerBadgeAvatarComponent: Component {
|
|||||||
private static let badgeIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Links/Link"), color: .white)?.withRenderingMode(.alwaysTemplate)
|
private static let badgeIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Links/Link"), color: .white)?.withRenderingMode(.alwaysTemplate)
|
||||||
|
|
||||||
override init(frame: CGRect) {
|
override init(frame: CGRect) {
|
||||||
self.avatarNode = AvatarNode(font: avatarPlaceholderFont(size: 15.0))
|
|
||||||
self.avatarNode.displaysAsynchronously = false
|
|
||||||
|
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
|
|
||||||
self.addSubnode(self.avatarNode)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
@ -1763,8 +1786,18 @@ final class PeerBadgeAvatarComponent: Component {
|
|||||||
|
|
||||||
let badgeFrame = CGRect(origin: CGPoint(x: size.width - badgeSize, y: size.height - badgeSize), size: CGSize(width: badgeSize, height: badgeSize))
|
let badgeFrame = CGRect(origin: CGPoint(x: size.width - badgeSize, y: size.height - badgeSize), size: CGSize(width: badgeSize, height: badgeSize))
|
||||||
|
|
||||||
self.avatarNode.frame = CGRect(origin: CGPoint(), size: size)
|
let avatarNode: AvatarNode
|
||||||
self.avatarNode.setPeer(
|
if let current = self.avatarNode {
|
||||||
|
avatarNode = current
|
||||||
|
} else {
|
||||||
|
avatarNode = AvatarNode(font: avatarPlaceholderFont(size: floor(size.width * 0.5)))
|
||||||
|
avatarNode.displaysAsynchronously = false
|
||||||
|
self.avatarNode = avatarNode
|
||||||
|
self.addSubview(avatarNode.view)
|
||||||
|
}
|
||||||
|
|
||||||
|
avatarNode.frame = CGRect(origin: CGPoint(), size: size)
|
||||||
|
avatarNode.setPeer(
|
||||||
context: component.context,
|
context: component.context,
|
||||||
theme: component.context.sharedContext.currentPresentationData.with({ $0 }).theme,
|
theme: component.context.sharedContext.currentPresentationData.with({ $0 }).theme,
|
||||||
peer: component.peer,
|
peer: component.peer,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user