mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
no message
This commit is contained in:
@@ -160,6 +160,7 @@ public func updateChannelMemberBannedRights(account: Account, peerId: PeerId, me
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var isKicked = false
|
||||
var isBanned = false
|
||||
if rights.flags.contains(.banReadMessages) {
|
||||
|
||||
@@ -38,6 +38,8 @@ private func filterMessageAttributesForOutgoingMessage(_ attributes: [MessageAtt
|
||||
return true
|
||||
case _ as AutoremoveTimeoutMessageAttribute:
|
||||
return true
|
||||
case _ as NotificationInfoMessageAttribute:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
@@ -276,6 +278,13 @@ func enqueueMessages(modifier: Modifier, account: Account, peerId: PeerId, messa
|
||||
|
||||
}
|
||||
|
||||
let authorId:PeerId?
|
||||
if let peer = peer as? TelegramChannel, case let .broadcast(info) = peer.info, !info.flags.contains(.messagesShouldHaveSignatures) {
|
||||
authorId = peer.id
|
||||
} else {
|
||||
authorId = account.peerId
|
||||
}
|
||||
|
||||
var entitiesAttribute: TextEntitiesMessageAttribute?
|
||||
for attribute in attributes {
|
||||
if let attribute = attribute as? TextEntitiesMessageAttribute {
|
||||
@@ -286,7 +295,7 @@ func enqueueMessages(modifier: Modifier, account: Account, peerId: PeerId, messa
|
||||
|
||||
let (tags, globalTags) = tagsForStoreMessage(incoming: false, attributes: attributes, media: sourceMessage.media, textEntities: entitiesAttribute?.entities)
|
||||
|
||||
storeMessages.append(StoreMessage(peerId: peerId, namespace: Namespaces.Message.Local, globallyUniqueId: randomId, timestamp: timestamp, flags: flags, tags: tags, globalTags: globalTags, forwardInfo: forwardInfo, authorId: account.peerId, text: sourceMessage.text, attributes: attributes, media: sourceMessage.media))
|
||||
storeMessages.append(StoreMessage(peerId: peerId, namespace: Namespaces.Message.Local, globallyUniqueId: randomId, timestamp: timestamp, flags: flags, tags: tags, globalTags: globalTags, forwardInfo: forwardInfo, authorId: authorId, text: sourceMessage.text, attributes: attributes, media: sourceMessage.media))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +95,10 @@ private func actionFromActivity(_ activity: PeerInputActivity?) -> Api.SendMessa
|
||||
return .sendMessageGamePlayAction
|
||||
case let .uploadingFile(progress):
|
||||
return .sendMessageUploadDocumentAction(progress: progress)
|
||||
case let .uploadingPhoto(progress):
|
||||
return .sendMessageUploadPhotoAction(progress: progress)
|
||||
case let .uploadingVideo(progress):
|
||||
return .sendMessageUploadVideoAction(progress: progress)
|
||||
case .recordingInstantVideo:
|
||||
return .sendMessageRecordRoundAction
|
||||
case .uploadingInstantVideo:
|
||||
|
||||
@@ -4,6 +4,8 @@ public enum PeerInputActivity: Comparable {
|
||||
case typingText
|
||||
case uploadingFile(progress: Int32)
|
||||
case recordingVoice
|
||||
case uploadingPhoto(progress: Int32)
|
||||
case uploadingVideo(progress: Int32)
|
||||
case playingGame
|
||||
case recordingInstantVideo
|
||||
case uploadingInstantVideo
|
||||
@@ -34,6 +36,18 @@ public enum PeerInputActivity: Comparable {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .uploadingPhoto(let progress):
|
||||
if case .uploadingPhoto(progress) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .uploadingVideo(let progress):
|
||||
if case .uploadingVideo(progress) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .recordingInstantVideo:
|
||||
if case .recordingInstantVideo = rhs {
|
||||
return true
|
||||
@@ -57,12 +71,16 @@ public enum PeerInputActivity: Comparable {
|
||||
return 1
|
||||
case .recordingVoice:
|
||||
return 2
|
||||
case .recordingInstantVideo:
|
||||
case .uploadingPhoto:
|
||||
return 3
|
||||
case .uploadingInstantVideo:
|
||||
case .uploadingVideo:
|
||||
return 4
|
||||
case .playingGame:
|
||||
case .recordingInstantVideo:
|
||||
return 5
|
||||
case .uploadingInstantVideo:
|
||||
return 6
|
||||
case .playingGame:
|
||||
return 7
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,9 +103,9 @@ extension PeerInputActivity {
|
||||
case let .sendMessageUploadDocumentAction(progress):
|
||||
self = .uploadingFile(progress: progress)
|
||||
case let .sendMessageUploadPhotoAction(progress):
|
||||
self = .uploadingFile(progress: progress)
|
||||
self = .uploadingPhoto(progress: progress)
|
||||
case let .sendMessageUploadVideoAction(progress):
|
||||
self = .uploadingFile(progress: progress)
|
||||
self = .uploadingVideo(progress: progress)
|
||||
case .sendMessageRecordRoundAction:
|
||||
self = .recordingInstantVideo
|
||||
case .sendMessageUploadRoundAction:
|
||||
|
||||
@@ -458,6 +458,10 @@ public final class PendingMessageManager {
|
||||
if attribute.flags.contains(.disableLinkPreviews) {
|
||||
flags |= Int32(1 << 1)
|
||||
}
|
||||
} else if let attribute = attribute as? NotificationInfoMessageAttribute {
|
||||
if attribute.flags.contains(.muted) {
|
||||
flags |= Int32(1 << 5)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@ import Foundation
|
||||
#endif
|
||||
|
||||
public func removePeerMember(account: Account, peerId: PeerId, memberId: PeerId) -> Signal<Void, NoError> {
|
||||
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
return updateChannelMemberBannedRights(account: account, peerId: peerId, memberId: memberId, rights: TelegramChannelBannedRights(flags: [.banReadMessages], untilDate: 0))
|
||||
}
|
||||
|
||||
return account.postbox.modify { modifier -> Signal<Void, NoError> in
|
||||
if let peer = modifier.getPeer(peerId), let memberPeer = modifier.getPeer(memberId), let inputUser = apiInputUser(memberPeer) {
|
||||
if let group = peer as? TelegramGroup {
|
||||
@@ -41,39 +46,6 @@ public func removePeerMember(account: Account, peerId: PeerId, memberId: PeerId)
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if let channel = peer as? TelegramChannel, let inputChannel = apiInputChannel(channel) {
|
||||
return account.network.request(Api.functions.channels.kickFromChannel(channel: inputChannel, userId: inputUser, kicked: .boolTrue))
|
||||
|> mapError { error -> Void in
|
||||
return Void()
|
||||
}
|
||||
|> `catch` { _ -> Signal<Api.Updates, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
account.stateManager.addUpdates(result)
|
||||
|
||||
return account.postbox.modify { modifier -> Void in
|
||||
modifier.updatePeerCachedData(peerIds: Set([peerId]), update: { _, cachedData -> CachedPeerData? in
|
||||
if let cachedData = cachedData as? CachedChannelData, let participants = cachedData.topParticipants {
|
||||
var updatedParticipants = participants.participants
|
||||
for i in 0 ..< participants.participants.count {
|
||||
if participants.participants[i].peerId == memberId {
|
||||
updatedParticipants.remove(at: i)
|
||||
break
|
||||
}
|
||||
}
|
||||
let updatedData = cachedData.withUpdatedTopParticipants(CachedChannelParticipants(participants: updatedParticipants))
|
||||
if let bannedCount = cachedData.participantsSummary.bannedCount {
|
||||
return updatedData.withUpdatedParticipantsSummary(cachedData.participantsSummary.withUpdatedBannedCount(bannedCount + 1))
|
||||
} else {
|
||||
return updatedData
|
||||
}
|
||||
} else {
|
||||
return cachedData
|
||||
}
|
||||
})
|
||||
} |> then(updateChannelParticipantsSummary(account: account, peerId: peerId))
|
||||
}
|
||||
} else {
|
||||
return .complete()
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ func fetchAndUpdateCachedParticipants(peerId: PeerId, network: Network, postbox:
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
return postbox.modify { modifier -> Void in
|
||||
switch result {
|
||||
case let .channelParticipants(_, participants, users):
|
||||
case let .channelParticipants(count, participants, users):
|
||||
var peers: [Peer] = []
|
||||
var peerPresences: [PeerId: PeerPresence] = [:]
|
||||
for user in users {
|
||||
@@ -37,7 +37,7 @@ func fetchAndUpdateCachedParticipants(peerId: PeerId, network: Network, postbox:
|
||||
|
||||
modifier.updatePeerCachedData(peerIds: [peerId], update: { peerId, currentData in
|
||||
if let currentData = currentData as? CachedChannelData {
|
||||
return currentData.withUpdatedTopParticipants(parsedParticipants)
|
||||
return currentData.withUpdatedTopParticipants(parsedParticipants).withUpdatedParticipantsSummary(currentData.participantsSummary.withUpdatedMemberCount(count))
|
||||
} else {
|
||||
return currentData
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user