mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +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 isKicked = false
|
||||||
var isBanned = false
|
var isBanned = false
|
||||||
if rights.flags.contains(.banReadMessages) {
|
if rights.flags.contains(.banReadMessages) {
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ private func filterMessageAttributesForOutgoingMessage(_ attributes: [MessageAtt
|
|||||||
return true
|
return true
|
||||||
case _ as AutoremoveTimeoutMessageAttribute:
|
case _ as AutoremoveTimeoutMessageAttribute:
|
||||||
return true
|
return true
|
||||||
|
case _ as NotificationInfoMessageAttribute:
|
||||||
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
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?
|
var entitiesAttribute: TextEntitiesMessageAttribute?
|
||||||
for attribute in attributes {
|
for attribute in attributes {
|
||||||
if let attribute = attribute as? TextEntitiesMessageAttribute {
|
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)
|
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
|
return .sendMessageGamePlayAction
|
||||||
case let .uploadingFile(progress):
|
case let .uploadingFile(progress):
|
||||||
return .sendMessageUploadDocumentAction(progress: progress)
|
return .sendMessageUploadDocumentAction(progress: progress)
|
||||||
|
case let .uploadingPhoto(progress):
|
||||||
|
return .sendMessageUploadPhotoAction(progress: progress)
|
||||||
|
case let .uploadingVideo(progress):
|
||||||
|
return .sendMessageUploadVideoAction(progress: progress)
|
||||||
case .recordingInstantVideo:
|
case .recordingInstantVideo:
|
||||||
return .sendMessageRecordRoundAction
|
return .sendMessageRecordRoundAction
|
||||||
case .uploadingInstantVideo:
|
case .uploadingInstantVideo:
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ public enum PeerInputActivity: Comparable {
|
|||||||
case typingText
|
case typingText
|
||||||
case uploadingFile(progress: Int32)
|
case uploadingFile(progress: Int32)
|
||||||
case recordingVoice
|
case recordingVoice
|
||||||
|
case uploadingPhoto(progress: Int32)
|
||||||
|
case uploadingVideo(progress: Int32)
|
||||||
case playingGame
|
case playingGame
|
||||||
case recordingInstantVideo
|
case recordingInstantVideo
|
||||||
case uploadingInstantVideo
|
case uploadingInstantVideo
|
||||||
@@ -34,6 +36,18 @@ public enum PeerInputActivity: Comparable {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
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:
|
case .recordingInstantVideo:
|
||||||
if case .recordingInstantVideo = rhs {
|
if case .recordingInstantVideo = rhs {
|
||||||
return true
|
return true
|
||||||
@@ -57,12 +71,16 @@ public enum PeerInputActivity: Comparable {
|
|||||||
return 1
|
return 1
|
||||||
case .recordingVoice:
|
case .recordingVoice:
|
||||||
return 2
|
return 2
|
||||||
case .recordingInstantVideo:
|
case .uploadingPhoto:
|
||||||
return 3
|
return 3
|
||||||
case .uploadingInstantVideo:
|
case .uploadingVideo:
|
||||||
return 4
|
return 4
|
||||||
case .playingGame:
|
case .recordingInstantVideo:
|
||||||
return 5
|
return 5
|
||||||
|
case .uploadingInstantVideo:
|
||||||
|
return 6
|
||||||
|
case .playingGame:
|
||||||
|
return 7
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,9 +103,9 @@ extension PeerInputActivity {
|
|||||||
case let .sendMessageUploadDocumentAction(progress):
|
case let .sendMessageUploadDocumentAction(progress):
|
||||||
self = .uploadingFile(progress: progress)
|
self = .uploadingFile(progress: progress)
|
||||||
case let .sendMessageUploadPhotoAction(progress):
|
case let .sendMessageUploadPhotoAction(progress):
|
||||||
self = .uploadingFile(progress: progress)
|
self = .uploadingPhoto(progress: progress)
|
||||||
case let .sendMessageUploadVideoAction(progress):
|
case let .sendMessageUploadVideoAction(progress):
|
||||||
self = .uploadingFile(progress: progress)
|
self = .uploadingVideo(progress: progress)
|
||||||
case .sendMessageRecordRoundAction:
|
case .sendMessageRecordRoundAction:
|
||||||
self = .recordingInstantVideo
|
self = .recordingInstantVideo
|
||||||
case .sendMessageUploadRoundAction:
|
case .sendMessageUploadRoundAction:
|
||||||
|
|||||||
@@ -458,6 +458,10 @@ public final class PendingMessageManager {
|
|||||||
if attribute.flags.contains(.disableLinkPreviews) {
|
if attribute.flags.contains(.disableLinkPreviews) {
|
||||||
flags |= Int32(1 << 1)
|
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
|
#endif
|
||||||
|
|
||||||
public func removePeerMember(account: Account, peerId: PeerId, memberId: PeerId) -> Signal<Void, NoError> {
|
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
|
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 peer = modifier.getPeer(peerId), let memberPeer = modifier.getPeer(memberId), let inputUser = apiInputUser(memberPeer) {
|
||||||
if let group = peer as? TelegramGroup {
|
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 {
|
} else {
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func fetchAndUpdateCachedParticipants(peerId: PeerId, network: Network, postbox:
|
|||||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||||
return postbox.modify { modifier -> Void in
|
return postbox.modify { modifier -> Void in
|
||||||
switch result {
|
switch result {
|
||||||
case let .channelParticipants(_, participants, users):
|
case let .channelParticipants(count, participants, users):
|
||||||
var peers: [Peer] = []
|
var peers: [Peer] = []
|
||||||
var peerPresences: [PeerId: PeerPresence] = [:]
|
var peerPresences: [PeerId: PeerPresence] = [:]
|
||||||
for user in users {
|
for user in users {
|
||||||
@@ -37,7 +37,7 @@ func fetchAndUpdateCachedParticipants(peerId: PeerId, network: Network, postbox:
|
|||||||
|
|
||||||
modifier.updatePeerCachedData(peerIds: [peerId], update: { peerId, currentData in
|
modifier.updatePeerCachedData(peerIds: [peerId], update: { peerId, currentData in
|
||||||
if let currentData = currentData as? CachedChannelData {
|
if let currentData = currentData as? CachedChannelData {
|
||||||
return currentData.withUpdatedTopParticipants(parsedParticipants)
|
return currentData.withUpdatedTopParticipants(parsedParticipants).withUpdatedParticipantsSummary(currentData.participantsSummary.withUpdatedMemberCount(count))
|
||||||
} else {
|
} else {
|
||||||
return currentData
|
return currentData
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user