Send as improvements

This commit is contained in:
Isaac 2024-08-12 22:34:30 +08:00
parent 03ee1379b2
commit ce0e2ba62d
4 changed files with 27 additions and 9 deletions

View File

@ -496,8 +496,8 @@ private func channelAdminsControllerEntries(presentationData: PresentationData,
if !isGroup && peer.hasPermission(.sendSomething) {
entries.append(.signMessages(presentationData.theme, presentationData.strings.Channel_SignMessages, signMessagesEnabled, showAuthorProfilesEnabled))
entries.append(.showAuthorProfiles(presentationData.theme, presentationData.strings.Channel_ShowAuthors, showAuthorProfilesEnabled, signMessagesEnabled))
if signMessagesEnabled {
entries.append(.showAuthorProfiles(presentationData.theme, presentationData.strings.Channel_ShowAuthors, showAuthorProfilesEnabled, signMessagesEnabled))
entries.append(.signMessagesInfo(presentationData.theme, presentationData.strings.Channel_ShowAuthorsFooter))
}
}

View File

@ -742,11 +742,16 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
if messageNamespace != Namespaces.Message.ScheduledLocal && messageNamespace != Namespaces.Message.QuickReplyLocal {
attributes.append(ViewCountMessageAttribute(count: 1))
}
if info.flags.contains(.messagesShouldHaveSignatures) {
attributes.append(AuthorSignatureMessageAttribute(signature: accountPeer.debugDisplayTitle))
}
if info.flags.contains(.messagesShouldHaveProfiles) {
authorId = account.peerId
if sendAsPeer == nil {
authorId = account.peerId
}
}
if info.flags.contains(.messagesShouldHaveSignatures) {
if let sendAsPeer, sendAsPeer.id == peerId {
} else {
attributes.append(AuthorSignatureMessageAttribute(signature: accountPeer.debugDisplayTitle))
}
}
case .group:
break

View File

@ -344,10 +344,8 @@ public extension Message {
return false
}
} else if self.author?.id == accountPeerId {
if let channel = self.peers[self.id.peerId] as? TelegramChannel, case let .broadcast(info) = channel.info {
if !info.flags.contains(.messagesShouldHaveProfiles) {
return true
}
if let channel = self.peers[self.id.peerId] as? TelegramChannel, case .broadcast = channel.info {
return true
}
return false
} else if self.flags.contains(.Incoming) {

View File

@ -284,6 +284,19 @@ extension ChatControllerImpl {
if let channel = peerViewMainPeer(peerView) as? TelegramChannel, case .group = channel.info, channel.hasPermission(.canBeAnonymous) {
allPeers = peers
var hasAnonymousPeer = false
for peer in peers {
if peer.peer.id == channel.id {
hasAnonymousPeer = true
break
}
}
if !hasAnonymousPeer {
allPeers?.insert(SendAsPeer(peer: channel, subscribers: 0, isPremiumRequired: false), at: 0)
}
} else if let channel = peerViewMainPeer(peerView) as? TelegramChannel, case let .broadcast(info) = channel.info, info.flags.contains(.messagesShouldHaveProfiles) {
allPeers = peers
var hasAnonymousPeer = false
for peer in peers {
if peer.peer.id == channel.id {
@ -3978,6 +3991,8 @@ extension ChatControllerImpl {
let defaultMyPeerId: PeerId
if let channel = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer as? TelegramChannel, case .group = channel.info, channel.hasPermission(.canBeAnonymous) {
defaultMyPeerId = channel.id
} else if let channel = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer as? TelegramChannel, case let .broadcast(info) = channel.info, info.flags.contains(.messagesShouldHaveProfiles) {
defaultMyPeerId = channel.id
} else {
defaultMyPeerId = strongSelf.context.account.peerId
}