mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
37 lines
1.2 KiB
Swift
37 lines
1.2 KiB
Swift
import Foundation
|
|
import Postbox
|
|
import TelegramCore
|
|
|
|
enum MessageTimestampStatusFormat {
|
|
case regular
|
|
case minimal
|
|
}
|
|
|
|
func stringForMessageTimestampStatus(message: Message, timeFormat: PresentationTimeFormat, strings: PresentationStrings, format: MessageTimestampStatusFormat = .regular) -> String {
|
|
var dateText = stringForMessageTimestamp(timestamp: message.timestamp, timeFormat: timeFormat)
|
|
|
|
var authorTitle: String?
|
|
if let author = message.author as? TelegramUser {
|
|
if let peer = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = peer.info {
|
|
authorTitle = author.displayTitle
|
|
}
|
|
} else {
|
|
if let peer = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = peer.info {
|
|
for attribute in message.attributes {
|
|
if let attribute = attribute as? AuthorSignatureMessageAttribute {
|
|
authorTitle = attribute.signature
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if case .regular = format {
|
|
if let authorTitle = authorTitle, !authorTitle.isEmpty {
|
|
dateText = "\(authorTitle), \(dateText)"
|
|
}
|
|
}
|
|
|
|
return dateText
|
|
}
|