mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Update API
This commit is contained in:
@@ -16,12 +16,13 @@ func _internal_updateGlobalPrivacySettings(account: Account) -> Signal<Never, No
|
||||
}
|
||||
let globalSettings: GlobalPrivacySettings
|
||||
switch result {
|
||||
case let .globalPrivacySettings(flags, nonContactPeersPaidStars):
|
||||
case let .globalPrivacySettings(flags, nonContactPeersPaidStars, disallowedStarGifts):
|
||||
let automaticallyArchiveAndMuteNonContacts = (flags & (1 << 0)) != 0
|
||||
let keepArchivedUnmuted = (flags & (1 << 1)) != 0
|
||||
let keepArchivedFolders = (flags & (1 << 2)) != 0
|
||||
let hideReadTime = (flags & (1 << 3)) != 0
|
||||
let nonContactChatsRequirePremium = (flags & (1 << 4)) != 0
|
||||
let displayGiftButton = (flags & (1 << 7)) != 0
|
||||
|
||||
let nonContactChatsPrivacy: GlobalPrivacySettings.NonContactChatsPrivacy
|
||||
if let nonContactPeersPaidStars, nonContactPeersPaidStars > 0 {
|
||||
@@ -32,12 +33,27 @@ func _internal_updateGlobalPrivacySettings(account: Account) -> Signal<Never, No
|
||||
nonContactChatsPrivacy = .everybody
|
||||
}
|
||||
|
||||
var disallowedGifts: DisallowedGifts = []
|
||||
if case let .disallowedStarGiftsSettings(giftFlags) = disallowedStarGifts {
|
||||
if (giftFlags & (1 << 0)) != 0 {
|
||||
disallowedGifts.insert(.unlimited)
|
||||
}
|
||||
if (giftFlags & (1 << 1)) != 0 {
|
||||
disallowedGifts.insert(.limited)
|
||||
}
|
||||
if (giftFlags & (1 << 2)) != 0 {
|
||||
disallowedGifts.insert(.unique)
|
||||
}
|
||||
}
|
||||
|
||||
globalSettings = GlobalPrivacySettings(
|
||||
automaticallyArchiveAndMuteNonContacts: automaticallyArchiveAndMuteNonContacts,
|
||||
keepArchivedUnmuted: keepArchivedUnmuted,
|
||||
keepArchivedFolders: keepArchivedFolders,
|
||||
hideReadTime: hideReadTime,
|
||||
nonContactChatsPrivacy: nonContactChatsPrivacy
|
||||
nonContactChatsPrivacy: nonContactChatsPrivacy,
|
||||
disallowedGifts: disallowedGifts,
|
||||
displayGiftButton: displayGiftButton
|
||||
)
|
||||
}
|
||||
updateGlobalPrivacySettings(transaction: transaction, { _ in
|
||||
@@ -222,12 +238,13 @@ func _internal_requestAccountPrivacySettings(account: Account) -> Signal<Account
|
||||
|
||||
let globalSettings: GlobalPrivacySettings
|
||||
switch globalPrivacySettings {
|
||||
case let .globalPrivacySettings(flags, nonContactPeersPaidStars):
|
||||
case let .globalPrivacySettings(flags, nonContactPeersPaidStars, disallowedStarGifts):
|
||||
let automaticallyArchiveAndMuteNonContacts = (flags & (1 << 0)) != 0
|
||||
let keepArchivedUnmuted = (flags & (1 << 1)) != 0
|
||||
let keepArchivedFolders = (flags & (1 << 2)) != 0
|
||||
let hideReadTime = (flags & (1 << 3)) != 0
|
||||
let nonContactChatsRequirePremium = (flags & (1 << 4)) != 0
|
||||
let displayGiftButton = (flags & (1 << 7)) != 0
|
||||
|
||||
let nonContactChatsPrivacy: GlobalPrivacySettings.NonContactChatsPrivacy
|
||||
if let nonContactPeersPaidStars, nonContactPeersPaidStars > 0 {
|
||||
@@ -238,12 +255,27 @@ func _internal_requestAccountPrivacySettings(account: Account) -> Signal<Account
|
||||
nonContactChatsPrivacy = .everybody
|
||||
}
|
||||
|
||||
var disallowedGifts: DisallowedGifts = []
|
||||
if case let .disallowedStarGiftsSettings(giftFlags) = disallowedStarGifts {
|
||||
if (giftFlags & (1 << 0)) != 0 {
|
||||
disallowedGifts.insert(.unlimited)
|
||||
}
|
||||
if (giftFlags & (1 << 1)) != 0 {
|
||||
disallowedGifts.insert(.limited)
|
||||
}
|
||||
if (giftFlags & (1 << 2)) != 0 {
|
||||
disallowedGifts.insert(.unique)
|
||||
}
|
||||
}
|
||||
|
||||
globalSettings = GlobalPrivacySettings(
|
||||
automaticallyArchiveAndMuteNonContacts: automaticallyArchiveAndMuteNonContacts,
|
||||
keepArchivedUnmuted: keepArchivedUnmuted,
|
||||
keepArchivedFolders: keepArchivedFolders,
|
||||
hideReadTime: hideReadTime,
|
||||
nonContactChatsPrivacy: nonContactChatsPrivacy
|
||||
nonContactChatsPrivacy: nonContactChatsPrivacy,
|
||||
disallowedGifts: disallowedGifts,
|
||||
displayGiftButton: displayGiftButton
|
||||
)
|
||||
}
|
||||
|
||||
@@ -348,6 +380,9 @@ func _internal_updateGlobalPrivacySettings(account: Account, settings: GlobalPri
|
||||
if settings.hideReadTime {
|
||||
flags |= 1 << 3
|
||||
}
|
||||
if settings.displayGiftButton {
|
||||
flags |= 1 << 7
|
||||
}
|
||||
|
||||
var noncontactPeersPaidStars: Int64?
|
||||
switch settings.nonContactChatsPrivacy {
|
||||
@@ -361,8 +396,24 @@ func _internal_updateGlobalPrivacySettings(account: Account, settings: GlobalPri
|
||||
noncontactPeersPaidStars = starsAmount.value
|
||||
}
|
||||
|
||||
var disallowedStargifts: Api.DisallowedStarGiftsSettings?
|
||||
if !settings.disallowedGifts.isEmpty {
|
||||
var giftFlags: Int32 = 0
|
||||
if settings.disallowedGifts.contains(.unlimited) {
|
||||
giftFlags |= 1 << 0
|
||||
}
|
||||
if settings.disallowedGifts.contains(.limited) {
|
||||
giftFlags |= 1 << 1
|
||||
}
|
||||
if settings.disallowedGifts.contains(.unique) {
|
||||
giftFlags |= 1 << 2
|
||||
}
|
||||
disallowedStargifts = .disallowedStarGiftsSettings(flags: giftFlags)
|
||||
}
|
||||
flags |= 1 << 6
|
||||
|
||||
return account.network.request(Api.functions.account.setGlobalPrivacySettings(
|
||||
settings: .globalPrivacySettings(flags: flags, noncontactPeersPaidStars: noncontactPeersPaidStars)
|
||||
settings: .globalPrivacySettings(flags: flags, noncontactPeersPaidStars: noncontactPeersPaidStars, disallowedStargifts: disallowedStargifts)
|
||||
))
|
||||
|> retryRequest
|
||||
|> ignoreValues
|
||||
|
||||
Reference in New Issue
Block a user