Swiftgram/TelegramUI/StringForMessageTimestampStatus.swift
Peter Iakovlev d36e7e3a6e no message
2018-02-23 20:28:31 +04:00

30 lines
1.0 KiB
Swift

import Foundation
import Postbox
import TelegramCore
func stringForMessageTimestampStatus(message: Message, timeFormat: PresentationTimeFormat, strings: PresentationStrings) -> 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 let authorTitle = authorTitle, !authorTitle.isEmpty {
dateText = "\(authorTitle), \(dateText)"
}
return dateText
}