Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin 2021-07-28 01:32:45 +03:00
commit 743369eb0e
8 changed files with 41 additions and 6 deletions

View File

@ -849,7 +849,8 @@
"MessageTimer.ShortWeeks_3_10" = "%@w";
"MessageTimer.ShortWeeks_any" = "%@w";
"MessageTimer.ShortWeeks_many" = "%@w";
"MessageTimer.ShortWeeks_0" = "%@w";
"MessageTimer.ShortMonths_1" = "%@mo";
"MessageTimer.ShortMonths_any" = "%@mo";
"Activity.UploadingPhoto" = "sending photo";
"Activity.UploadingVideo" = "sending video";

View File

@ -145,10 +145,12 @@ public struct ChatAvailableMessageActionOptions: OptionSet {
public struct ChatAvailableMessageActions {
public var options: ChatAvailableMessageActionOptions
public var banAuthor: Peer?
public var disableDelete: Bool
public init(options: ChatAvailableMessageActionOptions, banAuthor: Peer?) {
public init(options: ChatAvailableMessageActionOptions, banAuthor: Peer?, disableDelete: Bool) {
self.options = options
self.banAuthor = banAuthor
self.disableDelete = disableDelete
}
}

View File

@ -79,6 +79,8 @@ public protocol Media: class, PostboxCoding {
var indexableText: String? { get }
func isLikelyToBeUpdated() -> Bool
func preventsAutomaticMessageSendingFailure() -> Bool
func isEqual(to other: Media) -> Bool
func isSemanticallyEqual(to other: Media) -> Bool
@ -89,6 +91,10 @@ public extension Media {
return false
}
func preventsAutomaticMessageSendingFailure() -> Bool {
return false
}
var indexableText: String? {
return nil
}

View File

@ -1603,6 +1603,12 @@ public final class Postbox {
for id in self.messageHistoryUnsentTable.get() {
transaction.updateMessage(id, update: { message in
if !message.flags.contains(.Failed) {
for media in message.media {
if media.preventsAutomaticMessageSendingFailure() {
return .skip
}
}
if message.timestamp + 60 * 10 > timestampForAbsoluteTimeBasedOperations {
return .skip
}

View File

@ -251,6 +251,13 @@ public final class TelegramMediaAction: Media {
}
public let action: TelegramMediaActionType
public func preventsAutomaticMessageSendingFailure() -> Bool {
if case .historyScreenshot = self.action {
return true
}
return false
}
public init(action: TelegramMediaActionType) {
self.action = action

View File

@ -111,8 +111,10 @@ public func shortTimeIntervalString(strings: PresentationStrings, value: Int32)
return strings.MessageTimer_ShortHours(max(1, value / (60 * 60)))
} else if value < 60 * 60 * 24 * 7 {
return strings.MessageTimer_ShortDays(max(1, value / (60 * 60 * 24)))
} else {
} else if value < 60 * 60 * 24 * 31 {
return strings.MessageTimer_ShortWeeks(max(1, value / (60 * 60 * 24 * 7)))
} else {
return strings.MessageTimer_ShortMonths(max(1, value / (60 * 60 * 24 * 7 * 30)))
}
}

View File

@ -1059,6 +1059,7 @@ func chatAvailableMessageActionsImpl(postbox: Postbox, accountPeerId: PeerId, me
var banPeer: Peer?
var hadPersonalIncoming = false
var hadBanPeerId = false
var disableDelete = false
func getPeer(_ peerId: PeerId) -> Peer? {
if let peer = transaction.getPeer(peerId) {
@ -1229,6 +1230,15 @@ func chatAvailableMessageActionsImpl(postbox: Postbox, accountPeerId: PeerId, me
if canDeleteGlobally {
optionsMap[id]!.insert(.deleteGlobally)
}
for media in message.media {
if let action = media as? TelegramMediaAction {
if case .historyScreenshot = action.action {
optionsMap[id]!.remove(.deleteLocally)
optionsMap[id]!.remove(.deleteGlobally)
disableDelete = true
}
}
}
if user.botInfo != nil && message.flags.contains(.Incoming) && !user.id.isReplies && !isAction {
optionsMap[id]!.insert(.report)
}
@ -1239,6 +1249,7 @@ func chatAvailableMessageActionsImpl(postbox: Postbox, accountPeerId: PeerId, me
switch action.action {
case .historyScreenshot:
isNonRemovableServiceAction = true
disableDelete = true
default:
break
}
@ -1265,9 +1276,9 @@ func chatAvailableMessageActionsImpl(postbox: Postbox, accountPeerId: PeerId, me
if hadPersonalIncoming && optionsMap.values.contains(where: { $0.contains(.deleteGlobally) }) && !reducedOptions.contains(.deleteGlobally) {
reducedOptions.insert(.unsendPersonal)
}
return ChatAvailableMessageActions(options: reducedOptions, banAuthor: banPeer)
return ChatAvailableMessageActions(options: reducedOptions, banAuthor: banPeer, disableDelete: disableDelete)
} else {
return ChatAvailableMessageActions(options: [], banAuthor: nil)
return ChatAvailableMessageActions(options: [], banAuthor: nil, disableDelete: false)
}
}
}

View File

@ -154,7 +154,7 @@ final class ChatMessageSelectionInputPanelNode: ChatInputPanelNode {
if self.peerMedia {
self.deleteButton.isEnabled = !actions.options.intersection([.deleteLocally, .deleteGlobally]).isEmpty
} else {
self.deleteButton.isEnabled = true
self.deleteButton.isEnabled = !actions.disableDelete
}
self.shareButton.isEnabled = !actions.options.intersection([.forward]).isEmpty
self.reportButton.isEnabled = !actions.options.intersection([.report]).isEmpty