mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-04 05:26:48 +00:00
Merge commit '40ad8ff62822372c08d7b4cb726316e5d0e5ac71'
This commit is contained in:
commit
cf65440d8d
@ -84,6 +84,7 @@ public final class AccountContext {
|
||||
public var watchManager: WatchManager?
|
||||
|
||||
private var storedPassword: (String, CFAbsoluteTime, SwiftSignalKit.Timer)?
|
||||
private var limitsConfigurationDisposable: Disposable?
|
||||
|
||||
public init(sharedContext: SharedAccountContext, account: Account, limitsConfiguration: LimitsConfiguration) {
|
||||
self.sharedContext = sharedContext
|
||||
@ -105,10 +106,23 @@ public final class AccountContext {
|
||||
self.wallpaperUploadManager = nil
|
||||
}
|
||||
|
||||
let updatedLimitsConfiguration = account.postbox.preferencesView(keys: [PreferencesKeys.limitsConfiguration])
|
||||
|> map { preferences -> LimitsConfiguration in
|
||||
return preferences.values[PreferencesKeys.limitsConfiguration] as? LimitsConfiguration ?? LimitsConfiguration.defaultValue
|
||||
}
|
||||
|
||||
self.currentLimitsConfiguration = Atomic(value: limitsConfiguration)
|
||||
self._limitsConfiguration.set(.single(limitsConfiguration) |> then(updatedLimitsConfiguration))
|
||||
|
||||
let currentLimitsConfiguration = self.currentLimitsConfiguration
|
||||
self.limitsConfigurationDisposable = (self._limitsConfiguration.get()
|
||||
|> deliverOnMainQueue).start(next: { value in
|
||||
let _ = currentLimitsConfiguration.swap(value)
|
||||
})
|
||||
}
|
||||
|
||||
deinit {
|
||||
self.limitsConfigurationDisposable?.dispose()
|
||||
}
|
||||
|
||||
public func storeSecureIdPassword(password: String) {
|
||||
|
||||
@ -265,14 +265,23 @@ func contextMenuForChatPresentationIntefaceState(chatPresentationInterfaceState:
|
||||
let message = messages[0]
|
||||
|
||||
var hasEditRights = false
|
||||
var unlimitedInterval = false
|
||||
if message.id.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
hasEditRights = false
|
||||
} else if let author = message.author, author.id == context.account.peerId {
|
||||
hasEditRights = true
|
||||
} else if message.author?.id == message.id.peerId, let peer = message.peers[message.id.peerId] {
|
||||
if let peer = peer as? TelegramChannel, case .broadcast = peer.info {
|
||||
if peer.hasPermission(.editAllMessages) {
|
||||
hasEditRights = true
|
||||
if let peer = peer as? TelegramChannel {
|
||||
switch peer.info {
|
||||
case .broadcast:
|
||||
if peer.hasPermission(.editAllMessages) {
|
||||
hasEditRights = true
|
||||
}
|
||||
case .group:
|
||||
if peer.hasPermission(.pinMessages) {
|
||||
unlimitedInterval = true
|
||||
hasEditRights = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -318,7 +327,7 @@ func contextMenuForChatPresentationIntefaceState(chatPresentationInterfaceState:
|
||||
}
|
||||
|
||||
if !hasUneditableAttributes {
|
||||
if canPerformEditingActions(limits: limitsConfiguration, accountPeerId: context.account.peerId, message: message) {
|
||||
if canPerformEditingActions(limits: limitsConfiguration, accountPeerId: context.account.peerId, message: message, unlimitedInterval: unlimitedInterval) {
|
||||
canEdit = true
|
||||
}
|
||||
}
|
||||
@ -578,11 +587,15 @@ struct ChatAvailableMessageActions {
|
||||
let banAuthor: Peer?
|
||||
}
|
||||
|
||||
private func canPerformEditingActions(limits: LimitsConfiguration, accountPeerId: PeerId, message: Message) -> Bool {
|
||||
private func canPerformEditingActions(limits: LimitsConfiguration, accountPeerId: PeerId, message: Message, unlimitedInterval: Bool) -> Bool {
|
||||
if message.id.peerId == accountPeerId {
|
||||
return true
|
||||
}
|
||||
|
||||
if unlimitedInterval {
|
||||
return true
|
||||
}
|
||||
|
||||
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970)
|
||||
if Int64(message.timestamp) + Int64(limits.maxMessageEditingInterval) > Int64(timestamp) {
|
||||
return true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user